PySide6.QtGui.QRhiResource¶
- class QRhiResource¶
Base class for classes encapsulating native resource objects.
Details
Note
This is a RHI API with limited compatibility guarantees, see
QRhifor details.Inherited by:
QRhiTexture,QRhiShaderResourceBindings,QRhiSampler,QRhiRenderPassDescriptor,QRhiRenderTarget,QRhiTextureRenderTarget,QRhiRenderBuffer,QRhiSwapChain,QRhiSwapChainRenderTarget,QRhiGraphicsPipeline,QRhiComputePipeline,QRhiCommandBuffer,QRhiBufferAdded in version 6.6.
Synopsis¶
Methods¶
def
deleteLater()def
name()def
rhi()def
setName()
Virtual methods¶
def
destroy()def
resourceType()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- class Type¶
Specifies type of the resource.
Constant
Description
QRhiResource.Type.Buffer
QRhiResource.Type.Texture
QRhiResource.Type.Sampler
QRhiResource.Type.RenderBuffer
QRhiResource.Type.RenderPassDescriptor
QRhiResource.Type.SwapChainRenderTarget
QRhiResource.Type.TextureRenderTarget
QRhiResource.Type.ShaderResourceBindings
QRhiResource.Type.GraphicsPipeline
QRhiResource.Type.SwapChain
QRhiResource.Type.ComputePipeline
QRhiResource.Type.CommandBuffer
QRhiResource.Type.ShadingRateMap
- PySide6.QtGui.QRhiResource.m_id¶
- PySide6.QtGui.QRhiResource.m_objectName¶
- deleteLater()¶
When called without a frame being recorded, this function is equivalent to deleting the object. Between a
beginFrame()andendFrame()however the behavior is different: theQRhiResourcewill not be destroyed until the frame is submitted viaendFrame(), thus satisfying theQRhirequirement of not alteringQRhiResourceobjects that are referenced by the frame being recorded.If the
QRhithat 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
QRhibackend defers the releasing of those until it is guaranteed that the frame in which the buffer is accessed by the GPU has completed)rhi->beginFrame(swapchain); QRhiBuffer *buf = rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, 256); buf->deleteLater(); // ! u = rhi->nextResourceUpdateBatch(); u->uploadStaticBuffer(buf, data); // ... draw with buf rhi->endFrame();
See also
- abstract destroy()¶
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
QRhiResourceinstance can be reused, by callingcreate()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
endFrame().The
QRhiResourcedestructor also performs the same task, so calling this function is not necessary before deleting aQRhiResource.See also
- globalResourceId()¶
- Return type:
int
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.
- name()¶
- Return type:
Returns the currently set object name. By default the name is empty.
See also
Returns the type of the resource.
Returns the
QRhithat created this resource.If the
QRhithat created this object is already destroyed, the result isNone.- setName(name)¶
- Parameters:
name –
QByteArray
Sets a
namefor the object.This allows getting descriptive names for the native graphics resources visible in graphics debugging tools, such as RenderDoc and XCode .
When it comes to naming native objects by relaying the name via the appropriate graphics API, note that the name is ignored when
DebugMarkersare not supported, and may, depending on the backend, also be ignored whenEnableDebugMarkersis 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
QRhiBufferbacked by multiple native buffers,QRhiwill append a suffix to make the underlying native buffers easily distinguishable from each other.See also