![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtGui More...
#include <qrhi.h>
Public Types | |
enum | Type { Buffer , Texture , Sampler , RenderBuffer , RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings , GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer } |
Specifies type of the resource. More... | |
Public Member Functions | |
virtual | ~QRhiResource () |
Destructor. | |
virtual Type | resourceType () const =0 |
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 |
QRhi * | rhi () const |
Protected Member Functions | |
QRhiResource (QRhiImplementation *rhi) | |
Protected Attributes | |
QRhiImplementation * | m_rhi = nullptr |
quint64 | m_id |
QByteArray | m_objectName |
Friends | |
class | QRhiImplementation |
\inmodule QtGui
Base class for classes encapsulating native resource objects.
enum QRhiResource::Type |
Specifies type of the resource.
\value Buffer \value Texture \value Sampler \value RenderBuffer \value RenderPassDescriptor \value SwapChainRenderTarget \value TextureRenderTarget \value ShaderResourceBindings \value GraphicsPipeline \value SwapChain \value ComputePipeline \value CommandBuffer
Enumerator | |
---|---|
Buffer | |
Texture | |
Sampler | |
RenderBuffer | |
RenderPassDescriptor | |
SwapChainRenderTarget | |
TextureRenderTarget | |
ShaderResourceBindings | |
GraphicsPipeline | |
SwapChain | |
ComputePipeline | |
CommandBuffer |
|
virtual |
Destructor.
Releases (or requests deferred releasing of) the underlying native graphics resources, if there are any.
|
protected |
Definition at line 3338 of file qrhi.cpp.
References m_id, and QRhiGlobalObjectIdGenerator::newId().
void QRhiResource::deleteLater | ( | ) |
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.
If the QRhi that created this object is already destroyed, the object is deleted immediately.
Using deleteLater() can be a useful convenience in many cases, and it complements the low-level guarantee (that the underlying native graphics objects are never destroyed until it is safe to do so and it is known for sure that they are not used by the GPU in an still in-flight frame), by offering a way to make sure the C++ object instances (of QRhiBuffer, QRhiTexture, etc.) themselves also stay valid until the end of the current frame.
The following example shows a convenient way of creating a throwaway buffer that is only used in one frame and gets automatically released in endFrame(). (when it comes to the underlying native buffer(s), the usual guarantee applies: the QRhi backend defers the releasing of those until it is guaranteed that the frame in which the buffer is accessed by the GPU has completed)
Definition at line 3419 of file qrhi.cpp.
References QRhiImplementation::addDeleteLater(), and m_rhi.
Referenced by QSSGReflectionMapEntry::renderMips(), renderToKTXFileInternal(), RenderHelpers::rhiRenderReflectionMap(), and QQuick3DItem2D::updateSpatialNode().
|
pure virtual |
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 destroy() is called, the QRhiResource instance can be reused, by calling create()
again. That will then result in creating new native graphics resources underneath.
The QRhiResource destructor also performs the same task, so calling this function is not necessary before deleting a QRhiResource.
Implemented in QD3D11Buffer, QD3D11RenderBuffer, QD3D11Texture, QD3D11Sampler, QD3D11RenderPassDescriptor, QD3D11SwapChainRenderTarget, QD3D11TextureRenderTarget, QD3D11ShaderResourceBindings, QD3D11GraphicsPipeline, QD3D11ComputePipeline, QD3D11CommandBuffer, QD3D11SwapChain, QGles2Buffer, QGles2RenderBuffer, QGles2Texture, QGles2Sampler, QGles2RenderPassDescriptor, QGles2SwapChainRenderTarget, QGles2TextureRenderTarget, QGles2ShaderResourceBindings, QGles2GraphicsPipeline, QGles2ComputePipeline, QGles2CommandBuffer, QGles2SwapChain, QMetalBuffer, QMetalRenderBuffer, QMetalTexture, QMetalSampler, QMetalRenderPassDescriptor, QMetalSwapChainRenderTarget, QMetalTextureRenderTarget, QMetalShaderResourceBindings, QMetalGraphicsPipeline, QMetalComputePipeline, QMetalCommandBuffer, QMetalSwapChain, QNullBuffer, QNullRenderBuffer, QNullTexture, QNullSampler, QNullRenderPassDescriptor, QNullSwapChainRenderTarget, QNullTextureRenderTarget, QNullShaderResourceBindings, QNullGraphicsPipeline, QNullComputePipeline, QNullCommandBuffer, QNullSwapChain, QVkBuffer, QVkRenderBuffer, QVkTexture, QVkSampler, QVkRenderPassDescriptor, QVkSwapChainRenderTarget, QVkTextureRenderTarget, QVkShaderResourceBindings, QVkGraphicsPipeline, QVkComputePipeline, QVkCommandBuffer, and QVkSwapChain.
quint64 QRhiResource::globalResourceId | ( | ) | const |
User code rarely needs to deal with the value directly. It is used internally for tracking and bookkeeping purposes.
Definition at line 3466 of file qrhi.cpp.
References m_id.
QByteArray QRhiResource::name | ( | ) | const |
Definition at line 3430 of file qrhi.cpp.
References m_objectName.
Referenced by QSSGRhiContextStats::beginRenderPass(), QRhiPassResourceTracker::registerTexture(), and setName().
|
pure virtual |
Implemented in QRhiBuffer, QRhiTexture, QRhiSampler, QRhiRenderBuffer, QRhiRenderPassDescriptor, QRhiSwapChainRenderTarget, QRhiTextureRenderTarget, QRhiShaderResourceBindings, QRhiGraphicsPipeline, QRhiSwapChain, QRhiComputePipeline, and QRhiCommandBuffer.
Referenced by QRhiD3D11::beginPass(), QRhiGles2::beginPass(), QRhiMetal::beginPass(), QRhiNull::beginPass(), QRhiVulkan::beginPass(), QRhiD3D11::endPass(), QRhiGles2::endPass(), endTessellationComputeEncoding(), QRhiGles2::enqueueBindFramebuffer(), maybeRenderTargetData(), and rtData().
QRhi * QRhiResource::rhi | ( | ) | const |
If the QRhi that created this object is already destroyed, the result is \nullptr.
Definition at line 3477 of file qrhi.cpp.
References m_rhi, and QRhiImplementation::q.
Referenced by QSGGuiThreadRenderLoop::ensureRhi(), QSSGBufferManager::loadRenderImage(), and MainPass::renderPrep().
void QRhiResource::setName | ( | const QByteArray & | name | ) |
Sets a name for the object.
This allows getting descriptive names for the native graphics resources visible in graphics debugging tools, such as \l{https://renderdoc.org/}{RenderDoc} and \l{https://developer.apple.com/xcode/}{XCode}.
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.
Definition at line 3455 of file qrhi.cpp.
References m_objectName, and name().
Referenced by QSSGRenderReflectionMap::addReflectionMapEntry(), QSSGRenderShadowMap::addShadowMapEntry(), QVkRenderBuffer::create(), RenderHelpers::rhiPrepareAoTexture(), RenderHelpers::rhiPrepareDepthTexture(), RenderHelpers::rhiPrepareScreenTexture(), and QQuick3DSceneRenderer::synchronize().
|
friend |
|
protected |
Definition at line 829 of file qrhi.h.
Referenced by QRhiResource(), globalResourceId(), QRhiD3D11::setShaderResources(), QRhiMetal::setShaderResources(), QRhiVulkan::setShaderResources(), QRhiD3D11::updateShaderResourceBindings(), and QRhiVulkan::updateShaderResourceBindings().
|
protected |
Definition at line 830 of file qrhi.h.
Referenced by QD3D11Buffer::create(), QD3D11RenderBuffer::create(), QD3D11Texture::create(), QMetalBuffer::create(), QMetalRenderBuffer::create(), QMetalTexture::create(), QVkBuffer::create(), QVkRenderBuffer::create(), QVkTexture::create(), name(), and setName().
|
protected |
Definition at line 828 of file qrhi.h.
Referenced by QRhiCommandBuffer::beginComputePass(), QRhiCommandBuffer::beginExternal(), QRhiCommandBuffer::beginPass(), QRhiCommandBuffer::debugMarkBegin(), QRhiCommandBuffer::debugMarkEnd(), QRhiCommandBuffer::debugMarkMsg(), deleteLater(), QRhiCommandBuffer::dispatch(), QRhiCommandBuffer::draw(), QRhiCommandBuffer::drawIndexed(), QRhiCommandBuffer::endComputePass(), QRhiCommandBuffer::endExternal(), QRhiCommandBuffer::endPass(), QRhiCommandBuffer::lastCompletedGpuTime(), QRhiCommandBuffer::nativeHandles(), QD3D11RenderPassDescriptor::newCompatibleRenderPassDescriptor(), QGles2RenderPassDescriptor::newCompatibleRenderPassDescriptor(), QMetalRenderPassDescriptor::newCompatibleRenderPassDescriptor(), QNullRenderPassDescriptor::newCompatibleRenderPassDescriptor(), QVkRenderPassDescriptor::newCompatibleRenderPassDescriptor(), QD3D11TextureRenderTarget::newCompatibleRenderPassDescriptor(), QD3D11SwapChain::newCompatibleRenderPassDescriptor(), QGles2TextureRenderTarget::newCompatibleRenderPassDescriptor(), QGles2SwapChain::newCompatibleRenderPassDescriptor(), QMetalTextureRenderTarget::newCompatibleRenderPassDescriptor(), QMetalSwapChain::newCompatibleRenderPassDescriptor(), QNullTextureRenderTarget::newCompatibleRenderPassDescriptor(), QNullSwapChain::newCompatibleRenderPassDescriptor(), QVkTextureRenderTarget::newCompatibleRenderPassDescriptor(), QVkSwapChain::newCompatibleRenderPassDescriptor(), QRhiCommandBuffer::resourceUpdate(), rhi(), QRhiCommandBuffer::setBlendConstants(), QRhiCommandBuffer::setComputePipeline(), QRhiCommandBuffer::setGraphicsPipeline(), QRhiCommandBuffer::setScissor(), QRhiCommandBuffer::setShaderResources(), QRhiCommandBuffer::setStencilRef(), QRhiCommandBuffer::setVertexInput(), and QRhiCommandBuffer::setViewport().