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

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

+ Inheritance diagram for HdStResourceRegistry:

Public Member Functions

 HF_MALLOC_TAG_NEW ("new HdStResourceRegistry")
 
HDST_API HdStResourceRegistry (Hgi *hgi)
 
HDST_API void InvalidateShaderRegistry () override
 Invalidate any shaders registered with this registry. More...
 
HDST_API void ReloadResource (TfToken const &resourceType, std::string const &path) override
 Generic method to inform RenderDelegate a resource needs to be reloaded. More...
 
HDST_API VtDictionary GetResourceAllocation () const override
 Returns a report of resource allocation by role in bytes and a summary total allocation of GPU memory in bytes for this registry. More...
 
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)
 

Texture allocation API

More...
 
HDST_API HdStTextureObjectSharedPtr AllocateTextureObject (const HdStTextureIdentifier &textureId, HdTextureType textureType)
 Allocate texture object. More...
 
HDST_API void SetMemoryRequestForTextureType (HdTextureType textureType, size_t memoryRequest)
 Sets how much memory a single texture can consume in bytes by texture type. More...
 
HDST_API
HdBufferArrayRangeSharedPtr 
AllocateNonUniformBufferArrayRange (TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
 

BAR allocation API

More...
 
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)
 

BAR allocation/migration/update API

More...
 
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)
 

Resource update & computation queuing API

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 &computation, HdStComputeQueue const queue)
 Append a gpu computation into queue. More...
 
HDST_API
HdStDispatchBufferSharedPtr 
RegisterDispatchBuffer (TfToken const &role, int count, int commandNumUints)
 

Dispatch & buffer API

More...
 
HDST_API
HdStBufferResourceSharedPtr 
RegisterBufferResource (TfToken const &role, HdTupleType tupleType)
 Register a misc buffer resource. More...
 
HDST_API void GarbageCollectDispatchBuffers ()
 Remove any entries associated with expired dispatch buffers. More...
 
HDST_API void GarbageCollectBufferResources ()
 Remove any entries associated with expired misc buffers. 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
< 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
< HioGlslfxSharedPtr > 
RegisterGLSLFXFile (HdInstance< HioGlslfxSharedPtr >::ID id)
 Register a GLSLFX file. More...
 
HDST_API HdInstance
< HgiResourceBindingsSharedPtr > 
RegisterResourceBindings (HdInstance< HgiResourceBindingsSharedPtr >::ID id)
 Register a Hgi resource bindings into the registry. More...
 
HDST_API HdInstance
< HgiGraphicsPipelineSharedPtr > 
RegisterGraphicsPipeline (HdInstance< HgiGraphicsPipelineSharedPtr >::ID id)
 Register a Hgi graphics pipeline into the registry. More...
 
HDST_API HdInstance
< HgiComputePipelineSharedPtr > 
RegisterComputePipeline (HdInstance< HgiComputePipelineSharedPtr >::ID id)
 Register a Hgi compute pipeline into the registry. More...
 
HDST_API HgiBlitCmdsGetGlobalBlitCmds ()
 Returns the global hgi blit command queue for recording blitting work. More...
 
HDST_API HgiComputeCmdsGetGlobalComputeCmds ()
 Returns the global hgi compute cmd queue for recording compute work. More...
 
HDST_API void SubmitBlitWork (HgiSubmitWaitType wait=HgiSubmitWaitTypeNoWait)
 Submits blit work queued in global blit cmds for GPU execution. More...
 
HDST_API void SubmitComputeWork (HgiSubmitWaitType wait=HgiSubmitWaitTypeNoWait)
 Submits compute work queued in global compute cmds for GPU execution. More...
 
void SetNonUniformAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 Set the aggregation strategy for non uniform parameters (vertex, varying, facevarying) Takes ownership of the passed in strategy object. More...
 
