Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QMetalIndirectCommandBuffer Struct Reference

#include <qrhimetal_p.h>

Inheritance diagram for QMetalIndirectCommandBuffer:
Collaboration diagram for QMetalIndirectCommandBuffer:

Public Member Functions

 QMetalIndirectCommandBuffer (QRhiImplementation *rhi, Type type, quint32 maxCommandCount)
 ~QMetalIndirectCommandBuffer ()
void destroy () override
 Releases (or requests deferred releasing of) the underlying native graphics resources.
bool create () override
 Creates the corresponding native objects.
const QRhiIndirectDrawCommanddrawCommands () const
const QRhiIndexedIndirectDrawCommandindexedDrawCommands () const
quint64 contentsGeneration () const
Public Member Functions inherited from QRhiIndirectCommandBuffer
QRhiResource::Type resourceType () const override
Type type () const
void setType (Type t)
 Sets the command type t.
quint32 maxCommandCount () const
void setMaxCommandCount (quint32 count)
 Sets the capacity, the maximum number of commands, to count.
void clear ()
 Discards all commands recorded so far.
void draw (quint32 vertexCount, quint32 instanceCount=1, quint32 firstVertex=0, quint32 firstInstance=0)
 Records a non-indexed draw command with vertexCount, instanceCount, firstVertex, and firstInstance.
void drawIndexed (quint32 indexCount, quint32 instanceCount=1, quint32 firstIndex=0, qint32 vertexOffset=0, quint32 firstInstance=0)
 Records an indexed draw command with indexCount, instanceCount, firstIndex, vertexOffset, and firstInstance.
quint32 recordedCommandCount () const
bool isGpuBuilt () const
quint32 commandCount () const
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
QRhirhi () const

Public Attributes

QMetalIndirectCommandBufferDatad
int lastActiveFrameSlot = -1

Friends

class QRhiMetal

Additional Inherited Members

Public Types inherited from QRhiIndirectCommandBuffer
enum  Type { Draws , IndexedDraws }
 Specifies the kind of commands an indirect command buffer holds. More...
Public Types inherited from QRhiResource
enum  Type {
  Buffer , Texture , Sampler , RenderBuffer ,
  RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings ,
  GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer ,
  ShadingRateMap , IndirectCommandBuffer
}
 Specifies type of the resource. More...
Protected Member Functions inherited from QRhiIndirectCommandBuffer
 QRhiIndirectCommandBuffer (QRhiImplementation *rhi, Type type_, quint32 maxCommandCount_)
Protected Member Functions inherited from QRhiResource
 QRhiResource (QRhiImplementation *rhi)
Protected Attributes inherited from QRhiIndirectCommandBuffer
Type m_type
quint32 m_maxCommandCount
QByteArray m_data
quint32 m_commandCount = 0
quint64 m_generation = 0
bool m_gpuBuilt = false
quint32 m_gpuBuiltCommandCount = 0
Protected Attributes inherited from QRhiResource
QRhiImplementationm_rhi = nullptr
quint64 m_id
QByteArray m_objectName

Detailed Description

Definition at line 126 of file qrhimetal_p.h.

Constructor & Destructor Documentation

◆ QMetalIndirectCommandBuffer()

QMetalIndirectCommandBuffer::QMetalIndirectCommandBuffer ( QRhiImplementation * rhi,
Type type,
quint32 maxCommandCount )

Definition at line 4213 of file qrhimetal.mm.

References QMetalIndirectCommandBuffer(), and d.

Referenced by QMetalIndirectCommandBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~QMetalIndirectCommandBuffer()

QMetalIndirectCommandBuffer::~QMetalIndirectCommandBuffer ( )

Definition at line 4220 of file qrhimetal.mm.

References d, and destroy().

Here is the call graph for this function:

Member Function Documentation

◆ contentsGeneration()

quint64 QMetalIndirectCommandBuffer::contentsGeneration ( ) const
inline

Definition at line 141 of file qrhimetal_p.h.

◆ create()

bool QMetalIndirectCommandBuffer::create ( )
overridevirtual

Creates the corresponding native objects.

Fails when maxCommandCount() is 0.

A given QRhiIndirectCommandBuffer takes its commands either from draw() and drawIndexed() followed by QRhiResourceUpdateBatch::commitIndirectCommandBuffer(), or from QRhiCommandBuffer::buildIndirect(), but not from both. Moving to the latter is one-way: clear() does not undo it, and neither does a subsequent commitIndirectCommandBuffer(); isGpuBuilt() stays true and the commands keep coming from the buffer. Call create() again to get an indirect command buffer that is populated from the CPU once more.

Note
Like with every other QRhi resource, destroy() gives up the contents, and so create() starts from an empty indirect command buffer: recordedCommandCount() is 0 afterwards. Setting a different type() or maxCommandCount() and calling create() again therefore needs the commands to be recorded again as well.
Returns
true when successful, false when a graphics operation failed.

Implements QRhiIndirectCommandBuffer.

Definition at line 4249 of file qrhimetal.mm.

References QMetalIndirectCommandBufferData::created, d, destroy(), and lastActiveFrameSlot.

Here is the call graph for this function:

◆ destroy()

void QMetalIndirectCommandBuffer::destroy ( )
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.

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 deleting a QRhiResource.

See also
deleteLater()

Implements QRhiResource.

Definition at line 4226 of file qrhimetal.mm.

References QMetalIndirectCommandBufferData::builtSlot, QMetalIndirectCommandBufferData::created, d, QMetalIndirectCommandBufferData::fallbackBuild, QMetalIndirectCommandBufferData::gpuFilled, qrhimtl_releaseIcbSlots(), and QMetalIndirectCommandBufferData::slotSetupFailed.

Referenced by ~QMetalIndirectCommandBuffer(), and create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawCommands()

const QRhiIndirectDrawCommand * QMetalIndirectCommandBuffer::drawCommands ( ) const
inline

Definition at line 133 of file qrhimetal_p.h.

◆ indexedDrawCommands()

const QRhiIndexedIndirectDrawCommand * QMetalIndirectCommandBuffer::indexedDrawCommands ( ) const
inline

Definition at line 137 of file qrhimetal_p.h.

Referenced by qrhimtl_encodeIcbFromCpu(), and qrhimtl_replayIcbOnCpu().

Here is the caller graph for this function:

◆ QRhiMetal

friend class QRhiMetal
friend

Definition at line 145 of file qrhimetal_p.h.

Member Data Documentation

◆ d

◆ lastActiveFrameSlot

int QMetalIndirectCommandBuffer::lastActiveFrameSlot = -1

Definition at line 144 of file qrhimetal_p.h.

Referenced by create(), and qrhimtl_releaseIcbSlots().


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