QRhiResource Class
Base class for classes encapsulating native resource objects. More...
Header: | #include <QRhiResource> |
qmake: | QT += rhi |
Inherited By: | QRhiBuffer, QRhiCommandBuffer, QRhiComputePipeline, QRhiGraphicsPipeline, QRhiRenderBuffer, QRhiRenderPassDescriptor, QRhiRenderTarget, QRhiSampler, QRhiShaderResourceBindings, QRhiSwapChain, and QRhiTexture |
Public Types
enum | Type { Buffer, Texture, Sampler, RenderBuffer, ..., CommandBuffer } |
Public Functions
virtual | ~QRhiResource() |
quint64 | globalResourceId() const |
QByteArray | name() const |
virtual void | release() = 0 |
void | releaseAndDestroyLater() |
virtual QRhiResource::Type | resourceType() const = 0 |
void | setName(const QByteArray &name) |
Protected Functions
QRhiResource(const QRhiResource &) | |
QRhiResource & | operator=(const QRhiResource &) |
Protected Variables
quint64 | m_id |
QByteArray | m_objectName |
QRhiImplementation * | m_rhi |
Detailed Description
Base class for classes encapsulating native resource objects.
Property Documentation
Member Function Documentation
[protected]
QRhiResource::QRhiResource(const QRhiResource &)
Default constructs an instance of QRhiResource.
[virtual]
QRhiResource::~QRhiResource()
Destructor.
Releases (or requests deferred releasing of) the underlying native graphics resources, if there are any.
Note: Resources referenced by commands for the current frame should not be released until the frame is submitted by QRhi::endFrame().
See also release().
quint64 QRhiResource::globalResourceId() const
Returns the global, unique identifier of this QRhiResource.
User code rarely needs to deal with the value directly. It is used internally for tracking and bookkeeping purposes.
QByteArray QRhiResource::name() const
Returns the currently set object name. By default the name is empty.
See also setName().
[pure virtual]
void QRhiResource::release()
Releases (or requests deferred releasing of) the underlying native graphics resources. Safe to call multiple times, subsequent invocations will be a no-op then.
Once release() is called, the QRhiResource instance can be reused, by calling build()
again. That will then result in creating new native graphics resources underneath.
Note: Resources referenced by commands for the current frame should not be released until the frame is submitted by QRhi::endFrame().
The QRhiResource destructor also performs the same task, so calling this function is not necessary before destroying a QRhiResource.
See also releaseAndDestroyLater().
void QRhiResource::releaseAndDestroyLater()
When called without a frame being recorded, this function is equivalent to deleting the object. Between a QRhi::beginFrame() and QRhi::endFrame() however the behavior is different: the QRhiResource will not be destroyed until the frame is submitted via QRhi::endFrame(), thus satisfying the QRhi requirement of not altering QRhiResource objects that are referenced by the frame being recorded.
See also release().
[pure virtual]
QRhiResource::Type QRhiResource::resourceType() const
Returns the type of the resource.
void QRhiResource::setName(const QByteArray &name)
Sets a name for the object.
This has two uses: to get descriptive names for the native graphics resources visible in graphics debugging tools, such as RenderDoc and XCode, and in the output stream of QRhiProfiler.
When it comes to naming native objects by relaying the name via the appropriate graphics API, note that the name is ignored when QRhi::DebugMarkers are not supported, and may, depending on the backend, also be ignored when QRhi::EnableDebugMarkers is not set.
Note: The name may be ignored for objects other than buffers, renderbuffers, and textures, depending on the backend.
Note: The name may be modified. For slotted resources, such as a QRhiBuffer backed by multiple native buffers, QRhi will append a suffix to make the underlying native buffers easily distinguishable from each other.
See also name().
[protected]
QRhiResource &QRhiResource::operator=(const QRhiResource &)
Copy-assignment operator.