Here is the link of VkWriteDescriptorSet structure from vulkan specification:


Text pertaining dstArrayElement

dstArrayElement is the starting element in that ARRAY. If the descriptor binding identified by dstSet and dstBinding has a descriptor type of VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT then dstArrayElement specifies the starting byte offset within the binding.

I want know which array this statement is refering to?

enter image description here

  • \$\begingroup\$ Thank you so much DMGregory,you helpd me again \$\endgroup\$
    – Mark Peter
    Mar 18 at 8:41

I'll start with a bit context about VkDescriptorSetLayoutBinding and answer your question afterwards.

VkDescriptorSetLayoutBinding allows to describe not only one resource, but an array of resources.

Let's assume that you did not want to use only one texture in a GLSL shader:

layout(set = 0, binding = 0) uniform sampler2D texture;

but an array of textures:

layout(set = 0, binding = 0) uniform sampler2D textures[];

you'd create a VkDescriptorSetLayoutBinding with multiple texture descriptors, e.g. like follows:

VkDescriptorSetLayoutBinding dsLayout = {};
dsLayout.descriptorCount = 100u;

With VkWriteDescriptorSet you write the actual resource information to the GPU, s.t. your shaders know where they can "find" the resource on the GPU... or maybe more accurate: how they can access a certain resource.

If you wanted to write all 100 texture descriptors at once, you'd set the following data:

VkWriteDescriptorSet write = {};
write.dstArrayElement = 0u;
write.descriptorCount = 100u;

But if only the 70th texture has changed, you'd like to update only that one with:

VkWriteDescriptorSet write = {};
write.dstArrayElement = 69u;
write.descriptorCount = 1u;

So, to answer your question: dstArrayElement refers to the array of descriptors defined in VkDescriptorSetLayoutBinding. There will be many cases where VkDescriptorSetLayoutBinding only describes one descriptor (one could also say: an array of length 1), but if you use one VkDescriptorSetLayoutBinding to describe an array of resources, you might not always want to update all of them, but only one (or a few) by specifying an offset into the array of descriptors via dstArrayElement.

Btw.: VkDescriptorSetLayoutBinding and VkWriteDescriptorSet are linked to the same resource via its binding and dstBinding members, respectively.

  • \$\begingroup\$ "VkDescriptorSetLayoutBinding allows to describe not only one resource,"do you mean only one type of resource? \$\endgroup\$
    – Mark Peter
    Mar 18 at 8:53
  • 1
    \$\begingroup\$ No, I really meant "not only one resource". When I refer to "multiple resources" that can be e.g. "multiple textures" and hence "multiple resources". But it is true that the resource type can be set only once for an instance of VkDescriptorSetLayoutBinding. \$\endgroup\$
    – j00hi
    Mar 18 at 9:41
  • \$\begingroup\$ Oh,my bad.I thought is was "allows to describe only one resource."Don't know why I accidentally ignore the "not" here \$\endgroup\$
    – Mark Peter
    Mar 18 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.