QRhiTextureRenderTarget Class

Texture render target resource. 更多...

头: #include <QRhiTextureRenderTarget>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Since: Qt 6.6
继承: QRhiRenderTarget

公共类型

enum Flag { PreserveColorContents, PreserveDepthStencilContents }
flags Flags

公共函数

virtual bool create () = 0
QRhiTextureRenderTargetDescription description () const
QRhiTextureRenderTarget::Flags flags () const
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor () = 0
void setDescription (const QRhiTextureRenderTargetDescription & desc )
void setFlags (QRhiTextureRenderTarget::Flags f )

重实现公共函数

virtual QRhiResource::Type resourceType () const override

详细描述

A texture render target allows rendering into one or more textures, optionally with a depth texture or depth/stencil renderbuffer.

For multisample rendering the common approach is to use a renderbuffer as the color attachment and set the non-multisample destination texture as the resolve texture .

注意: Textures used in combination with QRhiTextureRenderTarget must be created with the QRhiTexture::RenderTarget 标志。

The simplest example of creating a render target with a texture as its single color attachment:

QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, size, 1, QRhiTexture::RenderTarget);
texture->create();
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ texture });
rp = rt->newCompatibleRenderPassDescriptor();
rt->setRenderPassDescriptor(rt);
rt->create();
// rt can now be used with beginPass()
					

注意: This is a RHI API with limited compatibility guarantees, see QRhi 了解细节。

成员类型文档编制

enum QRhiTextureRenderTarget:: Flag
flags QRhiTextureRenderTarget:: Flags

Flag values describing the load/store behavior for the render target. The load/store behavior may be baked into native resources under the hood, depending on the backend, and therefore it needs to be known upfront and cannot be changed without rebuilding (and so releasing and creating new native resources).

常量 描述
QRhiTextureRenderTarget::PreserveColorContents 1 << 0 Indicates that the contents of the color attachments is to be loaded when starting a render pass, instead of clearing. This is potentially more expensive, especially on mobile (tiled) GPUs, but allows preserving the existing contents between passes.
QRhiTextureRenderTarget::PreserveDepthStencilContents 1 << 1 Indicates that the contents of the depth texture is to be loaded when starting a render pass, instead clearing. Only applicable when a texture is used as the depth buffer ( QRhiTextureRenderTargetDescription::depthTexture () is set) because depth/stencil renderbuffers may not have any physical backing and data may not be written out in the first place.

Flags 类型是 typedef 对于 QFlags <Flag>。它存储 Flag 值的 OR 组合。

成员函数文档编制

[pure virtual] bool QRhiTextureRenderTarget:: create ()

Creates the corresponding native graphics resources. If there are already resources present due to an earlier create() with no corresponding destroy (),然后 destroy () is called implicitly first.

注意: renderPassDescriptor () must be set before calling create(). To obtain a QRhiRenderPassDescriptor compatible with the render target, call newCompatibleRenderPassDescriptor () before create() but after setting all other parameters, such as description () 和 flags (). To save resources, reuse the same QRhiRenderPassDescriptor with multiple QRhiTextureRenderTarget instances, whenever possible. Sharing the same render pass descriptor is only possible when the render targets have the same number and type of attachments (the actual textures can differ) and the same flags.

注意: resources, such as QRhiTexture instances, referenced in description () must already have create() called on them.

返回 true when successful, false when a graphics operation failed. Regardless of the return value, calling destroy () is always safe.

QRhiTextureRenderTargetDescription QRhiTextureRenderTarget:: description () const

Returns the render target description.

另请参阅 setDescription ().

QRhiTextureRenderTarget::Flags QRhiTextureRenderTarget:: flags () const

Returns the currently set flags.

另请参阅 setFlags ().

[pure virtual] QRhiRenderPassDescriptor *QRhiTextureRenderTarget:: newCompatibleRenderPassDescriptor ()

返回新的 QRhiRenderPassDescriptor that is compatible with this render target.

The returned value is used in two ways: it can be passed to setRenderPassDescriptor () 和 QRhiGraphicsPipeline::setRenderPassDescriptor (). A render pass descriptor describes the attachments (color, depth/stencil) and the load/store behavior that can be affected by flags (). A QRhiGraphicsPipeline can only be used in combination with a render target that has a compatible QRhiRenderPassDescriptor set.

Two QRhiTextureRenderTarget instances can share the same render pass descriptor as long as they have the same number and type of attachments. The associated QRhiTexture or QRhiRenderBuffer instances are not part of the render pass descriptor so those can differ in the two QRhiTextureRenderTarget 实例。

注意: resources, such as QRhiTexture instances, referenced in description () must already have create () called on them.

另请参阅 create ().

[override virtual] QRhiResource::Type QRhiTextureRenderTarget:: resourceType () const

重实现: QRhiResource::resourceType() const .

Returns the resource type.

void QRhiTextureRenderTarget:: setDescription (const QRhiTextureRenderTargetDescription & desc )

Sets the render target description desc .

另请参阅 description ().

void QRhiTextureRenderTarget:: setFlags ( QRhiTextureRenderTarget::Flags f )

Sets the flags to f .

另请参阅 flags ().