QSSGRhiContext Class
QSSGRhiContext。更多...
| Header: | #include <qssgrhicontext.h> |
| Since: | Qt 6.7 |
公共函数
| void | checkAndAdjustForNPoT(QRhiTexture *texture, QSSGRhiSamplerDescription *samplerDescription) |
| QRhiCommandBuffer * | commandBuffer() const |
| QRhiCommandBuffer::BeginPassFlags | commonPassFlags() const |
| QRhiTexture * | dummyTexture(QRhiTexture::Flags flags, QRhiResourceUpdateBatch *rub, const QSize &size = QSize(64, 64), const QColor &fillColor = Qt::black, int arraySize = 0) |
| bool | isValid() const |
| int | mainPassSampleCount() const |
| int | mainPassViewCount() const |
| QRhiRenderPassDescriptor * | mainRenderPassDescriptor() const |
| QRhiRenderTarget * | renderTarget() const |
| QRhi * | rhi() const |
| QRhiSampler * | sampler(const QSSGRhiSamplerDescription &samplerDescription) |
成员函数文档
void QSSGRhiContext::checkAndAdjustForNPoT(QRhiTexture *texture, QSSGRhiSamplerDescription *samplerDescription)
根据texture 的像素大小调整samplerDescription 的平铺和过滤模式。
在大多数情况下,samplerDescription 不会被更改。但在使用较旧的、过时的 3D API 时,对于宽度或高度不是 2 的幂的纹理,可能不支持QRhiSampler::Repeat 等平铺模式。
此便捷函数有助于创建健壮的应用程序,即使在运行时 OpenGL ES 2.0 或 WebGL 1 实现不支持QRhi::NPOTTextureRepeat 等功能时,这些应用程序仍能正常运行。
QRhiCommandBuffer *QSSGRhiContext::commandBuffer() const
返回Qt Quick 3D 渲染器所使用的当前帧的命令缓冲区。
QRhiCommandBuffer::BeginPassFlags QSSGRhiContext::commonPassFlags() const
返回调用 `QRhiCommandBuffer::beginPass()` 时推荐使用的标志。
QRhiTexture *QSSGRhiContext::dummyTexture(QRhiTexture::Flags flags, QRhiResourceUpdateBatch *rub, const QSize &size = QSize(64, 64), const QColor &fillColor = Qt::black, int arraySize = 0)
返回一个具有指定flags 和像素size 的纹理。
此函数旨在高效访问一个填充了指定fillColor 的“虚拟”纹理,并在渲染堆栈的各个环节中重复使用。
rub QRhiResourceUpdateBatch 必须是有效的,因为如果找不到合适的缓存对象,该函数将创建一个新的纹理并为其生成内容。随后,必要的上传操作将被排入给定的更新批处理队列中。
当arraySize 等于 2 或更大时,将返回一个 2D 纹理数组。
返回纹理的所有权仍归Qt Quick 3D 所有。
bool QSSGRhiContext::isValid() const
如果渲染器初始化成功,则返回 true。
int QSSGRhiContext::mainPassSampleCount() const
返回主渲染通道中使用的采样数量。
int QSSGRhiContext::mainPassViewCount() const
返回主渲染阶段中使用的多视图计数。该值在启用多视图渲染时为 2,未启用多视图渲染时为 1。
QRhiRenderPassDescriptor *QSSGRhiContext::mainRenderPassDescriptor() const
返回Qt Quick 3D 渲染器的主渲染阶段所使用的QRhiRenderPassDescriptor 。
QRhiRenderTarget *QSSGRhiContext::renderTarget() const
返回Qt Quick 3D 渲染器在当前帧中用于主渲染阶段的渲染目标。
如果View3D 使用的renderMode不是Offscreen,这实际上可以是一个来自交换链(swapchain)的渲染目标。更常见的情况是,渲染目标指的是一张纹理(即QRhiTextureRenderTarget ),例如因为renderMode是默认的Offscreen,或者因为正在使用后处理效果。
QRhi *QSSGRhiContext::rhi() const
返回Qt Quick 3D 渲染器所使用的 `QRhi ` 对象。
QRhiSampler *QSSGRhiContext::sampler(const QSSGRhiSamplerDescription &samplerDescription)
返回一个采样器,其滤波器和平铺模式由samplerDescription 中指定的参数决定。
生成的 `QRhiSampler ` 对象会被缓存并复用。因此,这是一种便捷的方式,可以访问具有给定设置的 `QRhiSampler `,而无需每次都创建一个新的专用对象。
返回的QRhiSampler 的所有权仍归Qt Quick 3D 所有。
© 2026 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.