descriptorCount 在 VkDescriptorSetLayoutBinding 中表示描述符集绑定的描述符数量。

huangapple go评论46阅读模式
英文:

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&lt;VkDescriptorSetLayoutBinding, 2&gt; 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();
}

huangapple
  • 本文由 发表于 2023年6月16日 05:08:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76485526.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定