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

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

+ Inheritance diagram for HdStResourceRegistry:

Public Member Functions

 HF_MALLOC_TAG_NEW ("new HdStResourceRegistry")
 
HDST_API
HdStDispatchBufferSharedPtr 
RegisterDispatchBuffer (TfToken const &role, int count, int commandNumUints)
 Register a buffer allocated with count * commandNumUints * sizeof(GLuint) to be used as an indirect dispatch buffer. More...
 
HDST_API
HdStPersistentBufferSharedPtr 
RegisterPersistentBuffer (TfToken const &role, size_t dataSize, void *data)
 Register a buffer initialized with dataSize bytes of data to be used as a persistently mapped shader storage buffer. More...
 
HDST_API void GarbageCollectDispatchBuffers ()
 Remove any entries associated with expired dispatch buffers. More...
 
HDST_API void GarbageCollectPersistentBuffers ()
 Remove any entries associated with expired persistently mapped buffers. More...
 
HDST_API
HdBufferArrayRangeSharedPtr 
MergeBufferArrayRange (HdAggregationStrategy *strategy, HdBufferArrayRegistry &bufferArrayRegistry, TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
 Check if range is compatible with newBufferSpecs. More...
 
HDST_API
HdBufferArrayRangeSharedPtr 
MergeNonUniformBufferArrayRange (TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
 MergeBufferArrayRange of non uniform buffer. More...
 
HDST_API
HdBufferArrayRangeSharedPtr 
MergeNonUniformImmutableBufferArrayRange (TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
 MergeBufferArrayRange of non uniform immutable buffer. More...
 
HDST_API
HdBufferArrayRangeSharedPtr 
MergeUniformBufferArrayRange (TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
 MergeBufferArrayRange of uniform buffer. More...
 
HDST_API
HdBufferArrayRangeSharedPtr 
MergeShaderStorageBufferArrayRange (TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
 MergeBufferArrayRange of shader storage buffer. More...
 
HDST_API HdInstance
< HdSt_MeshTopologySharedPtr > 
RegisterMeshTopology (HdInstance< HdSt_MeshTopologySharedPtr >::ID id)
 Instance Registries. More...
 
HDST_API HdInstance
< HdSt_BasisCurvesTopologySharedPtr > 
RegisterBasisCurvesTopology (HdInstance< HdSt_BasisCurvesTopologySharedPtr >::ID id)
 
HDST_API HdInstance
< Hd_VertexAdjacencySharedPtr > 
RegisterVertexAdjacency (HdInstance< Hd_VertexAdjacencySharedPtr >::ID id)
 
HDST_API HdInstance
< HdBufferArrayRangeSharedPtr > 
RegisterMeshIndexRange (HdInstance< HdBufferArrayRangeSharedPtr >::ID id, TfToken const &name)
 Topology Index buffer array range instancing Returns the HdInstance points to shared HdBufferArrayRange, distinguished by given ID. More...
 
HDST_API HdInstance
< HdBufferArrayRangeSharedPtr > 
RegisterBasisCurvesIndexRange (HdInstance< HdBufferArrayRangeSharedPtr >::ID id, TfToken const &name)
 
HDST_API HdInstance
< HdBufferArrayRangeSharedPtr > 
RegisterPrimvarRange (HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
 Primvar array range instancing Returns the HdInstance pointing to shared HdBufferArrayRange, distinguished by given ID. More...
 
HDST_API HdInstance
< HdBufferArrayRangeSharedPtr > 
RegisterExtComputationDataRange (HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
 ExtComputation data array range instancing Returns the HdInstance pointing to shared HdBufferArrayRange, distinguished by given ID. More...
 
HDST_API HdInstance
< HdStTextureResourceSharedPtr > 
RegisterTextureResource (TextureKey id)
 Register a texture into the texture registry. More...
 
HDST_API HdInstance
< HdStTextureResourceSharedPtr > 
FindTextureResource (TextureKey id, bool *found)
 Find a texture in the texture registry. More...
 
HDST_API HdInstance
< HdSt_GeometricShaderSharedPtr > 
RegisterGeometricShader (HdInstance< HdSt_GeometricShaderSharedPtr >::ID id)
 Register a geometric shader. More...
 
HDST_API HdInstance
< HdStGLSLProgramSharedPtr > 
RegisterGLSLProgram (HdInstance< HdStGLSLProgramSharedPtr >::ID id)
 Register a GLSL program into the program registry. More...
 
HDST_API HdInstance
< HdStTextureResourceHandleSharedPtr > 
RegisterTextureResourceHandle (HdInstance< HdStTextureResourceHandleSharedPtr >::ID id)
 Register a texture resource handle. More...
 
HDST_API HdInstance
< HdStTextureResourceHandleSharedPtr > 
FindTextureResourceHandle (HdInstance< HdStTextureResourceHandleSharedPtr >::ID id, bool *found)
 Find a texture resource handle. More...
 
void InvalidateShaderRegistry () override
 Invalidate any shaders registered with this registry. More...
 
- Public Member Functions inherited from HdResourceRegistry
 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...
 

Protected Member Functions

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

Additional Inherited Members

- Public Types inherited from HdResourceRegistry
typedef size_t TextureKey
 Globally unique id for texture, see HdRenderIndex::GetTextureKey() for details. More...
 
- Protected Attributes inherited from HdResourceRegistry
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
 

Detailed Description

A central registry of all GPU resources.

Definition at line 60 of file resourceRegistry.h.

Member Function Documentation

virtual void _GarbageCollect ( )
overrideprotectedvirtual

Hooks for derived registries to perform additional GC when GarbageCollect() or GarbageCollectBprims() is invoked.

Reimplemented from HdResourceRegistry.

virtual void _TallyResourceAllocation ( VtDictionary result) const
overrideprotectedvirtual

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 from HdResourceRegistry.

HDST_API HdInstance<HdStTextureResourceSharedPtr> FindTextureResource ( TextureKey  id,
bool *  found 
)

Find a texture in the texture registry.

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

HDST_API HdInstance<HdStTextureResourceHandleSharedPtr> FindTextureResourceHandle ( HdInstance< HdStTextureResourceHandleSharedPtr >::ID  id,
bool *  found 
)

Find a texture resource handle.

HDST_API void GarbageCollectDispatchBuffers ( )

Remove any entries associated with expired dispatch buffers.

HDST_API void GarbageCollectPersistentBuffers ( )

Remove any entries associated with expired persistently mapped buffers.

void InvalidateShaderRegistry ( )
overridevirtual

Invalidate any shaders registered with this registry.

Reimplemented from HdResourceRegistry.

HDST_API HdBufferArrayRangeSharedPtr MergeBufferArrayRange ( HdAggregationStrategy strategy,
HdBufferArrayRegistry bufferArrayRegistry,
TfToken const &  role,
HdBufferSpecVector const &  newBufferSpecs,
HdBufferArrayUsageHint  newUsageHint,
HdBufferArrayRangeSharedPtr const &  range 
)

Check if range is compatible with newBufferSpecs.

If not, allocate new bufferArrayRange with merged buffer specs, register migration computation and return the new range. Otherwise just return the same range.

HDST_API HdBufferArrayRangeSharedPtr MergeNonUniformBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  newBufferSpecs,
HdBufferArrayUsageHint  newUsageHint,
HdBufferArrayRangeSharedPtr const &  range 
)

MergeBufferArrayRange of non uniform buffer.

HDST_API HdBufferArrayRangeSharedPtr MergeNonUniformImmutableBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  newBufferSpecs,
HdBufferArrayUsageHint  newUsageHint,
HdBufferArrayRangeSharedPtr const &  range 
)

MergeBufferArrayRange of non uniform immutable buffer.

HDST_API HdBufferArrayRangeSharedPtr MergeShaderStorageBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  newBufferSpecs,
HdBufferArrayUsageHint  newUsageHint,
HdBufferArrayRangeSharedPtr const &  range 
)

MergeBufferArrayRange of shader storage buffer.

HDST_API HdBufferArrayRangeSharedPtr MergeUniformBufferArrayRange ( TfToken const &  role,
HdBufferSpecVector const &  newBufferSpecs,
HdBufferArrayUsageHint  newUsageHint,
HdBufferArrayRangeSharedPtr const &  range 
)

MergeBufferArrayRange of uniform buffer.

HDST_API HdStDispatchBufferSharedPtr RegisterDispatchBuffer ( TfToken const &  role,
int  count,
int  commandNumUints 
)

Register a buffer allocated with count * commandNumUints * sizeof(GLuint) to be used as an indirect dispatch buffer.

HDST_API HdInstance<HdBufferArrayRangeSharedPtr> RegisterExtComputationDataRange ( HdInstance< HdBufferArrayRangeSharedPtr >::ID  id)

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.

HDST_API HdInstance<HdSt_GeometricShaderSharedPtr> RegisterGeometricShader ( HdInstance< HdSt_GeometricShaderSharedPtr >::ID  id)

Register a geometric shader.

HDST_API HdInstance<HdStGLSLProgramSharedPtr> RegisterGLSLProgram ( HdInstance< HdStGLSLProgramSharedPtr >::ID  id)

Register a GLSL program into the program registry.

HDST_API HdInstance<HdBufferArrayRangeSharedPtr> RegisterMeshIndexRange ( HdInstance< HdBufferArrayRangeSharedPtr >::ID  id,
TfToken const &  name 
)

Topology 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.

HDST_API HdInstance<HdSt_MeshTopologySharedPtr> RegisterMeshTopology ( HdInstance< HdSt_MeshTopologySharedPtr >::ID  id)

Instance Registries.

These registries implement sharing and deduplication of data based on computed hash identifiers. Each returned HdInstance object retains a shared pointer to a data instance. When an HdInstance is registered for a previously unused ID, the data pointer will be null and it is the caller's responsibility to set its value. The instance registries are cleaned of unreferenced entries during garbage collection.

Note: As entries can be registered from multiple threads, the returned object holds a lock on the instance registry. This lock is held until the returned HdInstance object is destroyed. Topology instancing

HDST_API HdStPersistentBufferSharedPtr RegisterPersistentBuffer ( TfToken const &  role,
size_t  dataSize,
void *  data 
)

Register a buffer initialized with dataSize bytes of data to be used as a persistently mapped shader storage buffer.

HDST_API HdInstance<HdBufferArrayRangeSharedPtr> RegisterPrimvarRange ( HdInstance< HdBufferArrayRangeSharedPtr >::ID  id)

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

*Refer the comment on RegisterTopology for the same consideration.

HDST_API HdInstance<HdStTextureResourceSharedPtr> RegisterTextureResource ( TextureKey  id)

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.

HDST_API HdInstance<HdStTextureResourceHandleSharedPtr> RegisterTextureResourceHandle ( HdInstance< HdStTextureResourceHandleSharedPtr >::ID  id)

Register a texture resource handle.


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