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

A central registry of all GPU resources. More...

+ Inheritance diagram for HdResourceRegistry:

Public Types

typedef size_t TextureKey
 Globally unique id for texture, see RegisterTextureResource() for details. More...
 

Public Member Functions

 HF_MALLOC_TAG_NEW ("new HdResourceRegistry")
 
HD_API HdBufferArrayRangeSharedPtr AllocateNonUniformBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 Allocate new non uniform buffer array range. More...
 
HD_API HdBufferArrayRangeSharedPtr AllocateNonUniformImmutableBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 Allocate new immutable non uniform buffer array range. More...
 
HD_API HdBufferArrayRangeSharedPtr AllocateUniformBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 Allocate new uniform buffer range. More...
 
HD_API HdBufferArrayRangeSharedPtr AllocateShaderStorageBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 Allocate new shader storage buffer range. More...
 
HD_API HdBufferArrayRangeSharedPtr AllocateSingleBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 Allocate single entry (non-aggregated) buffer array range. More...
 
HD_API void AddSources (HdBufferArrayRangeSharedPtr const &range, HdBufferSourceVector &sources)
 Append source data for given range to be committed later. More...
 
HD_API void AddSource (HdBufferArrayRangeSharedPtr const &range, HdBufferSourceSharedPtr const &source)
 Append a source data for given range to be committed later. More...
 
HD_API void AddSource (HdBufferSourceSharedPtr const &source)
 Append a source data just to be resolved (used for cpu computations). More...
 
HD_API void AddComputation (HdBufferArrayRangeSharedPtr const &range, HdComputationSharedPtr const &computaion)
 Append a gpu computation into queue. More...
 
HD_API void Commit ()
 Commits all in-flight source data to the GPU, freeing the source buffers. More...
 
HD_API void GarbageCollect ()
 cleanup all buffers and remove if empty More...
 
HD_API void GarbageCollectBprims ()
 cleanup all Bprim registries More...
 
void SetNonUniformAggregationStrategy (HdAggregationStrategy *strategy)
 Set the aggregation strategy for non uniform parameters (vertex, varying, facevarying) Takes ownership of the passed in strategy object. More...
 
void SetNonUniformImmutableAggregationStrategy (HdAggregationStrategy *strategy)
 Set the aggregation strategy for non uniform immutable parameters (vertex, varying, facevarying) Takes ownership of the passed in strategy object. More...
 
void SetUniformAggregationStrategy (HdAggregationStrategy *strategy)
 Set the aggregation strategy for uniform (shader globals) Takes ownership of the passed in strategy object. More...
 
void SetShaderStorageAggregationStrategy (HdAggregationStrategy *strategy)
 Set the aggregation strategy for SSBO (uniform primvars) Takes ownership of the passed in strategy object. More...
 
void SetSingleStorageAggregationStrategy (HdAggregationStrategy *strategy)
 Set the aggregation strategy for single buffers (for nested instancer). More...
 
bool HasNonUniformAggregationStrategy () const
 Returns whether an aggregation strategy is set for non uniform params. More...
 
bool HasNonUniformImmutableAggregationStrategy () const
 Returns whether an aggregation strategy is set for non uniform immutable params. More...
 
bool HasUniformAggregationStrategy () const
 Returns whether an aggregation strategy is set for uniform params. More...
 
bool HasShaderStorageAggregationStrategy () const
 Returns whether an aggregation strategy is set for SSBO. More...
 
bool HasSingleStorageAggregationStrategy () const
 Returns whether an aggregation strategy is set for single buffers. More...
 
HD_API VtDictionary GetResourceAllocation () const
 Returns a report of resource allocation by role in bytes and a summary total allocation of GPU memory in bytes for this registry. More...
 
HD_API std::unique_lock
< std::mutex > 
RegisterMeshTopology (HdTopology::ID id, HdInstance< HdTopology::ID, HdMeshTopologySharedPtr > *pInstance)
 Topology instancing Returns (in the pointer) the HdInstance points to shared HdMeshTopology, distinguished by given ID. More...
 
