Nabla
Nabla copied to clipboard
Support Descriptor Indexing in Vulkan
I believe It's the case where descriptorIndexing device extension is enabled and also physDevDescriptorIndexingFeatures.descriptorBindingVariableDescriptorCount
is equal to VK_TRUE
meaning you'd enable variable sized descriptor arrays for shaders. (must be the last binding in the set)
So you don't know your the length of your variable-sized descriptor up to the point you actually want to allocate it's descriptorSet from the descriptorPool. This is what this struct is for; and It's basically asking for the "Count" of the "VariableCount" descriptors.
descriptorBindingVariableDescriptorCount indicates whether the implementation supports descriptor sets with a variable-sized last binding. If this feature is not enabled, VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT must not be used.
In order to expose thisIGPUDescriptorSetLayout::SBinding
should have an enum (a flag) related to this Vulkan Enum:
typedef enum VkDescriptorBindingFlagBits {
VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT = 0x00000001,
VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT = 0x00000002,
VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT = 0x00000004,
VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT = 0x00000008,
.
.
.
} VkDescriptorBindingFlagBits;
In order for it to work you should also give the binding the correct flag when creating the DescriptorSetLayout
.
VkDescriptorSetLayoutBindingFlagsCreateInfoEXT
in the pNext chain of VkDescriptorSetLayoutCreateInfo
Also we can do some validation ourselves here: for example check if the binding with the flagVARIABLE_DESCRIPTOR_COUNT_BIT
is the last binding number in the set.
as mentioned here in the commetns https://github.com/Devsh-Graphics-Programming/Nabla/blob/6634885ebe66f4e9ba1657631f0902e0773ff7ba/src/nbl/video/CVKLogicalDevice.h#L1003
Originally posted by @Erfan-Ahmadi in https://github.com/Devsh-Graphics-Programming/Nabla/pull/160#discussion_r690916570
if the variable count binding needs to be the last one, no point having that flag on the binding, better have it on the entire set :)