# 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.2646290063858032, "perplexity": 3700.2006751761005}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-39/segments/1631780055645.75/warc/CC-MAIN-20210917120628-20210917150628-00038.warc.gz"}