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

#include <resourceRegistry.h>

+ Inheritance diagram for HdStResourceRegistry:

Public Member Functions

 HF_MALLOC_TAG_NEW ("new HdStResourceRegistry")
 
HDST_API HdStResourceRegistry (Hgi *hgi)
 
HDST_API ~HdStResourceRegistry () override
 
HDST_API void InvalidateShaderRegistry () override
 Invalidate any shaders registered with this registry. More...
 
HDST_API VtDictionary GetResourceAllocation () const override
 
HDST_API HgiGetHgi ()
 Returns Hgi used to create/destroy GPU resources. More...
 
HDST_API HdStTextureHandleSharedPtr AllocateTextureHandle (const HdStTextureIdentifier &textureId, HdTextureType textureType, const HdSamplerParameters &samplerParams, size_t memoryRequest, bool createBindlessHandle, HdStShaderCodePtr const &shaderCode)
 
HDST_API HdStTextureObjectSharedPtr AllocateTextureObject (const HdStTextureIdentifier &textureId, HdTextureType textureType)
 
HDST_API
HdBufferArrayRangeSharedPtr 
AllocateNonUniformBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
AllocateNonUniformImmutableBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
AllocateUniformBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
AllocateShaderStorageBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
AllocateSingleBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
UpdateNonUniformBufferArrayRange (TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
UpdateNonUniformImmutableBufferArrayRange (TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
UpdateUniformBufferArrayRange (TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API
HdBufferArrayRangeSharedPtr 
UpdateShaderStorageBufferArrayRange (TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
 
HDST_API void AddSources (HdBufferArrayRangeSharedPtr const &range, HdBufferSourceSharedPtrVector &&sources)
 Append source data for given range to be committed later. More...
 
HDST_API void AddSource (HdBufferArrayRangeSharedPtr const &range, HdBufferSourceSharedPtr const &source)
 Append a source data for given range to be committed later. More...
 
HDST_API void AddSource (HdBufferSourceSharedPtr const &source)
 Append a source data just to be resolved (used for cpu computations). More...
 
HDST_API void AddComputation (HdBufferArrayRangeSharedPtr const &range, HdComputationSharedPtr const &computaion)
 
HDST_API
HdStDispatchBufferSharedPtr 
RegisterDispatchBuffer (TfToken const &role, int count, int commandNumUints)
 
HDST_API
HdStPersistentBufferSharedPtr 
RegisterPersistentBuffer (TfToken const &role, size_t dataSize, void *data)
 
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 HdInstance
< HdSt_MeshTopologySharedPtr
RegisterMeshTopology (HdInstance< HdSt_MeshTopologySharedPtr >::ID id)
 Topology instancing. 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)
 
HDST_API HdInstance
< HdBufferArrayRangeSharedPtr
RegisterBasisCurvesIndexRange (HdInstance< HdBufferArrayRangeSharedPtr >::ID id, TfToken const &name)
 
HDST_API HdInstance
< HdBufferArrayRangeSharedPtr
RegisterPrimvarRange (HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
 
HDST_API HdInstance
< HdBufferArrayRangeSharedPtr
RegisterExtComputationDataRange (HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
 
HDST_API HdInstance
< HdStTextureResourceSharedPtr
RegisterTextureResource (TextureKey id)
 
HDST_API HdInstance
< HdStTextureResourceSharedPtr
FindTextureResource (TextureKey id, bool *found)
 
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 SetNonUniformAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 
void SetNonUniformImmutableAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 
void SetUniformAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 
void SetShaderStorageAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 
void SetSingleStorageAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 
- Public Member Functions inherited from HdResourceRegistry
 HF_MALLOC_TAG_NEW ("new HdResourceRegistry")
 
HD_API HdResourceRegistry ()
 
virtual HD_API ~HdResourceRegistry ()
 
HD_API void Commit ()
 Commits all in-flight source data. More...
 
HD_API void GarbageCollect ()
 cleanup all buffers and remove if empty More...
 
HD_API void GarbageCollectBprims ()
 cleanup all Bprim registries More...
 
virtual HD_API void ReloadResource (TfToken const &resourceType, std::string const &path)
 

Protected Member Functions

void _Commit () override
 A hook for derived registries to perform additional resource commits. More...
 
void _GarbageCollect () override
 
void _GarbageCollectBprims () override
 

Friends

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

Additional Inherited Members

- Public Types inherited from HdResourceRegistry
typedef size_t TextureKey
 

Detailed Description

A central registry of all GPU resources.

Definition at line 86 of file resourceRegistry.h.

Constructor & Destructor Documentation

HDST_API HdStResourceRegistry::HdStResourceRegistry ( Hgi hgi)
explicit
HDST_API HdStResourceRegistry::~HdStResourceRegistry ( )
override

Member Function Documentation

void HdStResourceRegistry::_Commit ( )
overrideprotectedvirtual

A hook for derived registries to perform additional resource commits.

Reimplemented from HdResourceRegistry.

void HdStResourceRegistry::_GarbageCollect ( )
overrideprotectedvirtual

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

Reimplemented from HdResourceRegistry.

void HdStResourceRegistry::_GarbageCollectBprims ( )
overrideprotectedvirtual

Reimplemented from HdResourceRegistry.

HDST_API void HdStResourceRegistry::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.

HDST_API void HdStResourceRegistry::AddSource ( HdBufferArrayRangeSharedPtr const range,
HdBufferSourceSharedPtr const source 
)

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

HDST_API void HdStResourceRegistry::AddSource ( HdBufferSourceSharedPtr const source)

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

HDST_API void HdStResourceRegistry::AddSources ( HdBufferArrayRangeSharedPtr const range,
HdBufferSourceSharedPtrVector &&  sources 
)

Append source data for given range to be committed later.


Resource update & computation queuing API

HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::AllocateNonUniformBufferArrayRange ( TfToken const role,
HdBufferSpecVector const bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)

BAR allocation API

The Allocate* flavor of methods allocate a new BAR for the given buffer specs using the chosen aggregation strategy.

HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::AllocateNonUniformImmutableBufferArrayRange ( TfToken const role,
HdBufferSpecVector const bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)
HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::AllocateShaderStorageBufferArrayRange ( TfToken const role,
HdBufferSpecVector const bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)
HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::AllocateSingleBufferArrayRange ( TfToken const role,
HdBufferSpecVector const bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)
HDST_API HdStTextureHandleSharedPtr HdStResourceRegistry::AllocateTextureHandle ( const HdStTextureIdentifier textureId,
HdTextureType  textureType,
const HdSamplerParameters samplerParams,
size_t  memoryRequest,
bool  createBindlessHandle,
HdStShaderCodePtr const shaderCode 
)

Texture allocation API

Allocate texture handle (encapsulates texture and sampler object, bindless texture sampler handle, memory request and callback to shader).

The actual allocation of the associated GPU texture and sampler resources and loading of the texture file is delayed until the commit phase.

Parameters
textureIdPath to file and information to identify a texture if the file is a container for several textures (e.g., OpenVDB file containing several grids, movie file containing frames).
textureTypeTexture type, e.g., uv, ptex, ...
samplerParamsSampling parameters such as wrapS, ... wrapS, wrapT, wrapR mode, min filer, mag filter
memoryRequestMemory request. The texture is down-sampled to meet the target memory which is the maximum of all memory requests associated to the texture. If all memory requests are 0, no down-sampling will happen.
createBindlessHandleAlso create a GL texture sampler handle for bindless textures.
shaderCodeAfter the texture is committed (or after it has been changed) the given shader code can add additional buffer sources and computations using the texture metadata with AddResourcesFromTextures.
HDST_API HdStTextureObjectSharedPtr HdStResourceRegistry::AllocateTextureObject ( const HdStTextureIdentifier textureId,
HdTextureType  textureType 
)

Allocate texture object.

The actual allocation of the associated GPU texture and sampler resources and loading of the texture file is delayed until the commit phase.

Parameters
textureIdPath to file and information to identify a texture if the file is a container for several textures (e.g., OpenVDB file containing several grids, movie file containing frames).
textureTypeTexture type, e.g., uv, ptex, ...
HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::AllocateUniformBufferArrayRange ( TfToken const role,
HdBufferSpecVector const bufferSpecs,
HdBufferArrayUsageHint  usageHint 
)
HDST_API HdInstance<HdStTextureResourceSharedPtr> HdStResourceRegistry::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> HdStResourceRegistry::FindTextureResourceHandle ( HdInstance< HdStTextureResourceHandleSharedPtr >::ID  id,
bool *  found 
)

Find a texture resource handle.

HDST_API void HdStResourceRegistry::GarbageCollectDispatchBuffers ( )

Remove any entries associated with expired dispatch buffers.

HDST_API void HdStResourceRegistry::GarbageCollectPersistentBuffers ( )

Remove any entries associated with expired persistently mapped buffers.

HDST_API Hgi* HdStResourceRegistry::GetHgi ( )

Returns Hgi used to create/destroy GPU resources.

HDST_API VtDictionary HdStResourceRegistry::GetResourceAllocation ( ) const
overridevirtual

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

Reimplemented from HdResourceRegistry.

HdStResourceRegistry::HF_MALLOC_TAG_NEW ( "new HdStResourceRegistry )
HDST_API void HdStResourceRegistry::InvalidateShaderRegistry ( )
overridevirtual

Invalidate any shaders registered with this registry.

Reimplemented from HdResourceRegistry.

HDST_API HdInstance<HdBufferArrayRangeSharedPtr> HdStResourceRegistry::RegisterBasisCurvesIndexRange ( HdInstance< HdBufferArrayRangeSharedPtr >::ID  id,
TfToken const name 
)
HDST_API HdInstance<HdSt_BasisCurvesTopologySharedPtr> HdStResourceRegistry::RegisterBasisCurvesTopology ( HdInstance< HdSt_BasisCurvesTopologySharedPtr >::ID  id)
HDST_API HdStDispatchBufferSharedPtr HdStResourceRegistry::RegisterDispatchBuffer ( TfToken const role,
int  count,
int  commandNumUints 
)

Dispatch & persistent buffer API

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

HDST_API HdInstance<HdBufferArrayRangeSharedPtr> HdStResourceRegistry::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> HdStResourceRegistry::RegisterGeometricShader ( HdInstance< HdSt_GeometricShaderSharedPtr >::ID  id)

Register a geometric shader.

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

Register a GLSL program into the program registry.

HDST_API HdInstance<HdBufferArrayRangeSharedPtr> HdStResourceRegistry::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> HdStResourceRegistry::RegisterMeshTopology ( HdInstance< HdSt_MeshTopologySharedPtr >::ID  id)

Topology instancing.


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.

HDST_API HdStPersistentBufferSharedPtr HdStResourceRegistry::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> HdStResourceRegistry::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> HdStResourceRegistry::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> HdStResourceRegistry::RegisterTextureResourceHandle ( HdInstance< HdStTextureResourceHandleSharedPtr >::ID  id)

Register a texture resource handle.

HDST_API HdInstance<Hd_VertexAdjacencySharedPtr> HdStResourceRegistry::RegisterVertexAdjacency ( HdInstance< Hd_VertexAdjacencySharedPtr >::ID  id)
void HdStResourceRegistry::SetNonUniformAggregationStrategy ( std::unique_ptr< 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 403 of file resourceRegistry.h.

void HdStResourceRegistry::SetNonUniformImmutableAggregationStrategy ( std::unique_ptr< 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 411 of file resourceRegistry.h.

void HdStResourceRegistry::SetShaderStorageAggregationStrategy ( std::unique_ptr< HdAggregationStrategy > &&  strategy)
inline

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

Definition at line 425 of file resourceRegistry.h.

void HdStResourceRegistry::SetSingleStorageAggregationStrategy ( std::unique_ptr< HdAggregationStrategy > &&  strategy)
inline

Set the aggregation strategy for single buffers (for nested instancer). Takes ownership of the passed in strategy object.

Definition at line 432 of file resourceRegistry.h.

void HdStResourceRegistry::SetUniformAggregationStrategy ( std::unique_ptr< HdAggregationStrategy > &&  strategy)
inline

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

Definition at line 418 of file resourceRegistry.h.

HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::UpdateNonUniformBufferArrayRange ( TfToken const role,
HdBufferArrayRangeSharedPtr const curRange,
HdBufferSpecVector const updatedOrAddedSpecs,
HdBufferSpecVector const removedSpecs,
HdBufferArrayUsageHint  usageHint 
)

BAR allocation/migration/update API

The Update* flavor of methods handle both allocation of a new BAR and reallocation-migration based on the existing range, updated/added specs, removed specs and usage hint. This allows client code to be less verbose when a range's signature (specs) can change.

If curRange is invalid, this is equivalent to calling Allocate*. Otherwise, checks if curRange needs to be migrated to a new range (based on updatedOrAddedSpecs and removedSpecs and usageHint). If migration is necessary, allocate a new range and register necessary migration computations and return the new range. Otherwise, just return the same range.

HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::UpdateNonUniformImmutableBufferArrayRange ( TfToken const role,
HdBufferArrayRangeSharedPtr const curRange,
HdBufferSpecVector const updatedOrAddedSpecs,
HdBufferSpecVector const removedSpecs,
HdBufferArrayUsageHint  usageHint 
)
HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::UpdateShaderStorageBufferArrayRange ( TfToken const role,
HdBufferArrayRangeSharedPtr const curRange,
HdBufferSpecVector const updatedOrAddedSpecs,
HdBufferSpecVector const removedSpecs,
HdBufferArrayUsageHint  usageHint 
)
HDST_API HdBufferArrayRangeSharedPtr HdStResourceRegistry::UpdateUniformBufferArrayRange ( TfToken const role,
HdBufferArrayRangeSharedPtr const curRange,
HdBufferSpecVector const updatedOrAddedSpecs,
HdBufferSpecVector const removedSpecs,
HdBufferArrayUsageHint  usageHint 
)

Friends And Related Function Documentation

HDST_API friend std::ostream& operator<< ( std::ostream &  out,
const HdStResourceRegistry self 
)
friend

Debug dump.


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