Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QRhiRenderBuffer Class Referenceabstract

\inmodule QtGui More...

#include <qrhi.h>

+ Inheritance diagram for QRhiRenderBuffer:
+ Collaboration diagram for QRhiRenderBuffer:

Classes

struct  NativeRenderBuffer
 \inmodule QtGui More...
 

Public Types

enum  Type { DepthStencil , Color }
 Specifies the type of the renderbuffer. More...
 
enum  Flag { UsedWithSwapChainOnly = 1 << 0 }
 \variable QRhiRenderBuffer::NativeRenderBuffer::object More...
 
- Public Types inherited from QRhiResource
enum  Type {
  Buffer , Texture , Sampler , RenderBuffer ,
  RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings ,
  GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer
}
 Specifies type of the resource. More...
 

Public Member Functions

QRhiResource::Type resourceType () const override
 
Type type () const
 
void setType (Type t)
 Sets the type to t.
 
QSize pixelSize () const
 
void setPixelSize (const QSize &sz)
 Sets the size (in pixels) to sz.
 
int sampleCount () const
 
void setSampleCount (int s)
 Sets the sample count to s.
 
Flags flags () const
 
void setFlags (Flags f)
 Sets the flags to f.
 
virtual bool create ()=0
 Creates the corresponding native graphics resources.
 
virtual bool createFrom (NativeRenderBuffer src)
 Similar to create() except that no new native renderbuffer objects are created.
 
virtual QRhiTexture::Format backingFormat () const =0
 
- 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

 QRhiRenderBuffer (QRhiImplementation *rhi, Type type_, const QSize &pixelSize_, int sampleCount_, Flags flags_, QRhiTexture::Format backingFormatHint_)
 
- Protected Member Functions inherited from QRhiResource
 QRhiResource (QRhiImplementation *rhi)
 

Protected Attributes

Type m_type
 
QSize m_pixelSize
 
int m_sampleCount
 
Flags m_flags
 
QRhiTexture::Format m_backingFormatHint
 
- Protected Attributes inherited from QRhiResource
QRhiImplementationm_rhi = nullptr
 
quint64 m_id
 
QByteArray m_objectName
 

Detailed Description

\inmodule QtGui

Since
6.6

Renderbuffer resource.

Renderbuffers cannot be sampled or read but have some benefits over textures in some cases:

A \l DepthStencil renderbuffer may be lazily allocated and be backed by transient memory with some APIs. On some platforms this may mean the depth/stencil buffer uses no physical backing at all.

\l Color renderbuffers are useful since QRhi::MultisampleRenderBuffer may be supported even when QRhi::MultisampleTexture is not.

How the renderbuffer is implemented by a backend is not exposed to the applications. In some cases it may be backed by ordinary textures, while in others there may be a different kind of native resource used.

Renderbuffers that are used as (and are only used as) depth-stencil buffers in combination with a QRhiSwapChain's color buffers should have the UsedWithSwapChainOnly flag set. This serves a double purpose: such buffers, depending on the backend and the underlying APIs, be more efficient, and QRhi provides automatic sizing behavior to match the color buffers, which means calling setPixelSize() and create() are not necessary for such renderbuffers.

Note
This is a RHI API with limited compatibility guarantees, see \l QRhi for details.

Definition at line 1093 of file qrhi.h.

Member Enumeration Documentation

◆ Flag

\variable QRhiRenderBuffer::NativeRenderBuffer::object

64-bit integer containing the native object handle.

Used with QRhiRenderBuffer::createFrom().

With OpenGL the native handle is a GLuint value. object is expected to be a valid OpenGL renderbuffer object ID.

Flag values for flags() and setFlags()

\value UsedWithSwapChainOnly For DepthStencil renderbuffers this indicates that the renderbuffer is only used in combination with a QRhiSwapChain, and never in any other way. This provides automatic sizing and resource rebuilding, so calling setPixelSize() or create() is not needed whenever this flag is set. This flag value may also trigger backend-specific behavior, for example with OpenGL, where a separate windowing system interface API is in use (EGL, GLX, etc.), the flag is especially important as it avoids creating any actual renderbuffer resource as there is already a windowing system provided depth/stencil buffer as requested by QSurfaceFormat.

Enumerator
UsedWithSwapChainOnly 

Definition at line 1101 of file qrhi.h.

◆ Type

Specifies the type of the renderbuffer.

\value DepthStencil Combined depth/stencil \value Color Color

Enumerator
DepthStencil 
Color 

Definition at line 1096 of file qrhi.h.

Constructor & Destructor Documentation

◆ QRhiRenderBuffer()

QRhiRenderBuffer::QRhiRenderBuffer ( QRhiImplementation * rhi,
Type type_,
const QSize & pixelSize_,
int sampleCount_,
Flags flags_,
QRhiTexture::Format backingFormatHint_ )
protected

Definition at line 4059 of file qrhi.cpp.

Member Function Documentation

◆ backingFormat()

QRhiTexture::Format QRhiRenderBuffer::backingFormat ( ) const
pure virtual

Implemented in QD3D11RenderBuffer, QGles2RenderBuffer, QMetalRenderBuffer, QNullRenderBuffer, and QVkRenderBuffer.

Referenced by QRhiWidgetPrivate::ensureTexture().

+ Here is the caller graph for this function:

◆ create()

bool QRhiRenderBuffer::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.

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

