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
QRhiBufferBackedIndirectCommandBuffer Class Reference

#include <qrhi_p.h>

Inheritance diagram for QRhiBufferBackedIndirectCommandBuffer:
Collaboration diagram for QRhiBufferBackedIndirectCommandBuffer:

Public Member Functions

 QRhiBufferBackedIndirectCommandBuffer (QRhiImplementation *rhi, Type type, quint32 maxCommandCount)
 \variable QRhiIndirectCommandBufferBuildInfo::topology
 ~QRhiBufferBackedIndirectCommandBuffer ()
void destroy () override
 Releases (or requests deferred releasing of) the underlying native graphics resources.
bool create () override
 Creates the corresponding native objects.
void enqueueUpload (QRhiResourceUpdateBatch *u)
void execute (QRhiCommandBuffer *cb, quint32 firstCommand, quint32 commandCount)
void build (const QRhiIndirectCommandBufferBuildInfo &info)
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

bool valid = false
QRhiBufferbuffer = nullptr
quint64 uploadedGeneration = 0
QRhiIndirectCommandBufferBuildInfo buildInfo

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 304 of file qrhi_p.h.

Constructor & Destructor Documentation

◆ QRhiBufferBackedIndirectCommandBuffer()

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

\variable QRhiIndirectCommandBufferBuildInfo::topology

The topology the commands will be drawn with. Must match the topology of the graphics pipeline that is set when QRhiCommandBuffer::executeIndirect() is called. Some backends need it in order to build their native indirect command buffer, and it is not available to them outside of a render pass.

\variable QRhiIndirectCommandBufferBuildInfo::sourceBuffer

The buffer holding the QRhiIndirectDrawCommand or QRhiIndexedIndirectDrawCommand entries. Must have IndirectBuffer usage.

Its size is not used to work out how many commands there are, see commandCount.

\variable QRhiIndirectCommandBufferBuildInfo::sourceBufferOffset

\variable QRhiIndirectCommandBufferBuildInfo::commandCount

The number of commands to take from sourceBuffer. This is what QRhiIndirectCommandBuffer::commandCount() reports afterwards, and so how many draws QRhiCommandBuffer::executeIndirect() issues by default.

0 means QRhiIndirectCommandBuffer::maxCommandCount(). It does not mean "as many as fit in sourceBuffer": a buffer written by the GPU can be larger than the number of commands in it, so no count is ever derived from its size. A value above QRhiIndirectCommandBuffer::maxCommandCount() is clamped to it, with a warning.

Note
Specifying countBuffer changes what this value means: it stops being the number of commands and becomes the maximum number of commands, with the device-side count in countBuffer deciding the actual number. Without a countBuffer, exactly this many commands are executed.

\variable QRhiIndirectCommandBufferBuildInfo::stride

The byte distance between two commands in sourceBuffer. 0 means the size of the corresponding command struct.

\variable QRhiIndirectCommandBufferBuildInfo::countBuffer

An optional buffer whose first quint32 holds the number of commands to execute. Requires QRhi::DrawIndirectCount.

Note
Setting this turns commandCount into an upper bound. The device-side value is clamped to it, so a count buffer can only ever reduce the number of draws, never raise it.

\variable QRhiIndirectCommandBufferBuildInfo::countBufferOffset

\variable QRhiIndirectCommandBufferBuildInfo::indexBuffer

The index buffer the commands index into. Required for IndexedDraws.

\variable QRhiIndirectCommandBufferBuildInfo::indexBufferOffset

\variable QRhiIndirectCommandBufferBuildInfo::indexFormat

Definition at line 9093 of file qrhi.cpp.

References QRhiBufferBackedIndirectCommandBuffer().

Referenced by QRhiBufferBackedIndirectCommandBuffer().

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

◆ ~QRhiBufferBackedIndirectCommandBuffer()

QRhiBufferBackedIndirectCommandBuffer::~QRhiBufferBackedIndirectCommandBuffer ( )

Definition at line 9100 of file qrhi.cpp.

References destroy().

Here is the call graph for this function:

Member Function Documentation

◆ build()

void QRhiBufferBackedIndirectCommandBuffer::build ( const QRhiIndirectCommandBufferBuildInfo & info)

Definition at line 9170 of file qrhi.cpp.

◆ create()

bool QRhiBufferBackedIndirectCommandBuffer::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 9128 of file qrhi.cpp.

References destroy(), and valid.

Here is the call graph for this function:

◆ destroy()

void QRhiBufferBackedIndirectCommandBuffer::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 9105 of file qrhi.cpp.

References buffer, and valid.

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

Here is the caller graph for this function:

◆ enqueueUpload()

void QRhiBufferBackedIndirectCommandBuffer::enqueueUpload ( QRhiResourceUpdateBatch * u)

Definition at line 9147 of file qrhi.cpp.

References buffer.

◆ execute()

void QRhiBufferBackedIndirectCommandBuffer::execute ( QRhiCommandBuffer * cb,
quint32 firstCommand,
quint32 commandCount )

Definition at line 9183 of file qrhi.cpp.

References buffer.

Member Data Documentation

◆ buffer

◆ buildInfo

QRhiIndirectCommandBufferBuildInfo QRhiBufferBackedIndirectCommandBuffer::buildInfo

Definition at line 322 of file qrhi_p.h.

◆ uploadedGeneration

quint64 QRhiBufferBackedIndirectCommandBuffer::uploadedGeneration = 0

Definition at line 321 of file qrhi_p.h.

◆ valid

bool QRhiBufferBackedIndirectCommandBuffer::valid = false

Definition at line 319 of file qrhi_p.h.

Referenced by create(), and destroy().


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