# Which array does dstArrayElement refer to in the VkWriteDescriptorSet structure?

Here is the link of VkWriteDescriptorSet structure from vulkan specification:

https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkWriteDescriptorSet.html

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?

• Thank you so much DMGregory,you helpd me again 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.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
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.

• "VkDescriptorSetLayoutBinding allows to describe not only one resource,"do you mean only one type of resource? Mar 18 at 8:53
• 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. Mar 18 at 9:41
• Oh，my bad.I thought is was "allows to describe only one resource."Don't know why I accidentally ignore the "not" here Mar 18 at 11:10