![]() |
A VBO of a simple array of unsigned integers. More...
Public Member Functions | |
HDST_API | HdStDispatchBuffer (HdStResourceRegistry *resourceRegistry, TfToken const &role, int count, unsigned int commandNumUints) |
Constructor. commandNumUints is given in how many integers. More... | |
HDST_API | ~HdStDispatchBuffer () override |
Destructor. More... | |
HDST_API void | CopyData (std::vector< uint32_t > const &data) |
Update entire buffer data. More... | |
HDST_API void | AddBufferResourceView (TfToken const &name, HdTupleType tupleType, int offset) |
Add an interleaved view to this buffer. More... | |
int | GetCount () const |
Returns the dispatch count. More... | |
unsigned int | GetCommandNumUints () const |
Returns the number of uints in a single draw command. More... | |
HdStBufferArrayRangeSharedPtr | GetBufferArrayRange () const |
Returns a bar which locates all interleaved resources of the entire buffer. More... | |
HdStBufferResourceSharedPtr | GetEntireResource () const |
Returns entire buffer as a single HdBufferResource. More... | |
HDST_API bool | GarbageCollect () override |
Performs compaction if necessary and returns true if it becomes empty. More... | |
HDST_API void | Reallocate (std::vector< HdBufferArrayRangeSharedPtr > const &, HdBufferArraySharedPtr const &) override |
Performs reallocation. More... | |
HDST_API void | DebugDump (std::ostream &out) const override |
Debug output. More... | |
HDST_API HdStBufferResourceSharedPtr | GetResource () const |
Returns the GPU resource. More... | |
HDST_API HdStBufferResourceSharedPtr | GetResource (TfToken const &name) |
Returns the named GPU resource. More... | |
HdStBufferResourceNamedList const & | GetResources () const |
Returns the list of all named GPU resources for this bufferArray. More... | |
![]() | |
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. More... | |
size_t | GetVersion () const |
Returns the version of this buffer array. More... | |
HD_API void | IncrementVersion () |
Increments the version of this buffer array. More... | |
HD_API bool | TryAssignRange (HdBufferArrayRangeSharedPtr &range) |
Attempts to assign a range to this buffer array. More... | |
virtual HD_API size_t | GetMaxNumElements () const |
Returns the maximum number of elements capacity. More... | |
size_t | GetRangeCount () const |
How many ranges are attached to the buffer array. More... | |
HD_API HdBufferArrayRangePtr | GetRange (size_t idx) const |
Get the attached range at the specified index. More... | |
HD_API void | RemoveUnusedRanges () |
Remove any ranges from the range list that have been deallocated Returns number of ranges after clean-up. More... | |
bool | NeedsReallocation () const |
Returns true if Reallocate() needs to be called on this buffer array. More... | |
bool | IsImmutable () const |
Returns true if this buffer array is marked as immutable. More... | |
HdBufferArrayUsageHint | GetUsageHint () const |
Returns the usage hints for this buffer array. More... | |
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. More... | |
![]() | |
void | _SetMaxNumRanges (size_t max) |
Limits the number of ranges that can be allocated to this buffer to max. More... | |
HD_API void | _SetRangeList (std::vector< HdBufferArrayRangeSharedPtr > const &ranges) |
Swap the rangelist with ranges . More... | |
Additional Inherited Members | |
![]() | |
bool | _needsReallocation |
Dirty bit to set when the ranges attached to the buffer changes. More... | |
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.
HDST_API HdStDispatchBuffer | ( | HdStResourceRegistry * | resourceRegistry, |
TfToken const & | role, | ||
int | count, | ||
unsigned int | commandNumUints | ||
) |
Constructor. commandNumUints is given in how many integers.
|
override |
Destructor.
|
protected |
Adds a new, named GPU resource and returns it.
HDST_API void AddBufferResourceView | ( | TfToken const & | name, |
HdTupleType | tupleType, | ||
int | offset | ||
) |
Add an interleaved view to this buffer.
HDST_API void CopyData | ( | std::vector< uint32_t > const & | data | ) |
Update entire buffer data.
|
overridevirtual |
Debug output.
Implements HdBufferArray.
|
overridevirtual |
Performs compaction if necessary and returns true if it becomes empty.
Implements HdBufferArray.
|
inline |
Returns a bar which locates all interleaved resources of the entire buffer.
Definition at line 122 of file dispatchBuffer.h.
|
inline |
Returns the number of uints in a single draw command.
Definition at line 118 of file dispatchBuffer.h.
|
inline |
Returns the dispatch count.
Definition at line 115 of file dispatchBuffer.h.
|
inline |
Returns entire buffer as a single HdBufferResource.
Definition at line 127 of file dispatchBuffer.h.
HDST_API HdStBufferResourceSharedPtr GetResource | ( | ) | const |
Returns the GPU resource.
If the buffer array contains more than one resource, this method raises a coding error.
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.
|
inline |
Returns the list of all named GPU resources for this bufferArray.
Definition at line 155 of file dispatchBuffer.h.
|
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.