HD_API std::unique_lock
< std::mutex > 
RegisterBasisCurvesTopology (HdTopology::ID id, HdInstance< HdTopology::ID, HdBasisCurvesTopologySharedPtr > *pInstance)
 
HD_API std::unique_lock
< std::mutex > 
RegisterVertexAdjacency (HdTopology::ID id, HdInstance< HdTopology::ID, Hd_VertexAdjacencySharedPtr > *pInstance)
 
HD_API std::unique_lock
< std::mutex > 
RegisterMeshIndexRange (HdTopology::ID id, TfToken const &name, HdInstance< HdTopology::ID, HdBufferArrayRangeSharedPtr > *pInstance)
 Index buffer array range instancing Returns the HdInstance points to shared HdBufferArrayRange, distinguished by given ID. More...
 
HD_API std::unique_lock
< std::mutex > 
RegisterBasisCurvesIndexRange (HdTopology::ID id, TfToken const &name, HdInstance< HdTopology::ID, HdBufferArrayRangeSharedPtr > *pInstance)
 
HD_API std::unique_lock
< std::mutex > 
RegisterPrimvarRange (HdTopology::ID id, HdInstance< HdTopology::ID, HdBufferArrayRangeSharedPtr > *pInstance)
 Primvar array range instancing Returns the HdInstance pointing to shared HdBufferArrayRange, distinguished by given ID. More...
 
HD_API std::unique_lock
< std::mutex > 
RegisterExtComputationDataRange (HdTopology::ID id, HdInstance< HdTopology::ID, HdBufferArrayRangeSharedPtr > *pInstance)
 ExtComputation data array range instancing Returns the HdInstance pointing to shared HdBufferArrayRange, distinguished by given ID. More...
 
HD_API std::unique_lock
< std::mutex > 
RegisterTextureResource (TextureKey id, HdInstance< TextureKey, HdTextureResourceSharedPtr > *pInstance)
 Register a texture into the texture registry. More...
 
HD_API std::unique_lock
< std::mutex > 
FindTextureResource (TextureKey id, HdInstance< TextureKey, HdTextureResourceSharedPtr > *instance, bool *found)
 Find a texture in the texture registry. More...
 
virtual HD_API void InvalidateShaderRegistry ()
 Invalidate any shaders registered with this registry. More...
 

Protected Member Functions

virtual void _GarbageCollect ()
 A hook for derived registries to perform additional GC when GarbageCollect() is invoked. More...
 
virtual void _TallyResourceAllocation (VtDictionary *result) const
 A hook for derived registries to tally their resources by key into the given dictionary. More...
 

Protected Attributes

HdBufferArrayRegistry _nonUniformBufferArrayRegistry
 
HdBufferArrayRegistry _nonUniformImmutableBufferArrayRegistry
 
HdBufferArrayRegistry _uniformUboBufferArrayRegistry
 
HdBufferArrayRegistry _uniformSsboBufferArrayRegistry
 
HdBufferArrayRegistry _singleBufferArrayRegistry
 
std::unique_ptr
< HdAggregationStrategy
_nonUniformAggregationStrategy
 
std::unique_ptr
< HdAggregationStrategy
_nonUniformImmutableAggregationStrategy
 
std::unique_ptr
< HdAggregationStrategy
_uniformUboAggregationStrategy
 
std::unique_ptr
< HdAggregationStrategy
_uniformSsboAggregationStrategy
 
std::unique_ptr
< HdAggregationStrategy
_singleAggregationStrategy
 

Friends

HD_API friend std::ostream & operator<< (std::ostream &out, const HdResourceRegistry &self)
 Debug dump. More...
 

Detailed Description

A central registry of all GPU resources.

Definition at line 71 of file resourceRegistry.h.

