HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HdStDispatchBuffer Class Reference

#include <dispatchBuffer.h>

+ Inheritance diagram for HdStDispatchBuffer:

Public Member Functions

HDST_API HdStDispatchBuffer (Hgi *hgi, TfToken const &role, int count, unsigned int commandNumUints)
 Constructor. commandNumUints is given in how many integers. More...
 
HDST_API ~HdStDispatchBuffer ()
 Destructor. More...
 
HDST_API void CopyData (std::vector< GLuint > 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 GLuints in a single draw command. More...
 
HdStBufferArrayRangeGLSharedPtr GetBufferArrayRange () const
 
HdStBufferResourceGLSharedPtr GetEntireResource () const
 Returns entire buffer as a single HdBufferResource. More...
 
virtual HDST_API bool GarbageCollect ()
 Performs compaction if necessary and returns true if it becomes empty. More...
 
virtual HDST_API void Reallocate (std::vector< HdBufferArrayRangeSharedPtr > const &, HdBufferArraySharedPtr const &)
 
virtual HDST_API void DebugDump (std::ostream &out) const
 Debug output. More...
 
HDST_API
HdStBufferResourceGLSharedPtr 
GetResource () const
 
HDST_API
HdStBufferResourceGLSharedPtr 
GetResource (TfToken const &name)
 
HdStBufferResourceGLNamedList
const
GetResources () const
 Returns the list of all named GPU resources for this bufferArray. More...
 
- Public Member Functions inherited from HdBufferArray
HD_API HdBufferArray (TfToken const &role, TfToken const garbageCollectionPerfToken, HdBufferArrayUsageHint usageHint)
 
virtual HD_API ~HdBufferArray ()
 
TfToken constGetRole () const
 Returns the role of the GPU data in this bufferArray. More...
 
size_t GetVersion () const
 
HD_API void IncrementVersion ()
 Increments the version of this buffer array. More...
 
HD_API bool TryAssignRange (HdBufferArrayRangeSharedPtr &range)
 
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 ()
 
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
HdStBufferResourceGLSharedPtr 
_AddResource (TfToken const &name, HdTupleType tupleType, int offset, int stride)
 Adds a new, named GPU resource and returns it. More...
 
- Protected Member Functions inherited from HdBufferArray
void _SetMaxNumRanges (size_t max)
 
HD_API void _SetRangeList (std::vector< HdBufferArrayRangeSharedPtr > const &ranges)
 Swap the rangelist with ranges. More...
 

Additional Inherited Members

- Protected Attributes inherited from HdBufferArray
bool _needsReallocation
 

Detailed Description

A VBO of a simple array of GLuint.

This buffer is used to prepare data on the GPU for indirect dispatch i.e. to be consumed by glMultiDrawIndirect or glDispatchComputeIndirect. 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 GLuint 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

HDST_API HdStDispatchBuffer::HdStDispatchBuffer ( Hgi hgi,
TfToken const role,
int  count,
unsigned int  commandNumUints 
)

Constructor. commandNumUints is given in how many integers.

HDST_API HdStDispatchBuffer::~HdStDispatchBuffer ( )

Destructor.

Member Function Documentation

HDST_API HdStBufferResourceGLSharedPtr HdStDispatchBuffer::_AddResource ( TfToken const name,
HdTupleType  tupleType,
int  offset,
int  stride 
)
protected

Adds a new, named GPU resource and returns it.

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

Add an interleaved view to this buffer.

HDST_API void HdStDispatchBuffer::CopyData ( std::vector< GLuint > const data)

Update entire buffer data.

virtual HDST_API void HdStDispatchBuffer::DebugDump ( std::ostream &  out) const
virtual

Debug output.

Implements HdBufferArray.

virtual HDST_API bool HdStDispatchBuffer::GarbageCollect ( )
virtual

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

Implements HdBufferArray.

HdStBufferArrayRangeGLSharedPtr HdStDispatchBuffer::GetBufferArrayRange ( ) const
inline

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

Definition at line 119 of file dispatchBuffer.h.

unsigned int HdStDispatchBuffer::GetCommandNumUints ( ) const
inline

Returns the number of GLuints in a single draw command.

Definition at line 115 of file dispatchBuffer.h.

int HdStDispatchBuffer::GetCount ( ) const
inline

Returns the dispatch count.

Definition at line 112 of file dispatchBuffer.h.

HdStBufferResourceGLSharedPtr HdStDispatchBuffer::GetEntireResource ( ) const
inline

Returns entire buffer as a single HdBufferResource.

Definition at line 124 of file dispatchBuffer.h.

HDST_API HdStBufferResourceGLSharedPtr HdStDispatchBuffer::GetResource ( ) const

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

HDST_API HdStBufferResourceGLSharedPtr HdStDispatchBuffer::GetResource ( TfToken const name)

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

HdStBufferResourceGLNamedList const& HdStDispatchBuffer::GetResources ( ) const
inline

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

Definition at line 152 of file dispatchBuffer.h.

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

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: