Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QRhiTextureRenderTarget Class Referenceabstract

\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h More...

#include <qrhi.h>

Inheritance diagram for QRhiTextureRenderTarget:
Collaboration diagram for QRhiTextureRenderTarget:

Public Types

enum  Flag { PreserveColorContents = 1 << 0 , PreserveDepthStencilContents = 1 << 1 , DoNotStoreDepthStencilContents = 1 << 2 }
 Flag values describing the load/store behavior for the render target. More...
Public Types inherited from QRhiResource
enum  Type {
  Buffer , Texture , Sampler , RenderBuffer ,
  RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings ,
  GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer ,
  ShadingRateMap
}
 Specifies type of the resource. More...

Public Member Functions

QRhiResource::Type resourceType () const override
QRhiTextureRenderTargetDescription description () const
void setDescription (const QRhiTextureRenderTargetDescription &desc)
 Sets the render target description desc.
Flags flags () const
void setFlags (Flags f)
 Sets the flags to f.
virtual QRhiRenderPassDescriptornewCompatibleRenderPassDescriptor ()=0
virtual bool create ()=0
 Creates the corresponding native graphics resources.
Public Member Functions inherited from QRhiRenderTarget
virtual QSize pixelSize () const =0
virtual float devicePixelRatio () const =0
virtual int sampleCount () const =0
QRhiRenderPassDescriptorrenderPassDescriptor () const
void setRenderPassDescriptor (QRhiRenderPassDescriptor *desc)
 Sets the QRhiRenderPassDescriptor desc for use with this render target.
Public Member Functions inherited from QRhiResource
virtual ~QRhiResource ()
 Destructor.
virtual void destroy ()=0
 Releases (or requests deferred releasing of) the underlying native graphics resources.
void deleteLater ()
 When called without a frame being recorded, this function is equivalent to deleting the object.
QByteArray name () const
void setName (const QByteArray &name)
 Sets a name for the object.
quint64 globalResourceId () const
QRhirhi () const

Protected Member Functions

 QRhiTextureRenderTarget (QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc_, Flags flags_)
Protected Member Functions inherited from QRhiRenderTarget
 QRhiRenderTarget (QRhiImplementation *rhi)
Protected Member Functions inherited from QRhiResource
 QRhiResource (QRhiImplementation *rhi)

Protected Attributes

QRhiTextureRenderTargetDescription m_desc
Flags m_flags
Protected Attributes inherited from QRhiRenderTarget
QRhiRenderPassDescriptorm_renderPassDesc = nullptr
Protected Attributes inherited from QRhiResource
QRhiImplementationm_rhi = nullptr
quint64 m_id
QByteArray m_objectName

Detailed Description

\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h

Since
6.6

Texture render target resource.

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}. For more information, read the detailed description of the \l QRhiColorAttachment class.

Note
Textures used in combination with QRhiTextureRenderTarget must be created with the QRhiTexture::RenderTarget flag.

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

texture->create();
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ texture });
rt->create();
// rt can now be used with beginPass()
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Sets the QRhiRenderPassDescriptor desc for use with this render target.
Definition qrhi.h:1204
QRhi * rhi() const
Definition qrhi.cpp:3743
virtual QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor()=0
QRhiTextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc_, Flags flags_)
Definition qrhi.cpp:5467
virtual bool create()=0
Creates the corresponding native graphics resources.
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:906
@ RenderTarget
Definition qrhi.h:909
GLenum GLuint GLintptr GLsizeiptr size
GLenum GLuint texture
Note
This is a RHI API with limited compatibility guarantees, see \l QRhi for details.

Definition at line 1222 of file qrhi.h.

Member Enumeration Documentation

◆ Flag

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).

