7 #ifndef PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
8 #define PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
25 #include <tbb/concurrent_vector.h>
31 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
34 using ShaderPtr = std::shared_ptr<class Shader>;
46 std::shared_ptr<class HdSt_BasisCurvesTopology>;
49 std::weak_ptr<class HdStShaderCode>;
51 std::shared_ptr<class HdSt_GeometricShader>;
53 std::shared_ptr<class HdStRenderPassShader>;
56 std::shared_ptr<class HdStTextureHandle>;
58 std::shared_ptr<class HdStTextureObject>;
60 std::shared_ptr<class HdStBufferResource>;
62 std::shared_ptr<class HdStResourceRegistry>;
64 std::shared_ptr<class HdSt_VertexAdjacencyBuilder>;
66 std::shared_ptr<class HdSt_MeshTopology>;
68 std::shared_ptr<HgiResourceBindingsHandle>;
70 std::shared_ptr<HgiGraphicsPipelineHandle>;
72 std::shared_ptr<HgiComputePipelineHandle>;
99 std::vector<std::pair<HdStComputationSharedPtr, HdStComputeQueue>>;
122 std::string
const&
path)
override;
157 size_t memoryRequest,
188 size_t memoryRequest);
324 std::string debugName =
"");
416 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
451 const std::string& identifier,
452 const std::function<std::unique_ptr<HdResourceRegistry>()>& factory);
500 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
501 _nonUniformAggregationStrategy = std::move(strategy);
508 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
509 _nonUniformImmutableAggregationStrategy = std::move(strategy);
515 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
516 _uniformUboAggregationStrategy = std::move(strategy);
522 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
523 _uniformSsboAggregationStrategy = std::move(strategy);
529 std::unique_ptr<HdStAggregationStrategy> &&strategy) {
530 _singleAggregationStrategy = std::move(strategy);
537 const HdStResourceRegistry&
self);
544 void _CommitTextures();
569 struct _PendingSource {
596 typedef tbb::concurrent_vector<_PendingSource> _PendingSourceList;
597 _PendingSourceList _pendingSources;
598 std::atomic_size_t _numBufferSourcesToResolve;
600 struct _PendingComputation{
603 : range(range), computation(computation) { }
611 typedef tbb::concurrent_vector<_PendingComputation> _PendingComputationList;
622 std::unique_ptr<HdStAggregationStrategy> _nonUniformAggregationStrategy;
623 std::unique_ptr<HdStAggregationStrategy>
624 _nonUniformImmutableAggregationStrategy;
625 std::unique_ptr<HdStAggregationStrategy> _uniformUboAggregationStrategy;
626 std::unique_ptr<HdStAggregationStrategy> _uniformSsboAggregationStrategy;
627 std::unique_ptr<HdStAggregationStrategy> _singleAggregationStrategy;
629 typedef std::vector<HdStDispatchBufferSharedPtr>
630 _DispatchBufferRegistry;
631 _DispatchBufferRegistry _dispatchBufferRegistry;
633 typedef std::vector<HdStBufferResourceSharedPtr>
634 _BufferResourceRegistry;
635 _BufferResourceRegistry _bufferResourceRegistry;
639 _meshTopologyRegistry;
643 _basisCurvesTopologyRegistry;
647 _vertexAdjacencyBuilderRegistry;
651 _TopologyIndexRangeInstanceRegistry;
652 typedef tbb::concurrent_unordered_map<
TfToken,
653 _TopologyIndexRangeInstanceRegistry,
655 _TopologyIndexRangeInstanceRegMap;
657 _TopologyIndexRangeInstanceRegMap _meshTopologyIndexRangeRegistry;
658 _TopologyIndexRangeInstanceRegMap _basisCurvesTopologyIndexRangeRegistry;
662 _primvarRangeRegistry;
666 _extComputationDataRangeRegistry;
670 _geometricShaderRegistry;
674 _renderPassShaderRegistry;
678 _glslProgramRegistry;
684 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
690 std::unique_ptr<class HdSt_TextureHandleRegistry> _textureHandleRegistry;
694 _resourceBindingsRegistry;
698 _graphicsPipelineRegistry;
702 _computePipelineRegistry;
704 using _SubResourceRegistryMap =
705 tbb::concurrent_unordered_map<std::string,
706 std::unique_ptr<HdResourceRegistry>>;
707 _SubResourceRegistryMap _subResourceRegistries;
712 std::unique_ptr<HdStStagingBuffer> _stagingBuffer;
718 #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 * path
HDST_API HdStTextureObjectSharedPtr AllocateTextureObject(const HdStTextureIdentifier &textureId, HdStTextureType textureType)
std::shared_ptr< class HdSt_GeometricShader > HdSt_GeometricShaderSharedPtr
HDST_API void GarbageCollectBufferResources()
Remove any entries associated with expired misc buffers.
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)
HDST_API void SetMemoryRequestForTextureType(HdStTextureType textureType, size_t memoryRequest)
std::shared_ptr< HgiComputePipelineHandle > HgiComputePipelineSharedPtr
HDST_API void GarbageCollectDispatchBuffers()
Remove any entries associated with expired dispatch buffers.
HDST_API HdInstance< HdStRenderPassShaderSharedPtr > RegisterRenderPassShader(HdInstance< HdStRenderPassShaderSharedPtr >::ID id)
Register a render pass shader.
*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.
HDST_API HdResourceRegistry * FindOrCreateSubResourceRegistry(const std::string &identifier, const std::function< std::unique_ptr< HdResourceRegistry >()> &factory)
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
std::shared_ptr< class HdStRenderPassShader > HdStRenderPassShaderSharedPtr
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 HdInstance< HdSt_BasisCurvesTopologySharedPtr > RegisterBasisCurvesTopology(HdInstance< HdSt_BasisCurvesTopologySharedPtr >::ID id)
uint32_t HdBufferArrayUsageHint
std::shared_ptr< class HioGlslfx > HioGlslfxSharedPtr
#define PXR_NAMESPACE_CLOSE_SCOPE
HDST_API HdStDispatchBufferSharedPtr RegisterDispatchBuffer(TfToken const &role, int count, int commandNumUints)
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 HdStTextureHandleSharedPtr AllocateTextureHandle(const HdStTextureIdentifier &textureId, HdStTextureType textureType, const HdSamplerParameters &samplerParams, size_t memoryRequest, HdStShaderCodePtr const &shaderCode)
HDST_API friend std::ostream & operator<<(std::ostream &out, const HdStResourceRegistry &self)
Debug dump.
HDST_API HdStBufferResourceSharedPtr RegisterBufferResource(TfToken const &role, HdTupleType tupleType, HgiBufferUsage bufferUsage, std::string debugName="")
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.