Member Typedef Documentation

typedef size_t TextureKey

Globally unique id for texture, see RegisterTextureResource() for details.

Definition at line 275 of file resourceRegistry.h.

Member Function Documentation

virtual void _GarbageCollect ( )
protectedvirtual

A hook for derived registries to perform additional GC when GarbageCollect() is invoked.

Reimplemented in HdStResourceRegistry.

virtual void _TallyResourceAllocation ( VtDictionary result) const
protectedvirtual

A hook for derived registries to tally their resources by key into the given dictionary.

Any additions should be cumulative with the existing key values.

Reimplemented in HdStResourceRegistry.

HD_API void AddComputation ( HdBufferArrayRangeSharedPtr const &  range,
HdComputationSharedPtr const &  computaion 
)

Append a gpu computation into queue.

The parameter 'range' specifies the destination buffer range, which has to be allocated by caller of this function.

note: GPU computations will be executed in the order that they are registered.

HD_API void AddSource ( HdBufferArrayRangeSharedPtr const &  range,
HdBufferSourceSharedPtr const &  source 
)

Append a source data for given range to be committed later.

HD_API void AddSource ( HdBufferSourceSharedPtr const &  source)

Append a source data just to be resolved (used for cpu computations).

HD_API void AddSources ( HdBufferArrayRangeSharedPtr const &  range,
HdBufferSourceVector &  sources 
)

Append source data for given range to be committed later.

HD_API HdBufferArrayRangeSharedPtr AllocateNonUniformBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)

Allocate new non uniform buffer array range.

HD_API HdBufferArrayRangeSharedPtr AllocateNonUniformImmutableBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)

Allocate new immutable non uniform buffer array range.

HD_API HdBufferArrayRangeSharedPtr AllocateShaderStorageBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)

Allocate new shader storage buffer range.

HD_API HdBufferArrayRangeSharedPtr AllocateSingleBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)

Allocate single entry (non-aggregated) buffer array range.

HD_API HdBufferArrayRangeSharedPtr AllocateUniformBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)

Allocate new uniform buffer range.

HD_API void Commit ( )

Commits all in-flight source data to the GPU, freeing the source buffers.

HD_API std::unique_lock<std::mutex> FindTextureResource ( TextureKey  id,
HdInstance< TextureKey, HdTextureResourceSharedPtr > *  instance,
bool *  found 
)

Find a texture in the texture registry.

If found, it returns it. See RegisterTextureResource() for parameter details.

HD_API void GarbageCollect ( )

cleanup all buffers and remove if empty

HD_API void GarbageCollectBprims ( )

cleanup all Bprim registries

HD_API VtDictionary GetResourceAllocation ( ) const

Returns a report of resource allocation by role in bytes and a summary total allocation of GPU memory in bytes for this registry.

bool HasNonUniformAggregationStrategy ( ) const
inline

Returns whether an aggregation strategy is set for non uniform params.

Definition at line 186 of file resourceRegistry.h.

bool HasNonUniformImmutableAggregationStrategy ( ) const
inline

Returns whether an aggregation strategy is set for non uniform immutable params.

Definition at line 192 of file resourceRegistry.h.

bool HasShaderStorageAggregationStrategy ( ) const
inline

Returns whether an aggregation strategy is set for SSBO.

Definition at line 202 of file resourceRegistry.h.

bool HasSingleStorageAggregationStrategy ( ) const
inline

Returns whether an aggregation strategy is set for single buffers.

Definition at line 207 of file resourceRegistry.h.

bool HasUniformAggregationStrategy ( ) const
inline

Returns whether an aggregation strategy is set for uniform params.

Definition at line 197 of file resourceRegistry.h.

virtual HD_API void InvalidateShaderRegistry ( )
virtual

Invalidate any shaders registered with this registry.

Reimplemented in HdStResourceRegistry.

