简体   繁体   English

Vulkan,多个对象使用相同的统一缓冲区吗?

[英]Vulkan, same Uniform Buffer for multiple object?

I'm learning the Vulkan API, and I came across a little "problem": 我正在学习Vulkan API,但遇到了一些“问题”:

Currently my program is able to draw, using the Projection-View-Model matrix transformation, a cube at the axis origin: 目前,我的程序能够使用Projection-View-Model矩阵变换在轴原点绘制一个立方体:

I'm using 3 images/imageViews/framebuffers, so for each transformation matrix I have a vector of size 3 that holds them, and everything work perfectly (no errors from the validation layers etc)... the problem is: 我正在使用3个images / imageViews / framebuffers,所以对于每个转换矩阵,我都有一个大小为3的矢量来容纳它们,并且一切工作正常(验证层等没有错误)...问题是:

I now want to draw another object near my cube, so I thought I just had to update the model matrix twice every frame, the first time to position the cube, the second time for the other object, but this cannot work because the cube isn't drawn immediately when registering the command buffer, but when submitting it, so in the end the command buffer would simply use the second update of the model matrix for both the cube and the other object: 现在,我想在立方体附近绘制另一个对象,所以我以为我只需要每帧更新一次模型矩阵两次,第一次是放置立方体,第二次是另一个对象,但这不能工作,因为立方体不是在注册命令缓冲区时不会立即绘制,但在提交命令时会立即绘制,因此最后,命令缓冲区将仅对多维数据集和其他对象使用模型矩阵的第二次更新:

How to handle this situation? 如何处理这种情况?

Thanks. 谢谢。

Make the uniform buffer bigger put the second matrix after the first and point the second draw to the correct offset in the uniform buffer. 使统一缓冲区更大,将第二个矩阵放在第一个矩阵之后,然后将第二个绘制指向统一缓冲区中的正确偏移量。

You can use either separate descriptors or dynamic offsets. 您可以使用单独的描述符或动态偏移量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM