英文:
What does descriptorCount mean in VkDescriptorSetLayoutBinding?
问题
DescriptorCount 是指着色器接受的数组中元素的数量。所以,如果着色器接受了 vec4 vecs[5],那么 descriptorCount 的值应该是 5,对吗?
英文:
I use all this to create a uniform buffer. I would like to make sure I understand it correctly. DescriptorCount refers to the number of elements in the array that the shader accepts. So if the shader took vec4 vecs[5], the descriptorCount value would be 5, right?
答案1
得分: 1
是的,descriptorCount
指的是绑定拥有的元素数量(单个元素为1,数组为大于1)。
因此,要创建这个统一配置:
layout(binding = 0) buffer Buffer { uint x[]; } single;
layout(binding = 1) buffer Buffer { uint x[]; } array[5];
您需要指定两个具有不同描述符计数的绑定:
std::array<VkDescriptorSetLayoutBinding, 2> bindings{{
.binding = 0,
.descriptorCount = 1,
...
},{
.binding = 1,
.descriptorCount = 5,
...
}};
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo{
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
.bindingCount = bindings.size();
.pBindings = bindings.data();
}
英文:
Yes, descriptorCount
refers to the number of elements that the binding has (1 for single elements, > 1 for arrays).
So to create this uniform configuration
layout(binding = 0) buffer Buffer { uint x[]; } single;
layout(binding = 1) buffer Buffer { uint x[]; } array[5];
you would have to specify two bindings with different descriptor counts.
std::array<VkDescriptorSetLayoutBinding, 2> bindings{{
.binding = 0,
.descriptorCount = 1,
...
},{
.binding = 1,
.descriptorCount = 5,
...
}};
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo{
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
.bindingCount = bindings.size();
.pBindings = bindings.data();
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论