HD_API std::unique_lock<std::mutex> RegisterExtComputationDataRange ( HdTopology::ID  id,
HdInstance< HdTopology::ID, HdBufferArrayRangeSharedPtr > *  pInstance 
)

ExtComputation data array range instancing Returns the HdInstance pointing to shared HdBufferArrayRange, distinguished by given ID.

*Refer the comment on RegisterTopology for the same consideration.

HD_API std::unique_lock<std::mutex> RegisterMeshIndexRange ( HdTopology::ID  id,
TfToken const &  name,
HdInstance< HdTopology::ID, HdBufferArrayRangeSharedPtr > *  pInstance 
)

Index buffer array range instancing Returns the HdInstance points to shared HdBufferArrayRange, distinguished by given ID.

*Refer the comment on RegisterTopology for the same consideration.

HD_API std::unique_lock<std::mutex> RegisterMeshTopology ( HdTopology::ID  id,
HdInstance< HdTopology::ID, HdMeshTopologySharedPtr > *  pInstance 
)

Topology instancing Returns (in the pointer) the HdInstance points to shared HdMeshTopology, distinguished by given ID.

If IsFirstInstance() of the instance is true, the caller is responsible to initialize the HdMeshTopology. Also the HdMeshTopology has to be owned by someone else, otherwise the entry will get deleted on GarbageCollect(). HdInstance is intended to be used for temporary pointer, so the caller should not hold the instance for an extended time. ID is used as a hash key and the resolution of hash collision is the client's responsibility.

Note: As entries can be added by multiple threads the routine returns a lock on the instance registry. This lock should be held until the HdInstance object is destroyed.

HD_API std::unique_lock<std::mutex> RegisterPrimvarRange ( HdTopology::ID  id,
HdInstance< HdTopology::ID, HdBufferArrayRangeSharedPtr > *  pInstance 
)

Primvar array range instancing Returns the HdInstance pointing to shared HdBufferArrayRange, distinguished by given ID.

*Refer the comment on RegisterTopology for the same consideration.

HD_API std::unique_lock<std::mutex> RegisterTextureResource ( TextureKey  id,
HdInstance< TextureKey, HdTextureResourceSharedPtr > *  pInstance 
)

Register a texture into the texture registry.

Typically the other id's used refer to unique content where as for textures it's a unique id provided by the scene delegate. Hydra expects the id's to be unique in the context of a scene/stage aka render index. However, the texture registry can be shared between multiple render indices, so the renderIndexId is used to create a globally unique id for the texture resource.

void SetNonUniformAggregationStrategy ( HdAggregationStrategy strategy)
inline

Set the aggregation strategy for non uniform parameters (vertex, varying, facevarying) Takes ownership of the passed in strategy object.

Definition at line 155 of file resourceRegistry.h.

void SetNonUniformImmutableAggregationStrategy ( HdAggregationStrategy strategy)
inline

Set the aggregation strategy for non uniform immutable parameters (vertex, varying, facevarying) Takes ownership of the passed in strategy object.

Definition at line 162 of file resourceRegistry.h.

void SetShaderStorageAggregationStrategy ( HdAggregationStrategy strategy)
inline

Set the aggregation strategy for SSBO (uniform primvars) Takes ownership of the passed in strategy object.

Definition at line 175 of file resourceRegistry.h.

void SetSingleStorageAggregationStrategy ( HdAggregationStrategy strategy)
inline

Set the aggregation strategy for single buffers (for nested instancer).

Takes ownership of the passed in strategy object.

Definition at line 181 of file resourceRegistry.h.

void SetUniformAggregationStrategy ( HdAggregationStrategy strategy)
inline

Set the aggregation strategy for uniform (shader globals) Takes ownership of the passed in strategy object.

Definition at line 169 of file resourceRegistry.h.

Friends And Related Function Documentation

HD_API friend std::ostream& operator<< ( std::ostream &  out,
const HdResourceRegistry self 
)
friend

Debug dump.


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