Loading...
Searching...
No Matches
HdStDispatchBuffer Class Reference

A VBO of a simple array of unsigned integers. More...

#include <dispatchBuffer.h>

+ Inheritance diagram for HdStDispatchBuffer:

Public Member Functions

HDST_API HdStDispatchBuffer (HdStResourceRegistry *resourceRegistry, TfToken const &role, int count, unsigned int commandNumUints)
 Constructor. commandNumUints is given in how many integers.
 
HDST_API ~HdStDispatchBuffer () override
 Destructor.
 
HDST_API void CopyData (std::vector< uint32_t > const &data)
 Update entire buffer data.
 
HDST_API void AddBufferResourceView (TfToken const &name, HdTupleType tupleType, int offset)
 Add an interleaved view to this buffer.
 
int GetCount () const
 Returns the dispatch count.
 
unsigned int GetCommandNumUints () const
 Returns the number of uints in a single draw command.
 
HdStBufferArrayRangeSharedPtr GetBufferArrayRange () const
 Returns a bar which locates all interleaved resources of the entire buffer.
 
HdStBufferResourceSharedPtr GetEntireResource () const
 Returns entire buffer as a single HdStBufferResource.
 
HDST_API bool GarbageCollect () override
 Performs compaction if necessary and returns true if it becomes empty.
 
HDST_API void Reallocate (std::vector< HdBufferArrayRangeSharedPtr > const &, HdBufferArraySharedPtr const &) override
 Performs reallocation.
 
HDST_API void DebugDump (std::ostream &out) const override
 Debug output.
 
HDST_API HdStBufferResourceSharedPtr GetResource () const
 Returns the GPU resource.
 
HDST_API HdStBufferResourceSharedPtr GetResource (TfToken const &name)
 Returns the named GPU resource.
 
HdStBufferResourceNamedList const & GetResources () const
 Returns the list of all named GPU resources for this bufferArray.
 
- Public Member Functions inherited from HdBufferArray
HD_API HdBufferArray (TfToken const &role, TfToken const garbageCollectionPerfToken, HdBufferArrayUsageHint usageHint)
 
TfToken const & GetRole () const
 Returns the role of the GPU data in this bufferArray.
 
size_t GetVersion () const
 Returns the version of this buffer array.
 
HD_API void IncrementVersion ()
 Increments the version of this buffer array.
 
HD_API bool TryAssignRange (HdBufferArrayRangeSharedPtr &range)
 Attempts to assign a range to this buffer array.
 
virtual bool GarbageCollect ()=0
 Performs compaction if necessary and returns true if it becomes empty.
 
virtual void Reallocate (std::vector< HdBufferArrayRangeSharedPtr > const &ranges, HdBufferArraySharedPtr const &curRangeOwner)=0
 Performs reallocation.
 
virtual HD_API size_t GetMaxNumElements () const
 Returns the maximum number of elements capacity.
 
virtual void DebugDump (std::ostream &out) const =0
 Debug output.
 
size_t GetRangeCount () const
 How many ranges are attached to the buffer array.
 
HD_API HdBufferArrayRangePtr GetRange (size_t idx) const
 Get the attached range at the specified index.
 
HD_API void RemoveUnusedRanges ()
 Remove any ranges from the range list that have been deallocated Returns number of ranges after clean-up.
 
bool NeedsReallocation () const
 Returns true if Reallocate() needs to be called on this buffer array.
 
bool IsImmutable () const
 Returns true if this buffer array is marked as immutable.
 
HdBufferArrayUsageHint GetUsageHint () const
 Returns the usage hints for this buffer array.
 

Protected Member Functions

HDST_API HdStBufferResourceSharedPtr _AddResource (TfToken const &name, HdTupleType tupleType, int offset, int stride)
 Adds a new, named GPU resource and returns it.
 
- Protected Member Functions inherited from HdBufferArray
void _SetMaxNumRanges (size_t max)
 Limits the number of ranges that can be allocated to this buffer to max.
 
HD_API void _SetRangeList (std::vector< HdBufferArrayRangeSharedPtr > const &ranges)
 Swap the rangelist with ranges.
 

Additional Inherited Members

- Protected Attributes inherited from HdBufferArray
bool _needsReallocation
 Dirty bit to set when the ranges attached to the buffer changes.
 

Detailed Description

A VBO of a simple array of unsigned integers.

This buffer is used to prepare data on the GPU for indirect dispatch i.e. to be consumed by MultiDrawIndirect or DispatchComputeIndirect. At the same time, interleaved subsets of the array are bound in several different ways to provide additional data interface to shaders.

For each binding, we define 'BufferResourceView' on top of the uint array. HdBufferArray aggregates those views and HdResourceBinder binds them with specified binding method and interleaved offset.

Example: DrawElements + Instance culling : 14 integers for each drawitem

                      BufferResourceViews    BufferResourceViews
                         for draw               for cull

+-—draw item 0-—+-------------------------—> destination buffer | count | –+ | instanceCount | | | first | |-—> MDI dispatch | baseVertex | | | baseInstance | –+----------------------—> drawitem index | cullCount | -—+ | cullInstanceCount | |---------------------—> MDI dispatch | cullFirstVertex | | | cullBaseInstance | -—+ | modelDC | –+ | constantDC | |-—> DrawingCoord0 ----—> DrawingCoord0 | elementDC | | | primitiveDC | –+ | fvarDC | –+ | instanceIndexDC | |-—> DrawingCoord1 ----—> DrawingCoord1 | shaderDC | –+ | (instanceDC[0]) | –+ | (instanceDC[1]) | |-—> DrawingCoordI ----—> DrawingCoordI | (instanceDC[2]) | | | ... | –+ +-—draw item 1-—+ | count | | instanceCount | | ... |

XXX: it would be better to generalize this class not only for dispatch buffer, if we see other similar use-cases.

Definition at line 91 of file dispatchBuffer.h.

Constructor & Destructor Documentation

◆ HdStDispatchBuffer()

HDST_API HdStDispatchBuffer ( HdStResourceRegistry resourceRegistry,
TfToken const &  role,
int  count,
unsigned int  commandNumUints 
)

Constructor. commandNumUints is given in how many integers.

◆ ~HdStDispatchBuffer()

HDST_API ~HdStDispatchBuffer ( )
override

Destructor.

Member Function Documentation

◆ _AddResource()

HDST_API HdStBufferResourceSharedPtr _AddResource ( TfToken const &  name,
HdTupleType  tupleType,
int  offset,
int  stride 
)
protected

Adds a new, named GPU resource and returns it.

◆ AddBufferResourceView()

HDST_API void AddBufferResourceView ( TfToken const &  name,
HdTupleType  tupleType,
int  offset 
)

Add an interleaved view to this buffer.

◆ CopyData()

HDST_API void CopyData ( std::vector< uint32_t > const &  data)

Update entire buffer data.

◆ DebugDump()

HDST_API void DebugDump ( std::ostream &  out) const
overridevirtual

Debug output.

Implements HdBufferArray.

◆ GarbageCollect()

HDST_API bool GarbageCollect ( )
overridevirtual

Performs compaction if necessary and returns true if it becomes empty.

Implements HdBufferArray.

◆ GetBufferArrayRange()

HdStBufferArrayRangeSharedPtr GetBufferArrayRange ( ) const
inline

Returns a bar which locates all interleaved resources of the entire buffer.

Definition at line 122 of file dispatchBuffer.h.

◆ GetCommandNumUints()

unsigned int GetCommandNumUints ( ) const
inline

Returns the number of uints in a single draw command.

Definition at line 118 of file dispatchBuffer.h.

◆ GetCount()

int GetCount ( ) const
inline

Returns the dispatch count.

Definition at line 115 of file dispatchBuffer.h.

◆ GetEntireResource()

HdStBufferResourceSharedPtr GetEntireResource ( ) const
inline

Returns entire buffer as a single HdStBufferResource.

Definition at line 127 of file dispatchBuffer.h.

◆ GetResource() [1/2]

HDST_API HdStBufferResourceSharedPtr GetResource ( ) const

Returns the GPU resource.

If the buffer array contains more than one resource, this method raises a coding error.

◆ GetResource() [2/2]

HDST_API HdStBufferResourceSharedPtr GetResource ( TfToken const &  name)

Returns the named GPU resource.

This method returns the first found resource. In HDST_SAFE_MODE it checks all underlying GPU buffers in _resourceMap and raises a coding error if there are more than one GPU buffers exist.

◆ GetResources()

HdStBufferResourceNamedList const & GetResources ( ) const
inline

Returns the list of all named GPU resources for this bufferArray.

Definition at line 155 of file dispatchBuffer.h.

◆ Reallocate()

HDST_API void Reallocate ( std::vector< HdBufferArrayRangeSharedPtr > const &  ranges,
HdBufferArraySharedPtr const &  curRangeOwner 
)
overridevirtual

Performs reallocation.

After reallocation, the buffer will contain the specified ranges. If these ranges are currently held by a different buffer array instance, then their data will be copied from the specified curRangeOwner.

Implements HdBufferArray.


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