Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RHI::IndirectBufferWriter Class Reference

#include <IndirectBufferWriter.h>

Inherits AZ::RHI::Object.

Inherited by AZ::DX12::IndirectBufferWriter, and AZ::Vulkan::IndirectBufferWriter.

Public Member Functions

 AZ_RTTI (IndirectBufferWriter, "{7F569E74-382B-44EC-B0C5-89C07A184B47}")
 
ResultCode Init (Buffer &buffer, size_t byteOffset, uint32_t byteStride, uint32_t maxCommandSequences, const IndirectBufferSignature &signature)
 
ResultCode Init (void *memoryPtr, uint32_t byteStride, uint32_t maxCommandSequences, const IndirectBufferSignature &signature)
 
IndirectBufferWriterSetVertexView (uint32_t slot, const StreamBufferView &view)
 
IndirectBufferWriterSetIndexView (const IndexBufferView &view)
 
IndirectBufferWriterDraw (const DrawLinear &arguments)
 
IndirectBufferWriterDrawIndexed (const DrawIndexed &arguments)
 
IndirectBufferWriterDispatch (const DispatchDirect &arguments)
 
IndirectBufferWriterSetRootConstants (const uint8_t *data, uint32_t byteSize)
 
bool NextSequence ()
 
bool Seek (const uint32_t sequenceIndex)
 
void Flush ()
 Flush changes into the destination buffer. Only valid when using a buffer.
 
bool IsInitialized () const
 
uint32_t GetCurrentSequenceIndex () const
 
void Shutdown () override
 
- Public Member Functions inherited from AZ::RHI::Object
 AZ_RTTI (Object, "{E43378F1-2331-4173-94B8-990ED20E6003}")
 
void SetName (const Name &name)
 Sets the name of the object.
 
const Name & GetName () const
 Returns the name set on the object by SetName.
 
uint32_t use_count ()
 Returns the current use count of the object.
 

Protected Member Functions

uint8_t * GetTargetMemory () const
 
- Protected Member Functions inherited from AZ::RHI::Object
void add_ref () const
 
void release () const
 

Protected Attributes

Bufferm_buffer = 0
 
const IndirectBufferSignaturem_signature = nullptr
 
uint32_t m_maxSequences = 0
 
uint32_t m_sequenceStride = 0
 
size_t m_bufferOffset = 0
 
- Protected Attributes inherited from AZ::RHI::Object
AZStd::atomic_int m_useCount = 0
 

Detailed Description

IndirectBufferWriter is a helper class to write indirect commands to a buffer or a memory location in a platform independent way. Different APIs may have different layouts for the arguments of an indirect command. This class provides a secure and simple way to write the commands without worrying about API differences.

It also provides basic checks, like trying to write more commands than allowed, or writing commands that are not specified in the layout.

Member Function Documentation

◆ Dispatch()

IndirectBufferWriter * AZ::RHI::IndirectBufferWriter::Dispatch ( const DispatchDirect arguments)

Writes a dispatch command into the current sequence.

Parameters
argumentsThe dispatch arguments that will be written.
Returns
A pointer to the IndirectBufferWriter object (this).

◆ Draw()

IndirectBufferWriter * AZ::RHI::IndirectBufferWriter::Draw ( const DrawLinear arguments)

Writes a draw command into the current sequence.

Parameters
argumentsThe draw arguments that will be written.
Returns
A pointer to the IndirectBufferWriter object (this).

◆ DrawIndexed()

IndirectBufferWriter * AZ::RHI::IndirectBufferWriter::DrawIndexed ( const DrawIndexed arguments)

Writes a draw indexed command into the current sequence.

Parameters
argumentsThe draw indexed arguments that will be written.
Returns
A pointer to the IndirectBufferWriter object (this).

◆ Init() [1/2]

ResultCode AZ::RHI::IndirectBufferWriter::Init ( Buffer buffer,
size_t  byteOffset,
uint32_t  byteStride,
uint32_t  maxCommandSequences,
const IndirectBufferSignature signature 
)

Initialize the IndirectBufferWriter to write commands into a buffer.

Parameters
bufferThe buffer where to write the commands. Any previous values for the specified range will be overwritten. The buffer must be big enough to contain the max number of sequences.
byteOffsetThe offset into the buffer.
byteStrideThe stride between command sequences. Must be larger than the stride calculated from the signature.
maxCommandSequencesThe max number of sequences that the IndirectBufferWriter can write.
signatureSignature of the indirect buffer.
Returns
A result code denoting the status of the call. If successful, the IndirectBufferWriter is considered initialized and is able to service write requests. If failure, the IndirectBufferWriter remains uninitialized.

◆ Init() [2/2]

ResultCode AZ::RHI::IndirectBufferWriter::Init ( void *  memoryPtr,
uint32_t  byteStride,
uint32_t  maxCommandSequences,
const IndirectBufferSignature signature 
)

Initialize the IndirectBufferWriter to write commands into a memory location.

Parameters
memoryPtrThe memory location where the commands will be written. Must not be null.
byteStrideThe stride between command sequences. Must be larger than the stride calculated from the signature.
maxCommandSequencesThe max number of sequences that the IndirectBufferWriter can write.
signatureSignature of the indirect buffer.
Returns
A result code denoting the status of the call. If successful, the IndirectBufferWriter is considered initialized and is able to service write requests. If failure, the IndirectBufferWriter remains uninitialized.

◆ NextSequence()

bool AZ::RHI::IndirectBufferWriter::NextSequence ( )

Advance the current sequence index by 1.

Returns
True if the sequence index was increased correctly. False otherwise.

◆ Seek()

bool AZ::RHI::IndirectBufferWriter::Seek ( const uint32_t  sequenceIndex)

Move the current sequence index to a specified position.

Parameters
sequenceIndexThe index where the sequence index will be moved. Must be less than maxCommandSequences.
Returns
True if the sequence index was updated correctly. False otherwise and the current sequence index is not modified.

◆ SetIndexView()

IndirectBufferWriter * AZ::RHI::IndirectBufferWriter::SetIndexView ( const IndexBufferView view)

Writes an index buffer view command into the current sequence.

Parameters
viewThe IndexBufferView that will be set.
Returns
A pointer to the IndirectBufferWriter object (this).

◆ SetRootConstants()

IndirectBufferWriter * AZ::RHI::IndirectBufferWriter::SetRootConstants ( const uint8_t *  data,
uint32_t  byteSize 
)

Writes an inline constants command into the current sequence. This command will set the values of all inline constants of the Pipeline.

Parameters
dataA pointer to the data that contains the values that will be written.
byteSizeThe size of the data that will be written.
Returns
A pointer to the IndirectBufferWriter object (this).

◆ SetVertexView()

IndirectBufferWriter * AZ::RHI::IndirectBufferWriter::SetVertexView ( uint32_t  slot,
const StreamBufferView view 
)

Writes a vertex buffer view command into the current sequence.

Parameters
slotThe stream buffer slot that the view will set.
viewThe StreamBufferView that will be set.
Returns
A pointer to the IndirectBufferWriter object (this).

◆ Shutdown()

void AZ::RHI::IndirectBufferWriter::Shutdown ( )
overridevirtual

Shuts down the object. Derived classes can make this public if it fits with their lifecycle model (i.e. if they use an explicit Init / Shutdown). By default, it is private in order to maintain consistency with a simpler RAII lifecycle.

Reimplemented from AZ::RHI::Object.


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