QRhiRenderPassDescriptor Class
渲染传递资源。更多
头文件: | #include <rhi/qrhi.h> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate) |
qmake: | QT += gui-private |
自 | Qt 6.6 |
继承: | QRhiResource |
公共函数
virtual bool | isCompatible(const QRhiRenderPassDescriptor *other) const = 0 |
virtual const QRhiNativeHandles * | nativeHandles() |
virtual QRhiRenderPassDescriptor * | newCompatibleRenderPassDescriptor() const = 0 |
virtual QVector<quint32> | serializedFormat() const = 0 |
重新实现的公共函数
virtual QRhiResource::Type | resourceType() const override |
详细说明
如果底层图形 API 中存在渲染传递(render pass)这一概念,那么渲染传递就是一系列附件(颜色、深度、模板)的集合,并描述了如何使用这些附件。
注意: 这是一个 RHI API,兼容性保证有限,详情请参见QRhi 。
成员函数文档
[pure virtual]
bool QRhiRenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const
如果other QRhiRenderPassDescriptor 与此 兼容,则返回 true,这意味着this
和other 可以在QRhiGraphicsPipeline::setRenderPassDescriptor() 中互换使用。
renderpass 描述符的兼容性概念与layout compatibility 的QRhiShaderResourceBindings 实例类似。它们允许更好地重用QRhiGraphicsPipeline 实例:例如,QRhiGraphicsPipeline 实例缓存有望使用这些函数来查找匹配的管道,而不仅仅是比较指针,从而允许不同的QRhiRenderPassDescriptor 和QRhiShaderResourceBindings 与管道结合使用,只要它们是兼容的。
兼容性的具体细节取决于底层图形应用程序接口。来自同一个QRhiTextureRenderTarget 的两个 renderpass 描述符created 总是兼容的。
与QRhiShaderResourceBindings 类似,也可以在没有两个现有对象的情况下测试兼容性。通过调用serializedFormat() 提取不透明 blob,可以将返回的向量与另一个QRhiRenderPassDescriptor 的serializedFormat() 进行比较,从而测试兼容性。这在某些情况下有好处,因为它允许测试QRhiRenderPassDescriptor 与QRhiGraphicsPipeline 的兼容性,即使最初构建管道的QRhiRenderPassDescriptor 已不再可用(但其serializedFormat() 返回的数据仍然可用)。
另请参阅 newCompatibleRenderPassDescriptor() 和serializedFormat()。
[virtual]
const QRhiNativeHandles *QRhiRenderPassDescriptor::nativeHandles()
返回指向特定于后端QRhiNativeHandles 子类(如QRhiVulkanRenderPassNativeHandles )的指针。当后端不支持公开底层本地资源时,返回值为nullptr
。
另请参阅 QRhiVulkanRenderPassNativeHandles 。
[pure virtual]
QRhiRenderPassDescriptor *QRhiRenderPassDescriptor::newCompatibleRenderPassDescriptor() const
返回一个与compatible 相同的新QRhiRenderPassDescriptor 。
该函数允许克隆QRhiRenderPassDescriptor 。返回的对象可以随时使用,其所有权将转移给调用者。克隆QRhiRenderPassDescriptor 对象在以下情况下非常有用:该对象存储在与图形管道相关的数据结构中(以便创建新管道,而创建新管道又需要渲染通道描述符对象),而从渲染目标创建的渲染通道描述符的生命周期可能比管道短。(在这种情况下,在数据结构中存储一个克隆版本,从而转移所有权,可能会有好处。
另请参见 isCompatible()。
[override virtual]
QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const
重实现:QRhiResource::resourceType() 常量。
返回资源类型。
[pure virtual]
QVector<quint32> QRhiRenderPassDescriptor::serializedFormat() const
返回一个整数向量,其中包含一个描述compatibility 相关数据的不透明 blob。
给定两个QRhiRenderPassDescriptor 对象rp1
和rp2
,如果该函数返回的数据相同,则rp1->isCompatible(rp2)
,反之亦然。
注意: 调用该函数预计将是一种廉价操作,因为后端不应该计算该函数中的数据,而是返回一系列已经计算过的数据。
在创建作为库一部分的可重用组件时,图形管道的创建和维护都以库客户端管理的QRhiRenderTarget (无论是交换链还是纹理)为目标,因此组件必须能够处理不断变化的QRhiRenderPassDescriptor 。例如,由于渲染目标发生变化,先前的QRhiRenderPassDescriptor (至少与新的渲染目标有关)就会失效,因为现在的颜色格式和附件可能不同。或者因为variable rate shading 是动态使用的。有一种简单的模式可以帮助解决这个问题,那就是在每一帧上执行以下检查,以识别管道需要与新的QRhiRenderPassDescriptor 关联的情况,因为现在的呈现目标与之前的帧相比有些不同:
QRhiRenderPassDescriptor *rp = m_renderTarget->renderPassDescriptor(); if (m_pipeline && rp->serializedFormat() != m_renderPassFormat) { m_pipeline->setRenderPassDescriptor(rp); m_renderPassFormat = rp->serializedFormat(); m_pipeline->create(); } // remember to store m_renderPassFormat also when creating m_pipeline the first time
另请参见 isCompatible().
© 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.