\value PreserveColorContents 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. When doing multisample rendering with a resolve texture set, setting this flag also requests the multisample color data to be stored (written out) to the multisample texture or render buffer. (for non-multisample rendering the color data is always stored, but for MSAA storing the multisample data decreases efficiency for certain GPU architectures, hence defaulting to not writing it out) Note however that this is non-portable: in some cases there is no intermediate multisample texture on the graphics API level, e.g. when using OpenGL ES's {GL_EXT_multisampled_render_to_texture} as it is all implicit, handled by the OpenGL ES implementation. In that case, PreserveColorContents will likely have no effect. Therefore, avoid relying on this flag when using multisample rendering and the color attachment is using a multisample QRhiTexture (not QRhiRenderBuffer).

\value PreserveDepthStencilContents 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.

\value DoNotStoreDepthStencilContents Indicates that the contents of the depth texture does not need to be written out. Relevant only when a QRhiTexture, not QRhiRenderBuffer, is used as the depth-stencil buffer, because for QRhiRenderBuffer this is implicit. When a depthResolveTexture is set, the flag is not relevant, because the behavior is then as if the flag was set. This enum value is introduced in Qt 6.8.

Enumerator
PreserveColorContents 
PreserveDepthStencilContents 
DoNotStoreDepthStencilContents 

Definition at line 1225 of file qrhi.h.

Constructor & Destructor Documentation

◆ QRhiTextureRenderTarget()

QRhiTextureRenderTarget::QRhiTextureRenderTarget ( QRhiImplementation * rhi,
const QRhiTextureRenderTargetDescription & desc_,
Flags flags_ )
protected

Definition at line 5467 of file qrhi.cpp.

Member Function Documentation

◆ create()

virtual bool QRhiTextureRenderTarget::create ( )
pure virtual

Creates the corresponding native graphics resources.

If there are already resources present due to an earlier create() with no corresponding destroy(), then destroy() is called implicitly first.

Note
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() and 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.
Returns
true when successful, false when a graphics operation failed. Regardless of the return value, calling destroy() is always safe.

Implemented in QD3D11TextureRenderTarget, QGles2TextureRenderTarget, QMetalTextureRenderTarget, QNullTextureRenderTarget, and QVkTextureRenderTarget.

◆ description()

QRhiTextureRenderTargetDescription QRhiTextureRenderTarget::description ( ) const
inline
Returns
the render target description.

Definition at line 1234 of file qrhi.h.

◆ flags()

Flags QRhiTextureRenderTarget::flags ( ) const
inline
Returns
the currently set flags.

Definition at line 1237 of file qrhi.h.

◆ newCompatibleRenderPassDescriptor()

virtual QRhiRenderPassDescriptor * QRhiTextureRenderTarget::newCompatibleRenderPassDescriptor ( )
pure virtual
Returns
a new QRhiRenderPassDescriptor that is compatible with this render target.

The returned value is used in two ways: it can be passed to setRenderPassDescriptor() and 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 \l{QRhiRenderPassDescriptor::isCompatible()}{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 instances.

Note
resources, such as QRhiTexture instances, referenced in description() must already have create() called on them.
See also
create()

Implemented in QD3D11TextureRenderTarget, QGles2TextureRenderTarget, QMetalTextureRenderTarget, QNullTextureRenderTarget, and QVkTextureRenderTarget.

◆ resourceType()

QRhiResource::Type QRhiTextureRenderTarget::resourceType ( ) const
overridevirtual
Returns
the resource type.

Implements QRhiResource.

Definition at line 5479 of file qrhi.cpp.

◆ setDescription()

void QRhiTextureRenderTarget::setDescription ( const QRhiTextureRenderTargetDescription & desc)
inline

Sets the render target description desc.

Definition at line 1235 of file qrhi.h.

◆ setFlags()

void QRhiTextureRenderTarget::setFlags ( Flags f)
inline

Sets the flags to f.

Definition at line 1238 of file qrhi.h.

Member Data Documentation

◆ m_desc

QRhiTextureRenderTargetDescription QRhiTextureRenderTarget::m_desc
protected

Definition at line 1246 of file qrhi.h.

◆ m_flags

Flags QRhiTextureRenderTarget::m_flags
protected

Definition at line 1247 of file qrhi.h.


The documentation for this class was generated from the following files: