KhronosGroup / Vulkan-ValidationLayers

Vulkan Validation Layers (VVL)
https://vulkan.lunarg.com/doc/sdk/latest/linux/khronos_validation_layer.html
Other
777 stars 407 forks source link

VUID-VkDescriptorImageInfo-imageLayout-00344 false positive #8407

Open Trider12 opened 3 months ago

Trider12 commented 3 months ago

Environment:

Describe the Issue

Here I have two dispatches separated by an image barrier: image The barrier looks like this: image

The first dispatch writes to mip 1, the barrier transitions it from VK_IMAGE_LAYOUT_GENERAL to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, and the second dispatch reads from mip 1.

Both shaders access the mips like this:

layout(set = 0, binding = 25) uniform texture2D framebufferTextureMips[];
layout(set = 0, binding = 26, rgba16f) uniform image2D framebufferImageMips[];

Both arrays are backed by the same array of image views, each pointing to a single mip. The texture descriptors are updated with VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL and the image ones with VK_IMAGE_LAYOUT_GENERAL.

Afaik, my usage here is correct, but at the second dispatch call I get a validation error, saying that the layout of mip 1 is still VK_IMAGE_LAYOUT_GENERAL despite the barrier before the call.

Expected behavior

No validation error.

Valid Usage ID

VUID-VkDescriptorImageInfo-imageLayout-00344(ERROR / SPEC): msgNum: -564812795 - Validation Error: [ VUID-VkDescriptorImageInfo-imageLayout-00344 ] Object 0: handle = 0x1c737122030, type = VK_OBJECT_TYPE_COMMAND_BUFFER; Object 1: handle = 0x2b424a0000000034, name = frameBufferImage, type = VK_OBJECT_TYPE_IMAGE; | MessageID = 0xde55a405 | vkCmdDispatch(): Cannot use VkImage 0x2b424a0000000034[frameBufferImage] (layer=0 mip=1) with specific layout VK_IMAGE_LAYOUT_GENERAL that doesn't match the previous known layout VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. The Vulkan spec states: imageLayout must match the actual VkImageLayout of each subresource accessible from imageView at the time this descriptor is accessed as defined by the image layout matching rules (https://vulkan.lunarg.com/doc/view/1.3.290.0/windows/1.3-extensions/vkspec.html#VUID-VkDescriptorImageInfo-imageLayout-00344)

spencer-lunarg commented 3 months ago

I think this the same issue as https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/4646 and requires someone to go in and write tests and cleanup how we do layout transition tracking with miplevels