KhronosGroup / Vulkan-ValidationLayers

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

[VUID-vkCmdDrawIndexedIndirect-None-02699] Validation Error popping despite descriptor not used #5322

Closed FlorianLuna closed 10 months ago

FlorianLuna commented 1 year ago

Environment:

Hello,

While testing bindless (so using the indexing feature) VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES

I have the following validation layer error: _[VUID-vkCmdDrawIndexedIndirect-None-02699] Validation Error: [ VUID-vkCmdDrawIndexedIndirect-None-02699 ] Object 0: handle = 0xb8eaa6000033e070, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; | MessageID = 0x9410d614 | Descriptor set VkDescriptorSet 0xb8eaa6000033e070[] encountered the following validation error at vkCmdDrawIndexedIndirect() time: Descriptor in binding #0 index 252 is being used in draw but has never been updated via vkUpdateDescriptorSets() or a similar call_

However, I am 99.99% sure that the descriptor at the index 252 is never used (it's however true that it was not updated) but it is supposed to work fine when using the flags at descriptor layout creation.

const VkDescriptorBindingFlags bindlessFlag = VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT;

Also in the shader, I made sure that the 252 index is never used by doing something like this (we use a wrapper to have a cross-platform language) sampleGrad(txMyTexture[min(250,_index)], ssMyTexture[_uv, _uvDx, _uvDy);

So it should be impossible to reach index 252 (the texture binding slot is not used elsewhere). If I update the set until index 252 on the cpu side the error doesnt show up.

It seems the validation error is a false positive but maybe I am missing something.

How I create the descriptors The indexing feature is queued in my pnext chain ``` VkPhysicalDeviceDescriptorIndexingFeatures indexingFeatures{}; indexingFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES; indexingFeatures.pNext = nullptr; VkPhysicalDeviceFeatures2 physicalFeatures2 {}; physicalFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; physicalFeatures2.pNext = &indexingFeatures; ``` Descriptor layout is created like ``` VkDescriptorSetLayoutCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; createInfo.bindingCount = bindings.size(); createInfo.pBindings = bindings.data(); VkDescriptorSetLayoutBindingFlagsCreateInfo extendedInfo{}; const VkDescriptorBindingFlags bindlessFlags = VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT | VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT; if (hasBindless) { extendedInfo.pNext = nullptr; extendedInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO; extendedInfo.pBindingFlags = &bindlessFlags; createInfo.pNext = &extendedInfo; } VkDescriptorSetLayout newLayout; VulkanAssertSuccess(vkCreateDescriptorSetLayout(s_device, &createInfo, VK_ALLOC, &newLayout)); ``` descriptors are updated in a classic way (I don't that it needs something different than usual like a flag or something like that) Shader code looks roughly like that (we use an abstraction layer to make it cross-platforms) ``` #extension GL_EXT_nonuniform_qualifier : enable layout (set = BINDLESS_SET) uniform sampler2D txMyTexture[]; SamplerState ssMyTexture; float4 SampleMyTexture(uint _index, float2 _uv, float2 _uvDx, float2 _uvDy) { return sampleGrad(txMyTexture(min(250,_index)], ssMyTextyre, _uv, _uvDx, _uvDy); } ``` I spent some time digging what's wrong in my code but even when I explicitely reject any index > 250 I still have the issue. Maybe you have an insight regarding this issue. Thanks
FlorianLunaWild commented 1 year ago

(using my company account also to follow the thread)

FlorianLunaWild commented 1 year ago

I can also confirm that commenting the texture sampling line in the shader fixes the validation error. So despite the min it still thinks that index 252 is used.

jeremyg-lunarg commented 10 months ago

This should be fixed by https://github.com/KhronosGroup/Vulkan-ValidationLayers/pull/6883