Skip to content

layers: Handle oldSwapchain image reuse#11990

Merged
artem-lunarg merged 1 commit intoKhronosGroup:mainfrom
artem-lunarg:artem-issue-11939
Mar 27, 2026
Merged

layers: Handle oldSwapchain image reuse#11990
artem-lunarg merged 1 commit intoKhronosGroup:mainfrom
artem-lunarg:artem-issue-11939

Conversation

@artem-lunarg
Copy link
Copy Markdown
Contributor

@artem-lunarg artem-lunarg commented Mar 27, 2026

oldSwapchain images can be reused by the new swapchain. This PR handles this when handle wrapping is not enabled.

I updated the state tracker and thread safety tracker to account for the reuse of swapchain images. Potentially, other trackers may also need to be updated, but I'd prefer to address that later once there's specific evidence and this change has been tested for some time.

Closes #11939

ADDITIONAL CONTEXT: Swapchain image handle reuse is a bit different comparing to handle reuse in most (all?) other cases. In a typical case of handle reuse we a) delete resource, then b) try to create another resource and the driver reuses the handle of deleted resource. At any given moment the handle is associated with a single object. In most cases that can be naturally handled by the VVL (Delete has to properly cleanup resources).

With swapchain it is different. If oldSwapchain is used then both swapchains exist at the same time. The image handle can be associated with two swapchain objects. That's why special support is needed (Delete can't unconditionally cleanup swapchain image handles). I don't know of any other example in Vulkan that also requires such handling.

@ci-tester-lunarg
Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 692038.

@ci-tester-lunarg
Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 22968 running.

@artem-lunarg
Copy link
Copy Markdown
Contributor Author

artem-lunarg commented Mar 27, 2026

Need to investigate PositiveWsi.DestroySwapchainBeforeLayoutValidation failure on Samsung Galaxy.

Validation Error: [ VUID-VkPresentInfoKHR-pImageIndices-01430 ] | MessageID = 0x48ad24c6
vkQueuePresentKHR(): pPresentInfo->pSwapchains[0] images passed to present must be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR but VkImage 0xb400006f64025910 is in VK_IMAGE_LAYOUT_UNDEFINED.

@ci-tester-lunarg
Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 22968 failed.

oldSwapchain images can be reused by the new swapchain.
This change handles this scenario when handle wrapping is not enabled
@ci-tester-lunarg
Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build queued with queue ID 692298.

@ci-tester-lunarg
Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 22973 running.

@artem-lunarg artem-lunarg marked this pull request as ready for review March 27, 2026 16:03
@artem-lunarg artem-lunarg requested a review from a team as a code owner March 27, 2026 16:03
Copy link
Copy Markdown
Contributor

@spencer-lunarg spencer-lunarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for clarifying and taking care of the oldSwapchain stuff!

@ci-tester-lunarg
Copy link
Copy Markdown
Collaborator

CI Vulkan-ValidationLayers build # 22973 passed.

@artem-lunarg artem-lunarg merged commit 2586cd1 into KhronosGroup:main Mar 27, 2026
20 checks passed
@artem-lunarg artem-lunarg deleted the artem-issue-11939 branch March 27, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash on resize when using GPU-AV

3 participants