QSSGRhiContext Class

QSSGRhiContext. More...

Header: #include <QSSGRhiContext>
Since: Qt 6.7

Public Functions

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)

Detailed Description

Member Function Documentation

void QSSGRhiContext::checkAndAdjustForNPoT(QRhiTexture *texture, QSSGRhiSamplerDescription *samplerDescription)

Adjusts samplerDescription's tiling and filtering modes based on the pixel size of texture.

In most cases, samplerDescription is not changed. With older, legacy 3D APIs in use, there is however a chance that tiling modes such as QRhiSampler::Repeat are not supported for textures with a non-power-of-two width or height.

This convenience function helps creating robust applications that can still function even when features such as QRhi::NPOTTextureRepeat are not supported by an OpenGL ES 2.0 or WebGL 1 implementation at run time.

QRhiCommandBuffer *QSSGRhiContext::commandBuffer() const

Returns The current frame's command buffer used by the Qt Quick 3D renderer.

QRhiCommandBuffer::BeginPassFlags QSSGRhiContext::commonPassFlags() const

Returns The recommended flags when calling QRhiCommandBuffer::beginPass().

QRhiTexture *QSSGRhiContext::dummyTexture(QRhiTexture::Flags flags, QRhiResourceUpdateBatch *rub, const QSize &size = QSize(64, 64), const QColor &fillColor = Qt::black, int arraySize = 0)

Returns a texture that has the specified flags and pixel size.

This is intended to efficiently gain access to a "dummy" texture filled with a given fillColor, and reused in various places in the rendering stack.

rub must be a valid QRhiResourceUpdateBatch since this function will create a new texture and generate content for it, if a suitable cached object is not found. The necessary upload operations are then enqueued on this given update batch.

When arraySize is 2 or more, a 2D texture array is returned.

The ownership of the returned texture stays with Qt Quick 3D.

bool QSSGRhiContext::isValid() const

Returns true if the renderer is initialized successfully.

int QSSGRhiContext::mainPassSampleCount() const

Returns the sample count used in the main render pass.

int QSSGRhiContext::mainPassViewCount() const

Returns the multiview count used in the main render pass. This is either 2, when multiview rendering is in use, or 1 (no multiview).

QRhiRenderPassDescriptor *QSSGRhiContext::mainRenderPassDescriptor() const

Returns The QRhiRenderPassDescriptor used by the main render pass of the Qt Quick 3D renderer.

QRhiRenderTarget *QSSGRhiContext::renderTarget() const

Returns The render target the Qt Quick 3D renderer uses for its main render pass in the current frame.

This can effectively be a render target from a swapchain, if the View3D uses a renderMode other than Offscreen. More commonly, the render target refers to a texture (i.e., is a QRhiTextureRenderTarget), e.g. because the renderMode is the default Offscreen, or because post-processing effects are in use.

QRhi *QSSGRhiContext::rhi() const

Returns The QRhi object used by the Qt Quick 3D renderer.

QRhiSampler *QSSGRhiContext::sampler(const QSSGRhiSamplerDescription &samplerDescription)

Returns a sampler with the filter and tiling modes specified in samplerDescription.

The generated QRhiSampler objects are cached and reused. Thus this is a convenient way to gain access to a QRhiSampler with the given settings, without having to create a new, dedicated object all the time.

The ownership of the returned QRhiSampler stays with Qt Quick 3D.