void SetNonUniformImmutableAggregationStrategy (std::unique_ptr< 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 (std::unique_ptr< HdAggregationStrategy > &&strategy)
 Set the aggregation strategy for uniform (shader globals) Takes ownership of the passed in strategy object. More...
 
void SetShaderStorageAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 Set the aggregation strategy for SSBO (uniform primvars) Takes ownership of the passed in strategy object. More...
 
void SetSingleStorageAggregationStrategy (std::unique_ptr< HdAggregationStrategy > &&strategy)
 Set the aggregation strategy for single buffers (for nested instancer). More...
 
- Public Member Functions inherited from HdResourceRegistry
 HF_MALLOC_TAG_NEW ("new 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...
 

Protected Member Functions

void _Commit () override
 A hook for derived registries to perform additional resource commits. More...
 
void _GarbageCollect () override
 Hooks for derived registries to perform additional GC when GarbageCollect() or GarbageCollectBprims() is invoked. More...
 
- Protected Member Functions inherited from HdResourceRegistry
virtual HD_API void _GarbageCollectBprims ()
 

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
 Globally unique id for texture, see HdRenderIndex::GetTextureKey() for details. More...
 

Detailed Description

A central registry of all GPU resources.

Definition at line 113 of file resourceRegistry.h.

Member Function Documentation

void _Commit ( )
overrideprotectedvirtual

A hook for derived registries to perform additional resource commits.

Reimplemented from HdResourceRegistry.

void _GarbageCollect ( )
overrideprotectedvirtual

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

Reimplemented from HdResourceRegistry.

HDST_API void AddComputation ( HdBufferArrayRangeSharedPtr const &  range,
HdComputationSharedPtr const &  computation,
HdStComputeQueue const  queue 
)

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 AddSource ( HdBufferArrayRangeSharedPtr const &  range,
HdBufferSourceSharedPtr const &  source 
)

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

HDST_API void AddSource ( HdBufferSourceSharedPtr const &  source)

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

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


Resource update & computation queuing API

Append source data for given range to be committed later.

HDST_API HdBufferArrayRangeSharedPtr 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 HdStTextureHandleSharedPtr 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 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 void GarbageCollectBufferResources ( )

Remove any entries associated with expired misc buffers.

HDST_API void GarbageCollectDispatchBuffers ( )

Remove any entries associated with expired dispatch buffers.

HDST_API HgiBlitCmds* GetGlobalBlitCmds ( )

Returns the global hgi blit command queue for recording blitting work.

When using this global cmd instead of creating a new HgiBlitCmds we reduce the number of command buffers being created. The returned pointer should not be held onto by the client as it is only valid until the HgiBlitCmds has been submitted.

HDST_API HgiComputeCmds* GetGlobalComputeCmds ( )

Returns the global hgi compute cmd queue for recording compute work.

When using this global cmd instead of creating a new HgiComputeCmds we reduce the number of command buffers being created. The returned pointer should not be held onto by the client as it is only valid until the HgiComputeCmds has been submitted.

HDST_API Hgi* GetHgi ( )

Returns Hgi used to create/destroy GPU resources.

HDST_API VtDictionary 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.

HDST_API void InvalidateShaderRegistry ( )
overridevirtual

Invalidate any shaders registered with this registry.

Reimplemented from HdResourceRegistry.

HDST_API HdStBufferResourceSharedPtr RegisterBufferResource ( TfToken const &  role,
HdTupleType  tupleType 
)

Register a misc buffer resource.

Usually buffers are part of a buffer array (buffer aggregation) and are managed via buffer array APIs. RegisterBufferResource lets you create a standalone buffer that can be used for misc purposes (Eg. GPU frustum cull prim count read back).

HDST_API HdInstance<HgiComputePipelineSharedPtr> RegisterComputePipeline ( HdInstance< HgiComputePipelineSharedPtr >::ID  id)

Register a Hgi compute pipeline into the registry.

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


Dispatch & buffer API

Register a buffer allocated with count * commandNumUints * sizeof(uint32_t) 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<HioGlslfxSharedPtr> RegisterGLSLFXFile ( HdInstance< HioGlslfxSharedPtr >::ID  id)

Register a GLSLFX file.

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

Register a GLSL program into the program registry.

HDST_API HdInstance<HgiGraphicsPipelineSharedPtr> RegisterGraphicsPipeline ( HdInstance< HgiGraphicsPipelineSharedPtr >::ID  id)

Register a Hgi graphics pipeline into the 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 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<HgiResourceBindingsSharedPtr> RegisterResourceBindings ( HdInstance< HgiResourceBindingsSharedPtr >::ID  id)

Register a Hgi resource bindings into the registry.

HDST_API void ReloadResource ( TfToken const &  resourceType,
std::string const &  path 
)
overridevirtual

Generic method to inform RenderDelegate a resource needs to be reloaded.

This method can be used by the application to inform the renderDelegate that a resource, which may not have any prim representation in Hydra, needs to be reloaded. For example a texture found in a material network. The path can be absolute or relative. It should usually match the path found for textures during HdMaterial::Sync.

Reimplemented from HdResourceRegistry.

HDST_API void SetMemoryRequestForTextureType ( HdTextureType  textureType,
size_t  memoryRequest 
)

Sets how much memory a single texture can consume in bytes by texture type.

Only has an effect if non-zero and only applies to textures if no texture handle referencing the texture has a memory request.

void 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 474 of file resourceRegistry.h.

void 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 482 of file resourceRegistry.h.

void 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 496 of file resourceRegistry.h.

void 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 503 of file resourceRegistry.h.

void 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 489 of file resourceRegistry.h.

HDST_API void SubmitBlitWork ( HgiSubmitWaitType  wait = HgiSubmitWaitTypeNoWait)

Submits blit work queued in global blit cmds for GPU execution.

We can call this when we want to submit some work to the GPU. To stall the CPU and wait for the GPU to finish, 'wait' can be provided. To insert a barrier to ensure memory writes are visible after the barrier a HgiMemoryBarrier can be provided.

HDST_API void SubmitComputeWork ( HgiSubmitWaitType  wait = HgiSubmitWaitTypeNoWait)

Submits compute work queued in global compute cmds for GPU execution.

We can call this when we want to submit some work to the GPU. To stall the CPU and wait for the GPU to finish, 'wait' can be provided. To insert a barrier to ensure memory writes are visible after the barrier a HgiMemoryBarrier can be provided.

HDST_API HdBufferArrayRangeSharedPtr 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.

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: