Open Mr-222 opened 5 days ago
Thanks for reporting this!
I guess my first question is why you needed VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT
(this is me grasping how people use the VVL settings)
We are currently getting things ready for the upcoming SDK, so will be a while until I can look at this, but thanks for deep investigation you have done so far
Thank you spencer, take your time! For the question, I need the extension to disable the handle wrapping feature so that I can access the “real” object allocated by the driver for some backdoor APIs. Also, I'm a little curious about the driver behavior, do you have any clue about what decides if the driver would reuse old swapchain's image handle or not?
Also reformatted the codeblock in my description to make it clear, sorry for the inexperience of issuing if you think the codeblock is messy.
do you have any clue about what decides if the driver would reuse old swapchain's image handle or not?
It took me years and I still feel I don't understand the Linux Windowing system... Windows is worse as I have no idea how drivers interact with WSI on Windows
lol, got it!
Environment:
Describe the Issue
This issue heavily depends on driver implementation, I only observe this issue in NVIDIA GPU.
When VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT is enabled, which means I manually disable the handle wrapping. At this time, when recreating a swapchain by calling
vkCreateSwapchainKHR
with oldswapchain parameter, the validation layer will ignore situations likeVKImage
from different swapchains uses same handles. So we may get same image handles used by old swapchains when callingvkGetSwapchainImagesKHR
, which the validation layer is not properly handled. Here's a simple example:When destroy the swapchain1, the validation layer would also delete the swapchain's images in the
StateMap
andObjectTable
without checking if newly created swapchain is using those image handles. However, swapchain2 is still using those images. As a result, the program would crash afterwards because it can't find corresponding image handle when creating image view and framebuffer for the new swapchain.A simple reproduce
You can use Vulkan sample to reproduce this bug crash easily, just add the VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT extension. What I did is change the
Instance.cpp
inVulkan-Samples/framework/core
, change the constructor ofInstance
, add the extension:Also add the instance extension in
ray_tracing_basic.cpp
:After that, run
ray_tracing_basic
sample, it may crash. It may also crashes when you resize the window. Note that there's a probability to this thing, because the GPU drive doesn't always choose to reuse image handles when recreating a swapchain. According to my experiments, this bug happens four times out of ten, and it only happens when using NVIDIA GPU. So if you don't see this bug crash at the first time, try resize the window multiple times or relaunch the sample several times.Possible cause
There are 3 places in the code that contributes this bug, the validation layer doesn't check if the image handle is being used by newly created swapchain.
First is in
image_state.cpp
, line605
, this would cause validation layer can't create its image view object.The second one lies in
object_tracker_utils
, line820
:The last one is in
thread_safety_validation.cpp
, line476
: