QQuickWindow::GraphicsStateInfo Struct
struct QQuickWindow::GraphicsStateInfo描述 RHI 在调用beginExternalCommands() 时的一些图形状态。更多
公共变量
int | currentFrameSlot |
int | framesInFlight |
成员变量文档
int GraphicsStateInfo::currentFrameSlot
该变量用于保存记录帧时的当前帧槽索引。
当场景图使用较低级别的 3D API(如 Vulkan 或 Metal)渲染时,Qt XML 有责任确保在开始新帧时阻塞,并发现 CPU 已经比 GPU 超前一定帧数(因为在current
-FramesInFlight
帧号中提交的命令缓冲区尚未完成)。在其他图形应用程序接口(如 OpenGL 或 Direct 3D 11)中,这种级别的控制并不向应用程序接口客户端公开,而是由图形应用程序接口的实现来处理。
推而广之,这也意味着适当的双倍(或三倍)缓冲资源(如缓冲区)要由图形 API 客户端来管理。最常见的情况是,数据在帧间变化的统一缓冲区不能在提交帧时简单地更改其内容,因为在开始记录下一帧时,该帧可能仍处于活动状态("飞行中")。为了避免流水线停滞,一种方法是在引擎盖下设置多个缓冲区(和内存分配),这样至少可以实现此类资源的双缓冲方案。
直接使用图形 API(如 Vulkan)进行整合渲染的应用程序可能希望以与 Qt 渲染引擎的帧提交流程兼容的方式,对自己的图形资源执行类似的双倍或三倍缓冲。这就需要知道飞行中帧的最大数量(通常为 2 或 3)和当前帧槽索引的值,后者是一个 0、1、...、FramesInFlight-1 的数字,然后再绕一圈。前者显示在framesInFlight 变量中。后者,即当前索引,就是这个值。
有关在实践中使用这些值的示例,请参阅{场景图 - QML 下的 Vulkan} 和{场景图 - Vulkan 纹理导入}示例。
int GraphicsStateInfo::framesInFlight
该变量用于保存飞行帧的最大数量。
详细说明请参见currentFrameSlot 。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.