Implemented in QD3D11RenderBuffer, QGles2RenderBuffer, QMetalRenderBuffer, QNullRenderBuffer, and QVkRenderBuffer.

Referenced by QD3D11SwapChain::createOrResize(), QGles2SwapChain::createOrResize(), QMetalSwapChain::createOrResize(), QVkSwapChain::createOrResize(), QRhiWidgetPrivate::ensureTexture(), QRhiWidgetPrivate::invokeInitialize(), and QQuick3DSceneRenderer::synchronize().

+ Here is the caller graph for this function:

◆ createFrom()

bool QRhiRenderBuffer::createFrom ( NativeRenderBuffer src)
virtual

Similar to create() except that no new native renderbuffer objects are created.

Instead, the native renderbuffer object specified by src is used.

This allows importing an existing renderbuffer object (which must belong to the same device or sharing context, depending on the graphics API) from an external graphics engine.

Note
This is currently applicable to OpenGL only. This function exists solely to allow importing a renderbuffer object that is bound to some special, external object, such as an EGLImageKHR. Once the application performed the glEGLImageTargetRenderbufferStorageOES call, the renderbuffer object can be passed to this function to create a wrapping QRhiRenderBuffer, which in turn can be passed in as a color attachment to a QRhiTextureRenderTarget to enable rendering to the EGLImage.
pixelSize(), sampleCount(), and flags() must still be set correctly. Passing incorrect sizes and other values to QRhi::newRenderBuffer() and then following it with a createFrom() expecting that the native renderbuffer object alone is sufficient to deduce such values is wrong and will lead to problems.
QRhiRenderBuffer does not take ownership of the native object, and destroy() will not release that object.
This function is only implemented when the QRhi::RenderBufferImport feature is reported as \l{QRhi::isFeatureSupported()}{supported}. Otherwise, the function does nothing and the return value is false.
Returns
true when successful, false when not supported.

Reimplemented in QGles2RenderBuffer.

Definition at line 4119 of file qrhi.cpp.

References Q_UNUSED.

◆ flags()

QRhiRenderBuffer::Flags QRhiRenderBuffer::flags ( ) const
inline
Returns
the flags.

Definition at line 1121 of file qrhi.h.

Referenced by QD3D11SwapChain::createOrResize(), QGles2SwapChain::createOrResize(), QMetalSwapChain::createOrResize(), and QVkSwapChain::createOrResize().

+ Here is the caller graph for this function:

◆ pixelSize()

QSize QRhiRenderBuffer::pixelSize ( ) const
inline
Returns
the pixel size.

Definition at line 1115 of file qrhi.h.

Referenced by QD3D11TextureRenderTarget::create(), QNullTextureRenderTarget::create(), QD3D11SwapChain::createOrResize(), QGles2SwapChain::createOrResize(), QMetalSwapChain::createOrResize(), QVkSwapChain::createOrResize(), QRhiWidgetPrivate::ensureTexture(), and QRhiWidgetPrivate::invokeInitialize().

+ Here is the caller graph for this function:

◆ resourceType()

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

Implements QRhiResource.

Definition at line 4071 of file qrhi.cpp.

References QRhiResource::RenderBuffer.

◆ sampleCount()

int QRhiRenderBuffer::sampleCount ( ) const
inline
Returns
the sample count. 1 means no multisample antialiasing.

Definition at line 1118 of file qrhi.h.

Referenced by QD3D11SwapChain::createOrResize(), QMetalSwapChain::createOrResize(), QVkSwapChain::createOrResize(), QRhiWidgetPrivate::ensureTexture(), and QQuick3DSceneRenderer::renderToRhiTexture().

+ Here is the caller graph for this function:

◆ setFlags()

void QRhiRenderBuffer::setFlags ( Flags f)
inline

Sets the flags to f.

Definition at line 1122 of file qrhi.h.

◆ setPixelSize()

void QRhiRenderBuffer::setPixelSize ( const QSize & sz)
inline

Sets the size (in pixels) to sz.

Definition at line 1116 of file qrhi.h.

Referenced by QD3D11SwapChain::createOrResize(), QGles2SwapChain::createOrResize(), QMetalSwapChain::createOrResize(), QVkSwapChain::createOrResize(), QRhiWidgetPrivate::ensureTexture(), QRhiWidgetPrivate::invokeInitialize(), and QQuick3DSceneRenderer::synchronize().

+ Here is the caller graph for this function:

◆ setSampleCount()

void QRhiRenderBuffer::setSampleCount ( int s)
inline

Sets the sample count to s.

Definition at line 1119 of file qrhi.h.

◆ setType()

void QRhiRenderBuffer::setType ( Type t)
inline

Sets the type to t.

Definition at line 1113 of file qrhi.h.

◆ type()

QRhiRenderBuffer::Type QRhiRenderBuffer::type ( ) const
inline
Returns
the renderbuffer type.

Definition at line 1112 of file qrhi.h.

Member Data Documentation

◆ m_backingFormatHint

◆ m_flags

Flags QRhiRenderBuffer::m_flags
protected

Definition at line 1135 of file qrhi.h.

Referenced by QGles2RenderBuffer::create(), and QGles2RenderBuffer::createFrom().

◆ m_pixelSize

QSize QRhiRenderBuffer::m_pixelSize
protected

◆ m_sampleCount

int QRhiRenderBuffer::m_sampleCount
protected

◆ m_type


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