且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Vulkan 描述符绑定

更新时间:2021-09-03 02:16:11

vkUpdateDescriptorSets 未与任何内容同步.因此,您不能在使用中更新描述符集.您必须确保使用相关描述符集的所有渲染操作都已完成,并且未将任何命令放置在使用相关描述符集的命令缓冲区中.

vkUpdateDescriptorSets is not synchonrized with anything. Therefore, you cannot update a descriptor set while it is in use. You must ensure that all rendering operations that use the descriptor set in question have finished, and that no commands have been placed in command buffers that use the set in question.

它基本上就像一个全局变量;你不能让人们在没有某种同步的情况下从多个线程访问全局变量.而且 Vulkan 不会同步对描述符集的访问.

It's basically like a global variable; you can't have people accessing a global variable from numerous threads without some kind of synchronization. And Vulkan doesn't synchronize access to descriptor sets.

有几种方法可以解决这个问题.您可以为每个对象提供其自己的描述符集.这通常是通过使频繁变化的描述符集数据具有比不太频繁变化的数据更高的索引来实现的.这样,您就不会更改每个对象的每个描述符,而只会更改每个对象的描述符.

There are several ways to deal with this. You can give each object its own descriptor set. This is usually done by having the frequently changing descriptor set data be of a higher index than the less frequently changing data. That way, you're not changing every descriptor for each object, only the ones that change on a per-object basis.

您可以使用推送常量数据来索引大表/数组纹理.所以描述符集将有一个数组纹理或一个纹理数组(如果你有纹理数组的动态索引).推送常量将提供一个索引,着色器使用该索引从数组纹理/纹理数组中获取该特定对象的纹理.这使得频繁更改相当便宜,并且相同的索引也可以用于为每个对象提供自己的变换矩阵(通过获取矩阵数组).

You can use push constant data to index into large tables/array textures. So the descriptor set would have an array texture or an array of textures (if you have dynamic indexing for arrays of textures). A push constant would provide an index, which is used by the shader to fetch that particular object's texture from the array texture/array of textures. This makes frequent changes fairly cheap, and the same index can also be used to give each object its own transformation matrices (by fetching into an array of matrices).

如果您有可用的扩展 VK_KHR_push_descriptor,那么您可以将描述符的更改直接集成到命令缓冲区中.这比推送常量机制好多少当然取决于实现.

If you have the extension VK_KHR_push_descriptor available, then you can integrate changes to descriptors directly into the command buffer. How much better this is than the push constant mechanism is of course implementation-dependent.