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>.
|
#include <qrhimetal_p.h>
Public Member Functions | |
QMetalBuffer (QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size) | |
~QMetalBuffer () | |
void | destroy () override |
Releases (or requests deferred releasing of) the underlying native graphics resources. | |
bool | create () override |
Creates the corresponding native graphics resources. | |
QRhiBuffer::NativeBuffer | nativeBuffer () override |
char * | beginFullDynamicBufferUpdateForCurrentFrame () override |
void | endFullDynamicBufferUpdateForCurrentFrame () override |
To be called when the entire contents of the buffer data has been updated in the memory block returned from beginFullDynamicBufferUpdateForCurrentFrame(). | |
Public Member Functions inherited from QRhiBuffer | |
QRhiResource::Type | resourceType () const override |
Type | type () const |
void | setType (Type t) |
Sets the buffer's type to t. | |
UsageFlags | usage () const |
void | setUsage (UsageFlags u) |
Sets the buffer's usage flags to u. | |
quint32 | size () const |
void | setSize (quint32 sz) |
Sets the size of the buffer in bytes. | |
Public Member Functions inherited from QRhiResource | |
virtual | ~QRhiResource () |
Destructor. | |
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 |
Public Attributes | |
QMetalBufferData * | d |
uint | generation = 0 |
int | lastActiveFrameSlot = -1 |
Static Public Attributes | |
static constexpr int | WorkBufPoolUsage = 1 << 8 |
Friends | |
class | QRhiMetal |
struct | QMetalShaderResourceBindings |
Additional Inherited Members | |
Public Types inherited from QRhiBuffer | |
enum | Type { Immutable , Static , Dynamic } |
Specifies storage type of buffer resource. More... | |
enum | UsageFlag { VertexBuffer = 1 << 0 , IndexBuffer = 1 << 1 , UniformBuffer = 1 << 2 , StorageBuffer = 1 << 3 } |
Flag values to specify how the buffer is going to be used. 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... | |
Protected Member Functions inherited from QRhiBuffer | |
QRhiBuffer (QRhiImplementation *rhi, Type type_, UsageFlags usage_, quint32 size_) | |
\variable QRhiBuffer::NativeBuffer::objects | |
Protected Member Functions inherited from QRhiResource | |
QRhiResource (QRhiImplementation *rhi) | |
Protected Attributes inherited from QRhiBuffer | |
Type | m_type |
UsageFlags | m_usage |
quint32 | m_size |
Protected Attributes inherited from QRhiResource | |
QRhiImplementation * | m_rhi = nullptr |
quint64 | m_id |
QByteArray | m_objectName |
Definition at line 28 of file qrhimetal_p.h.
QMetalBuffer::QMetalBuffer | ( | QRhiImplementation * | rhi, |
Type | type, | ||
UsageFlags | usage, | ||
quint32 | size ) |
Definition at line 3230 of file qrhimetal.mm.
References QMetalBufferData::buf, d, i, and QMTL_FRAMES_IN_FLIGHT.
QMetalBuffer::~QMetalBuffer | ( | ) |
|
overridevirtual |
This is a shortcut for medium-to-large dynamic uniform buffers that have their entire contents (or at least all regions that are read by the shaders in the current frame) changed {in every frame} and the QRhiResourceUpdateBatch-based update mechanism is seen too heavy due to the amount of data copying involved.
The call to this function must be eventually followed by a call to endFullDynamicUniformBufferUpdateForCurrentFrame(), before recording any render or compute pass that relies on this buffer.
Reimplemented from QRhiBuffer.
Definition at line 3335 of file qrhimetal.mm.
References QMetalBufferData::buf, contents, d, QRhiBuffer::Dynamic, QRhiBuffer::m_type, Q_ASSERT, and QRHI_RES_RHI.
|
overridevirtual |
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.
true
when successful, false
when a graphics operation failed. Regardless of the return value, calling destroy() is always safe. Implements QRhiBuffer.
Definition at line 3266 of file qrhimetal.mm.
References aligned(), QMetalBufferData::buf, QByteArray::constData(), d, destroy(), QRhiBuffer::Dynamic, generation, i, QByteArray::isEmpty(), lastActiveFrameSlot, QRhiResource::m_objectName, QRhiBuffer::m_size, QRhiBuffer::m_type, QRhiBuffer::m_usage, QMetalBufferData::managed, QByteArray::number(), QMTL_FRAMES_IN_FLIGHT, QRHI_RES_RHI, qWarning, QMetalBufferData::slotted, QRhiBuffer::StorageBuffer, QRhiBuffer::UniformBuffer, and WorkBufPoolUsage.
Referenced by QMetalComputePipeline::create().
|
overridevirtual |
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.
Implements QRhiResource.
Definition at line 3244 of file qrhimetal.mm.
References QMetalBufferData::buf, QRhiMetalData::DeferredReleaseEntry::Buffer, QRhiMetalData::DeferredReleaseEntry::buffer, d, i, QRhiMetalData::DeferredReleaseEntry::lastActiveFrameSlot, lastActiveFrameSlot, QMetalBufferData::pendingUpdates, QMTL_FRAMES_IN_FLIGHT, QRHI_RES_RHI, and QRhiMetalData::DeferredReleaseEntry::type.
Referenced by ~QMetalBuffer(), and create().
|
overridevirtual |
To be called when the entire contents of the buffer data has been updated in the memory block returned from beginFullDynamicBufferUpdateForCurrentFrame().
Reimplemented from QRhiBuffer.
Definition at line 3350 of file qrhimetal.mm.
References QMetalBufferData::buf, d, QRhiBuffer::m_size, QMetalBufferData::managed, and QRHI_RES_RHI.
|
overridevirtual |
A QRhiBuffer may be backed by multiple native buffer objects, depending on the type() and the QRhi backend in use. When this is the case, all of them are returned in the objects array in the returned struct, with slotCount specifying the number of native buffer objects. While \l{QRhi::beginFrame()}{recording a frame}, QRhi::currentFrameSlot() can be used to determine which of the native buffers QRhi is using for operations that read or write from this QRhiBuffer within the frame being recorded.
In some cases a QRhiBuffer will not be backed by a native buffer object at all. In this case slotCount will be set to 0 and no valid native objects are returned. This is not an error, and is perfectly valid when a given backend does not use native buffers for QRhiBuffers with certain types or usages.
Reimplemented from QRhiBuffer.
Definition at line 3319 of file qrhimetal.mm.
References QMetalBufferData::buf, d, i, Q_ASSERT, QMTL_FRAMES_IN_FLIGHT, QRHI_RES_RHI, and QMetalBufferData::slotted.
|
friend |
Definition at line 42 of file qrhimetal_p.h.
|
friend |
Definition at line 41 of file qrhimetal_p.h.
QMetalBufferData* QMetalBuffer::d |
Definition at line 38 of file qrhimetal_p.h.
Referenced by QMetalBuffer(), ~QMetalBuffer(), beginFullDynamicBufferUpdateForCurrentFrame(), create(), destroy(), QRhiMetal::drawIndexed(), endFullDynamicBufferUpdateForCurrentFrame(), nativeBuffer(), and QRhiMetal::setShaderResources().
uint QMetalBuffer::generation = 0 |
Definition at line 39 of file qrhimetal_p.h.
Referenced by create().
int QMetalBuffer::lastActiveFrameSlot = -1 |
Definition at line 40 of file qrhimetal_p.h.
Referenced by QMetalGraphicsPipelineData::ExtraBufferManager::acquireWorkBuffer(), create(), and destroy().
|
staticconstexpr |
Definition at line 44 of file qrhimetal_p.h.
Referenced by QMetalGraphicsPipelineData::ExtraBufferManager::acquireWorkBuffer(), and create().