24 #ifndef PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
25 #define PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
42 #include <tbb/concurrent_vector.h>
48 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
51 using ShaderPtr = std::shared_ptr<class Shader>;
63 std::shared_ptr<class HdSt_BasisCurvesTopology>;
66 std::weak_ptr<class HdStShaderCode>;
68 std::shared_ptr<class HdSt_GeometricShader>;
71 std::shared_ptr<class HdStTextureHandle>;
73 std::shared_ptr<class HdStTextureObject>;
75 std::shared_ptr<class HdStBufferResource>;
77 std::shared_ptr<class HdStResourceRegistry>;
79 std::shared_ptr<class HdSt_VertexAdjacencyBuilder>;
81 std::shared_ptr<class HdSt_MeshTopology>;
83 std::shared_ptr<HgiResourceBindingsHandle>;
85 std::shared_ptr<HgiGraphicsPipelineHandle>;
87 std::shared_ptr<HgiComputePipelineHandle>;
114 std::vector<std::pair<HdStComputationSharedPtr, HdStComputeQueue>>;
172 size_t memoryRequest,
203 size_t memoryRequest);
425 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
493 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
494 _nonUniformAggregationStrategy = std::move(strategy);
501 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
502 _nonUniformImmutableAggregationStrategy = std::move(strategy);
508 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
509 _uniformUboAggregationStrategy = std::move(strategy);
515 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
516 _uniformSsboAggregationStrategy = std::move(strategy);
522 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
523 _singleAggregationStrategy = std::move(strategy);
530 const HdStResourceRegistry&
self);
537 void _CommitTextures();
562 struct _PendingSource {
589 typedef tbb::concurrent_vector<_PendingSource> _PendingSourceList;
590 _PendingSourceList _pendingSources;
591 std::atomic_size_t _numBufferSourcesToResolve;
593 struct _PendingComputation{
596 : range(range), computation(computation) { }
604 typedef tbb::concurrent_vector<_PendingComputation> _PendingComputationList;
615 std::unique_ptr<HdStAggregationStrategy> _nonUniformAggregationStrategy;
616 std::unique_ptr<HdStAggregationStrategy>
617 _nonUniformImmutableAggregationStrategy;
618 std::unique_ptr<HdStAggregationStrategy> _uniformUboAggregationStrategy;
619 std::unique_ptr<HdStAggregationStrategy> _uniformSsboAggregationStrategy;
620 std::unique_ptr<HdStAggregationStrategy> _singleAggregationStrategy;
622 typedef std::vector<HdStDispatchBufferSharedPtr>
623 _DispatchBufferRegistry;
624 _DispatchBufferRegistry _dispatchBufferRegistry;
626 typedef std::vector<HdStBufferResourceSharedPtr>
627 _BufferResourceRegistry;
628 _BufferResourceRegistry _bufferResourceRegistry;
632 _meshTopologyRegistry;
636 _basisCurvesTopologyRegistry;
640 _vertexAdjacencyBuilderRegistry;
644 _TopologyIndexRangeInstanceRegistry;
645 typedef tbb::concurrent_unordered_map<
TfToken,
646 _TopologyIndexRangeInstanceRegistry,
648 _TopologyIndexRangeInstanceRegMap;
650 _TopologyIndexRangeInstanceRegMap _meshTopologyIndexRangeRegistry;
651 _TopologyIndexRangeInstanceRegMap _basisCurvesTopologyIndexRangeRegistry;
655 _primvarRangeRegistry;
659 _extComputationDataRangeRegistry;
663 _geometricShaderRegistry;
667 _glslProgramRegistry;
673 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
679 std::unique_ptr<class HdSt_TextureHandleRegistry> _textureHandleRegistry;
683 _resourceBindingsRegistry;
687 _graphicsPipelineRegistry;
691 _computePipelineRegistry;
696 std::unique_ptr<HdStStagingBuffer> _stagingBuffer;
702 #endif //PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
HDST_API HdStStagingBuffer * GetStagingBuffer()
Returns the staging buffer used when committing data to the GPU.
std::shared_ptr< class HdStDispatchBuffer > HdStDispatchBufferSharedPtr
void SetUniformAggregationStrategy(std::unique_ptr< HdStAggregationStrategy > &&strategy)
HDST_API HdBufferArrayRangeSharedPtr UpdateUniformBufferArrayRange(TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
HDST_API HdInstance< HdSt_MeshTopologySharedPtr > RegisterMeshTopology(HdInstance< HdSt_MeshTopologySharedPtr >::ID id)
Topology instancing.
HDST_API HdInstance< HgiResourceBindingsSharedPtr > RegisterResourceBindings(HdInstance< HgiResourceBindingsSharedPtr >::ID id)
Register a Hgi resource bindings into the registry.
std::shared_ptr< class HdSt_BasisCurvesTopology > HdSt_BasisCurvesTopologySharedPtr
std::weak_ptr< class HdStShaderCode > HdStShaderCodePtr
#define MATERIALX_NAMESPACE_BEGIN
GLsizei const GLchar *const * string
GLsizei const GLchar *const * path
std::shared_ptr< class HdSt_GeometricShader > HdSt_GeometricShaderSharedPtr
HDST_API void GarbageCollectBufferResources()
Remove any entries associated with expired misc buffers.
HDST_API void SetMemoryRequestForTextureType(HdTextureType textureType, size_t memoryRequest)
Functor to use for hash maps from tokens to other things.
std::vector< HdBufferSourceSharedPtr > HdBufferSourceSharedPtrVector
HF_MALLOC_TAG_NEW("new HdStResourceRegistry")
HDST_API HdBufferArrayRangeSharedPtr AllocateShaderStorageBufferArrayRange(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
**But if you need a result
void SetSingleStorageAggregationStrategy(std::unique_ptr< HdStAggregationStrategy > &&strategy)
HDST_API HdInstance< HdBufferArrayRangeSharedPtr > RegisterExtComputationDataRange(HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
HDST_API HdInstance< HdBufferArrayRangeSharedPtr > RegisterPrimvarRange(HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
HDST_API HdInstance< HdSt_VertexAdjacencyBuilderSharedPtr > RegisterVertexAdjacencyBuilder(HdInstance< HdSt_VertexAdjacencyBuilderSharedPtr >::ID id)
HDST_API HdInstance< HdSt_GeometricShaderSharedPtr > RegisterGeometricShader(HdInstance< HdSt_GeometricShaderSharedPtr >::ID id)
Register a geometric shader.
std::shared_ptr< class HdSt_MeshTopology > HdSt_MeshTopologySharedPtr
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 HdInstance< HgiGraphicsPipelineSharedPtr > RegisterGraphicsPipeline(HdInstance< HgiGraphicsPipelineSharedPtr >::ID id)
Register a Hgi graphics pipeline into the registry.
std::shared_ptr< HgiGraphicsPipelineHandle > HgiGraphicsPipelineSharedPtr
HDST_API void AddComputation(HdBufferArrayRangeSharedPtr const &range, HdStComputationSharedPtr const &computation, HdStComputeQueue const queue)
void _Commit() override
A hook for derived registries to perform additional resource commits.
std::shared_ptr< HgiResourceBindingsHandle > HgiResourceBindingsSharedPtr
GLsizei GLsizei GLchar * source
HDST_API Hgi * GetHgi()
Returns Hgi used to create/destroy GPU resources.
HDST_API HdBufferArrayRangeSharedPtr UpdateNonUniformImmutableBufferArrayRange(TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
std::shared_ptr< class HdStComputation > HdStComputationSharedPtr
HDST_API HdBufferArrayRangeSharedPtr AllocateSingleBufferArrayRange(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
std::shared_ptr< HgiComputePipelineHandle > HgiComputePipelineSharedPtr
HDST_API void GarbageCollectDispatchBuffers()
Remove any entries associated with expired dispatch buffers.
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the queue
HDST_API void AddSources(HdBufferArrayRangeSharedPtr const &range, HdBufferSourceSharedPtrVector &&sources)
Append source data for given range to be committed later.
GLuint const GLchar * name
HDST_API ~HdStResourceRegistry() override
std::vector< struct HdBufferSpec > HdBufferSpecVector
HDST_API void SubmitComputeWork(HgiSubmitWaitType wait=HgiSubmitWaitTypeNoWait)
HDST_API HdInstance< HioGlslfxSharedPtr > RegisterGLSLFXFile(HdInstance< HioGlslfxSharedPtr >::ID id)
Register a GLSLFX file.
std::shared_ptr< class HdStTextureObject > HdStTextureObjectSharedPtr
std::unique_ptr< class HgiComputeCmds > HgiComputeCmdsUniquePtr
HDST_API HdInstance< HdBufferArrayRangeSharedPtr > RegisterMeshIndexRange(HdInstance< HdBufferArrayRangeSharedPtr >::ID id, TfToken const &name)
std::shared_ptr< class HdStBufferResource > HdStBufferResourceSharedPtr
std::shared_ptr< class HdStGLSLProgram > HdStGLSLProgramSharedPtr
HDST_API void SubmitBlitWork(HgiSubmitWaitType wait=HgiSubmitWaitTypeNoWait)
HDST_API HdBufferArrayRangeSharedPtr UpdateNonUniformBufferArrayRange(TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
HDST_API void ReloadResource(TfToken const &resourceType, std::string const &path) override
std::unique_ptr< class HgiBlitCmds > HgiBlitCmdsUniquePtr
HDST_API VtDictionary GetResourceAllocation() const override
HDST_API HgiComputeCmds * GetGlobalComputeCmds(HgiComputeDispatch dispatchMethod=HgiComputeDispatchSerial)
HDST_API void InvalidateShaderRegistry() override
Invalidate any shaders registered with this registry.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
HDST_API HdBufferArrayRangeSharedPtr UpdateShaderStorageBufferArrayRange(TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
std::vector< std::pair< HdStComputationSharedPtr, HdStComputeQueue >> HdStComputationComputeQueuePairVector
HDST_API void AddSource(HdBufferArrayRangeSharedPtr const &range, HdBufferSourceSharedPtr const &source)
Append a source data for given range to be committed later.
std::shared_ptr< class HdStTextureHandle > HdStTextureHandleSharedPtr
HDST_API HdStBufferResourceSharedPtr RegisterBufferResource(TfToken const &role, HdTupleType tupleType, HgiBufferUsage bufferUsage)
HDST_API HdInstance< HdSt_BasisCurvesTopologySharedPtr > RegisterBasisCurvesTopology(HdInstance< HdSt_BasisCurvesTopologySharedPtr >::ID id)
std::shared_ptr< class HioGlslfx > HioGlslfxSharedPtr
#define PXR_NAMESPACE_CLOSE_SCOPE
HDST_API HdStDispatchBufferSharedPtr RegisterDispatchBuffer(TfToken const &role, int count, int commandNumUints)
HDST_API HdStTextureHandleSharedPtr AllocateTextureHandle(const HdStTextureIdentifier &textureId, HdTextureType textureType, const HdSamplerParameters &samplerParams, size_t memoryRequest, HdStShaderCodePtr const &shaderCode)
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
void _GarbageCollect() override
std::shared_ptr< class HdSt_VertexAdjacencyBuilder > HdSt_VertexAdjacencyBuilderSharedPtr
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
void SetNonUniformImmutableAggregationStrategy(std::unique_ptr< HdStAggregationStrategy > &&strategy)
HDST_API HgiBlitCmds * GetGlobalBlitCmds()
#define MATERIALX_NAMESPACE_END
HDST_API HdInstance< HgiComputePipelineSharedPtr > RegisterComputePipeline(HdInstance< HgiComputePipelineSharedPtr >::ID id)
Register a Hgi compute pipeline into the registry.
HDST_API friend std::ostream & operator<<(std::ostream &out, const HdStResourceRegistry &self)
Debug dump.
HDST_API HdStTextureObjectSharedPtr AllocateTextureObject(const HdStTextureIdentifier &textureId, HdTextureType textureType)
HDST_API HdInstance< HdBufferArrayRangeSharedPtr > RegisterBasisCurvesIndexRange(HdInstance< HdBufferArrayRangeSharedPtr >::ID id, TfToken const &name)
std::shared_ptr< class HdBufferSource > HdBufferSourceSharedPtr
void SetShaderStorageAggregationStrategy(std::unique_ptr< HdStAggregationStrategy > &&strategy)
std::shared_ptr< class HdStResourceRegistry > HdStResourceRegistrySharedPtr
HDST_API HdStResourceRegistry(Hgi *hgi)
HDST_API HdBufferArrayRangeSharedPtr AllocateUniformBufferArrayRange(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
void SetNonUniformAggregationStrategy(std::unique_ptr< HdStAggregationStrategy > &&strategy)
HDST_API HdInstance< HdStGLSLProgramSharedPtr > RegisterGLSLProgram(HdInstance< HdStGLSLProgramSharedPtr >::ID id)
Register a GLSL program into the program registry.