vulkan 绑定在着色器中必须是顺序的吗
does vulkan bindings have to be sequential in shaders
在 vulkan 中,制服、变量或属性的绑定是否必须按顺序进行?
假设我们有
layout (std140, set = 0, binding = 0) uniform ubo1 {}
layout (std140, set = 0, binding = 3) uniform ubo2 {}
允许吗?属性绑定也一样。?
是的,这在着色器代码中是允许的。不太确定实现。
您可以查看 VkDescriptorSetLayoutCreateInfo
的文档,了解定义描述符集布局所涉及的内容。您会注意到 VkDescriptorSetLayoutBinding
允许在任意索引处指定绑定。
作为个人偏好的问题(并且我没有找到关于此事的任何明确措辞),我根本不相信实现可以直观地处理这个问题。因此,我创建了 "fill in the gaps".
的空绑定
不,它们不一定要塞得严严实实。在 Descriptor Layout 描述 (13.2.1) 中,规范说:
Bindings that are not specified have a descriptorCount and stageFlags of zero, and the descriptorType is treated as undefined. However, all binding numbers between 0 and the maximum binding number in the VkDescriptorSetLayoutCreateInfo::pBindings array may consume memory in the descriptor set layout even if not all descriptor bindings are used, though it should not consume additional memory from the descriptor pool.
Note: The maximum binding number specified should be as compact as possible to avoid wasted memory.
在 vulkan 中,制服、变量或属性的绑定是否必须按顺序进行? 假设我们有
layout (std140, set = 0, binding = 0) uniform ubo1 {}
layout (std140, set = 0, binding = 3) uniform ubo2 {}
允许吗?属性绑定也一样。?
是的,这在着色器代码中是允许的。不太确定实现。
您可以查看 VkDescriptorSetLayoutCreateInfo
的文档,了解定义描述符集布局所涉及的内容。您会注意到 VkDescriptorSetLayoutBinding
允许在任意索引处指定绑定。
作为个人偏好的问题(并且我没有找到关于此事的任何明确措辞),我根本不相信实现可以直观地处理这个问题。因此,我创建了 "fill in the gaps".
的空绑定不,它们不一定要塞得严严实实。在 Descriptor Layout 描述 (13.2.1) 中,规范说:
Bindings that are not specified have a descriptorCount and stageFlags of zero, and the descriptorType is treated as undefined. However, all binding numbers between 0 and the maximum binding number in the VkDescriptorSetLayoutCreateInfo::pBindings array may consume memory in the descriptor set layout even if not all descriptor bindings are used, though it should not consume additional memory from the descriptor pool.
Note: The maximum binding number specified should be as compact as possible to avoid wasted memory.