HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resourceRegistry.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
8 #define PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/base/vt/dictionary.h"
12 
13 #include "pxr/imaging/hdSt/api.h"
15 #include "pxr/imaging/hdSt/enums.h"
16 
17 #include "pxr/imaging/hgi/hgi.h"
18 
24 
25 #include <tbb/concurrent_vector.h>
26 
27 #include <atomic>
28 #include <map>
29 #include <memory>
30 
31 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
32 #include <MaterialXCore/Library.h>
34  using ShaderPtr = std::shared_ptr<class Shader>;
36 #endif
37 
39 
40 using HdStComputationSharedPtr = std::shared_ptr<class HdStComputation>;
41 using HdStDispatchBufferSharedPtr = std::shared_ptr<class HdStDispatchBuffer>;
42 using HdStGLSLProgramSharedPtr = std::shared_ptr<class HdStGLSLProgram>;
43 using HioGlslfxSharedPtr = std::shared_ptr<class HioGlslfx>;
44 
46  std::shared_ptr<class HdSt_BasisCurvesTopology>;
47 
48 using HdStShaderCodePtr =
49  std::weak_ptr<class HdStShaderCode>;
51  std::shared_ptr<class HdSt_GeometricShader>;
53  std::shared_ptr<class HdStRenderPassShader>;
54 
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>;
73 
76 class HdStStagingBuffer;
77 
78 /// \enum HdStComputeQueue
79 ///
80 /// Determines the 'compute queue' a computation should be added into.
81 ///
82 /// We only perform synchronization between queues, not within one queue.
83 /// In OpenGL terms that means we insert memory barriers between computations
84 /// of two queues, but not between two computations in the same queue.
85 ///
86 /// A prim determines the role for each queue based on its local knowledge of
87 /// compute dependencies. Eg. HdStMesh knows computing normals should wait
88 /// until the primvar refinement computation has fnished. It can assign one
89 /// queue to primvar refinement and a following queue for normal computations.
90 ///
97 
99  std::vector<std::pair<HdStComputationSharedPtr, HdStComputeQueue>>;
100 
101 
102 /// \class HdStResourceRegistry
103 ///
104 /// A central registry of all GPU resources.
105 ///
107 {
108 public:
109  HF_MALLOC_TAG_NEW("new HdStResourceRegistry");
110 
111  HDST_API
112  explicit HdStResourceRegistry(Hgi* hgi);
113 
114  HDST_API
115  ~HdStResourceRegistry() override;
116 
117  HDST_API
118  void InvalidateShaderRegistry() override;
119 
120  HDST_API
121  void ReloadResource(TfToken const& resourceType,
122  std::string const& path) override;
123 
124  HDST_API
125  VtDictionary GetResourceAllocation() const override;
126 
127  /// Returns Hgi used to create/destroy GPU resources.
128  HDST_API
129  Hgi* GetHgi();
130 
131  /// ------------------------------------------------------------------------
132  /// Texture allocation API
133  /// ------------------------------------------------------------------------
134  ///
135 
136  /// Allocate texture handle (encapsulates texture and sampler
137  /// object, memory request and callback to shader).
138  ///
139  /// The actual allocation of the associated GPU texture and
140  /// sampler resources and loading of the texture file is delayed
141  /// until the commit phase.
142  HDST_API
144  /// Path to file and information to identify a texture if the
145  /// file is a container for several textures (e.g., OpenVDB
146  /// file containing several grids, movie file containing frames).
147  const HdStTextureIdentifier &textureId,
148  /// Texture type, e.g., uv, ptex, ...
149  HdStTextureType textureType,
150  /// Sampling parameters such as wrapS, ...
151  /// wrapS, wrapT, wrapR mode, min filer, mag filter
152  const HdSamplerParameters &samplerParams,
153  /// Memory request. The texture is down-sampled to meet the
154  /// target memory which is the maximum of all memory requests
155  /// associated to the texture.
156  /// If all memory requests are 0, no down-sampling will happen.
157  size_t memoryRequest,
158  /// After the texture is committed (or after it has been
159  /// changed) the given shader code can add additional buffer
160  /// sources and computations using the texture metadata with
161  /// AddResourcesFromTextures.
162  HdStShaderCodePtr const &shaderCode);
163 
164  /// Allocate texture object.
165  ///
166  /// The actual allocation of the associated GPU texture and
167  /// sampler resources and loading of the texture file is delayed
168  /// until the commit phase.
169  HDST_API
171  /// Path to file and information to identify a texture if the
172  /// file is a container for several textures (e.g., OpenVDB
173  /// file containing several grids, movie file containing frames).
174  const HdStTextureIdentifier &textureId,
175  /// Texture type, e.g., uv, ptex, ...
176  HdStTextureType textureType);
177 
178  /// Sets how much memory a single texture can consume in bytes by
179  /// texture type.
180  ///
181  /// Only has an effect if non-zero and only applies to textures if
182  /// no texture handle referencing the texture has a memory
183  /// request.
184  ///
185  HDST_API
187  HdStTextureType textureType,
188  size_t memoryRequest);
189 
190  /// ------------------------------------------------------------------------
191  /// BAR allocation API
192  /// ------------------------------------------------------------------------
193  ///
194  /// The Allocate* flavor of methods allocate a new BAR for the given buffer
195  /// specs using the chosen aggregation strategy.
196 
197  HDST_API
199  TfToken const &role,
200  HdBufferSpecVector const &bufferSpecs,
201  HdBufferArrayUsageHint usageHint);
202 
203  HDST_API
205  TfToken const &role,
206  HdBufferSpecVector const &bufferSpecs,
207  HdBufferArrayUsageHint usageHint);
208 
209  HDST_API
211  TfToken const &role,
212  HdBufferSpecVector const &bufferSpecs,
213  HdBufferArrayUsageHint usageHint);
214 
215  HDST_API
217  TfToken const &role,
218  HdBufferSpecVector const &bufferSpecs,
219  HdBufferArrayUsageHint usageHint);
220 
221  HDST_API
223  TfToken const &role,
224  HdBufferSpecVector const &bufferSpecs,
225  HdBufferArrayUsageHint usageHint);
226 
227  /// ------------------------------------------------------------------------
228  /// BAR allocation/migration/update API
229  /// ------------------------------------------------------------------------
230  ///
231  /// The Update* flavor of methods handle both allocation of a new BAR and
232  /// reallocation-migration based on the existing range, updated/added specs,
233  /// removed specs and usage hint. This allows client code to be less verbose
234  /// when a range's signature (specs) can change.
235  ///
236  /// If \p curRange is invalid, this is equivalent to calling Allocate*.
237  /// Otherwise, checks if \p curRange needs to be migrated to a new range
238  /// (based on \p updatedOrAddedSpecs and \p removedSpecs and \p usageHint).
239  /// If migration is necessary, allocate a new range and register necessary
240  /// migration computations and return the new range.
241  /// Otherwise, just return the same range.
242 
243  HDST_API
245  TfToken const &role,
246  HdBufferArrayRangeSharedPtr const& curRange,
247  HdBufferSpecVector const &updatedOrAddedSpecs,
248  HdBufferSpecVector const& removedSpecs,
249  HdBufferArrayUsageHint usageHint);
250 
251  HDST_API
253  TfToken const &role,
254  HdBufferArrayRangeSharedPtr const& curRange,
255  HdBufferSpecVector const &updatedOrAddedSpecs,
256  HdBufferSpecVector const& removedSpecs,
257  HdBufferArrayUsageHint usageHint);
258 
259  HDST_API
261  TfToken const &role,
262  HdBufferArrayRangeSharedPtr const& curRange,
263  HdBufferSpecVector const &updatedOrAddedSpecs,
264  HdBufferSpecVector const& removedSpecs,
265  HdBufferArrayUsageHint usageHint);
266 
267  HDST_API
269  TfToken const &role,
270  HdBufferArrayRangeSharedPtr const& curRange,
271  HdBufferSpecVector const &updatedOrAddedSpecs,
272  HdBufferSpecVector const& removedSpecs,
273  HdBufferArrayUsageHint usageHint);
274 
275  /// ------------------------------------------------------------------------
276  /// Resource update & computation queuing API
277  /// ------------------------------------------------------------------------
278 
279  /// Append source data for given range to be committed later.
280  HDST_API
283 
284  /// Append a source data for given range to be committed later.
285  HDST_API
286  void AddSource(HdBufferArrayRangeSharedPtr const &range,
288 
289  /// Append a source data just to be resolved (used for cpu computations).
290  HDST_API
291  void AddSource(HdBufferSourceSharedPtr const &source);
292 
293  /// Append a gpu computation into queue.
294  /// The parameter 'range' specifies the destination buffer range,
295  /// which has to be allocated by caller of this function.
296  ///
297  /// note: GPU computations will be executed in the order that
298  /// they are registered.
299  HDST_API
301  HdStComputationSharedPtr const &computation,
302  HdStComputeQueue const queue);
303 
304  /// ------------------------------------------------------------------------
305  /// Dispatch & buffer API
306  /// ------------------------------------------------------------------------
307 
308  /// Register a buffer allocated with \a count * \a commandNumUints *
309  /// sizeof(uint32_t) to be used as an indirect dispatch buffer.
310  HDST_API
312  TfToken const &role, int count, int commandNumUints);
313 
314  /// Register a misc buffer resource.
315  /// Usually buffers are part of a buffer array (buffer aggregation) and are
316  /// managed via buffer array APIs.
317  /// RegisterBufferResource lets you create a standalone buffer that can
318  /// be used for misc purposes (Eg. GPU frustum cull prim count read back).
319  HDST_API
321  TfToken const &role,
322  HdTupleType tupleType,
323  HgiBufferUsage bufferUsage,
324  std::string debugName = "");
325 
326  /// Remove any entries associated with expired dispatch buffers.
327  HDST_API
329 
330  /// Remove any entries associated with expired misc buffers.
331  HDST_API
333 
334  /// ------------------------------------------------------------------------
335  /// Instance Registries
336  /// ------------------------------------------------------------------------
337 
338  /// These registries implement sharing and deduplication of data based
339  /// on computed hash identifiers. Each returned HdInstance object retains
340  /// a shared pointer to a data instance. When an HdInstance is registered
341  /// for a previously unused ID, the data pointer will be null and it is
342  /// the caller's responsibility to set its value. The instance registries
343  /// are cleaned of unreferenced entries during garbage collection.
344  ///
345  /// Note: As entries can be registered from multiple threads, the returned
346  /// object holds a lock on the instance registry. This lock is held
347  /// until the returned HdInstance object is destroyed.
348 
349  /// Topology instancing
350  HDST_API
353 
354  HDST_API
358 
359  HDST_API
363 
364  /// Topology Index buffer array range instancing
365  /// Returns the HdInstance points to shared HdBufferArrayRange,
366  /// distinguished by given ID.
367  /// *Refer the comment on RegisterTopology for the same consideration.
368  HDST_API
372 
373  HDST_API
377 
378  /// Primvar array range instancing
379  /// Returns the HdInstance pointing to shared HdBufferArrayRange,
380  /// distinguished by given ID.
381  /// *Refer the comment on RegisterTopology for the same consideration.
382  HDST_API
386 
387  /// ExtComputation data array range instancing
388  /// Returns the HdInstance pointing to shared HdBufferArrayRange,
389  /// distinguished by given ID.
390  /// *Refer the comment on RegisterTopology for the same consideration.
391  HDST_API
395 
396  /// Register a geometric shader.
397  HDST_API
400 
401  /// Register a render pass shader.
402  HDST_API
405 
406  /// Register a GLSL program into the program registry.
407  HDST_API
410 
411  /// Register a GLSLFX file.
412  HDST_API
415 
416 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
417  /// Register MaterialX GLSLFX Shader.
418  HDST_API
420  RegisterMaterialXShader(HdInstance<MaterialX::ShaderPtr>::ID id);
421 #endif
422 
423  /// Register a Hgi resource bindings into the registry.
424  HDST_API
427 
428  /// Register a Hgi graphics pipeline into the registry.
429  HDST_API
432 
433  /// Register a Hgi compute pipeline into the registry.
434  HDST_API
437 
438  /// Finds a sub resource registry for the given identifier if it already
439  /// exists or creates one by invoking the provided factory function.
440  ///
441  /// A sub resource registry is simply another resource registry defined
442  /// externally but whose lifetime is tied to this HdStResourceRegistry and
443  /// can be retrieved via this function.
444  ///
445  /// Any sub resource registries will have their Commit functions invoked
446  /// when Commit is invoked on this instance, and their GarbageCollect
447  /// functions invoked when GarbageCollect is invoked on this instance.
448  HDST_API
451  const std::string& identifier,
452  const std::function<std::unique_ptr<HdResourceRegistry>()>& factory);
453 
454  /// Returns the global hgi blit command queue for recording blitting work.
455  /// When using this global cmd instead of creating a new HgiBlitCmds we
456  /// reduce the number of command buffers being created.
457  /// The returned pointer should not be held onto by the client as it is
458  /// only valid until the HgiBlitCmds has been submitted.
459  HDST_API
461 
462  /// Returns the global hgi compute cmd queue for recording compute work.
463  /// When using this global cmd instead of creating a new HgiComputeCmds we
464  /// reduce the number of command buffers being created.
465  /// The returned pointer should not be held onto by the client as it is
466  /// only valid until the HgiComputeCmds has been submitted.
467  HDST_API
470 
471  /// Submits blit work queued in global blit cmds for GPU execution.
472  /// We can call this when we want to submit some work to the GPU.
473  /// To stall the CPU and wait for the GPU to finish, 'wait' can be provided.
474  /// To insert a barrier to ensure memory writes are visible after the
475  /// barrier a HgiMemoryBarrier can be provided.
476  HDST_API
478 
479  /// Submits compute work queued in global compute cmds for GPU execution.
480  /// We can call this when we want to submit some work to the GPU.
481  /// To stall the CPU and wait for the GPU to finish, 'wait' can be provided.
482  /// To insert a barrier to ensure memory writes are visible after the
483  /// barrier a HgiMemoryBarrier can be provided.
484  HDST_API
486 
487  /// Returns the staging buffer used when committing data to the GPU.
488  HDST_API
490 
491 public:
492  //
493  // Unit test API
494  //
495 
496  /// Set the aggregation strategy for non uniform parameters
497  /// (vertex, varying, facevarying)
498  /// Takes ownership of the passed in strategy object.
500  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
501  _nonUniformAggregationStrategy = std::move(strategy);
502  }
503 
504  /// Set the aggregation strategy for non uniform immutable parameters
505  /// (vertex, varying, facevarying)
506  /// Takes ownership of the passed in strategy object.
508  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
509  _nonUniformImmutableAggregationStrategy = std::move(strategy);
510  }
511 
512  /// Set the aggregation strategy for uniform (shader globals)
513  /// Takes ownership of the passed in strategy object.
515  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
516  _uniformUboAggregationStrategy = std::move(strategy);
517  }
518 
519  /// Set the aggregation strategy for SSBO (uniform primvars)
520  /// Takes ownership of the passed in strategy object.
522  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
523  _uniformSsboAggregationStrategy = std::move(strategy);
524  }
525 
526  /// Set the aggregation strategy for single buffers (for nested instancer).
527  /// Takes ownership of the passed in strategy object.
529  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
530  _singleAggregationStrategy = std::move(strategy);
531  }
532 
533  /// Debug dump
534  HDST_API
535  friend std::ostream &operator <<(
536  std::ostream &out,
537  const HdStResourceRegistry& self);
538 
539 protected:
540  void _Commit() override;
541  void _GarbageCollect() override;
542 
543 private:
544  void _CommitTextures();
545  // Wrapper function for BAR allocation
546  HdBufferArrayRangeSharedPtr _AllocateBufferArrayRange(
547  HdStAggregationStrategy *strategy,
548  HdStBufferArrayRegistry &bufferArrayRegistry,
549  TfToken const &role,
550  HdBufferSpecVector const &bufferSpecs,
551  HdBufferArrayUsageHint usageHint);
552 
553  /// Wrapper function for BAR allocation/reallocation-migration.
554  HdBufferArrayRangeSharedPtr _UpdateBufferArrayRange(
555  HdStAggregationStrategy *strategy,
556  HdStBufferArrayRegistry &bufferArrayRegistry,
557  TfToken const &role,
558  HdBufferArrayRangeSharedPtr const& curRange,
559  HdBufferSpecVector const &updatedOrAddedSpecs,
560  HdBufferSpecVector const& removedSpecs,
561  HdBufferArrayUsageHint usageHint);
562 
563  // Tally resources by key into the given dictionary. Any additions should
564  // be cumulative with the existing key values.
565  void _TallyResourceAllocation(VtDictionary *result) const;
566 
567  // TODO: this is a transient structure. we'll revisit the BufferSource
568  // interface later.
569  struct _PendingSource {
570  _PendingSource(HdBufferArrayRangeSharedPtr const &range)
571  : range(range)
572  , sources()
573  {
574  }
575 
576  _PendingSource(HdBufferArrayRangeSharedPtr const &range,
577  HdBufferSourceSharedPtr const &source)
578  : range(range)
579  , sources(1, source)
580  {
581  }
582 
583  _PendingSource(HdBufferArrayRangeSharedPtr const &range,
585  : range(range)
586  , sources(std::move(sources))
587  {
588  }
589 
592  };
593 
594  Hgi* _hgi;
595 
596  typedef tbb::concurrent_vector<_PendingSource> _PendingSourceList;
597  _PendingSourceList _pendingSources;
598  std::atomic_size_t _numBufferSourcesToResolve;
599 
600  struct _PendingComputation{
601  _PendingComputation(HdBufferArrayRangeSharedPtr const &range,
602  HdStComputationSharedPtr const &computation)
603  : range(range), computation(computation) { }
605  HdStComputationSharedPtr computation;
606  };
607 
608  // If we need more 'compute queues' we can increase HdStComputeQueueCount.
609  // We could also consider tbb::concurrent_priority_queue if we want this
610  // to be dynamically scalable.
611  typedef tbb::concurrent_vector<_PendingComputation> _PendingComputationList;
612  _PendingComputationList _pendingComputations[HdStComputeQueueCount];
613 
614  // aggregated buffer array
615  HdStBufferArrayRegistry _nonUniformBufferArrayRegistry;
616  HdStBufferArrayRegistry _nonUniformImmutableBufferArrayRegistry;
617  HdStBufferArrayRegistry _uniformUboBufferArrayRegistry;
618  HdStBufferArrayRegistry _uniformSsboBufferArrayRegistry;
619  HdStBufferArrayRegistry _singleBufferArrayRegistry;
620 
621  // current aggregation strategies
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;
628 
629  typedef std::vector<HdStDispatchBufferSharedPtr>
630  _DispatchBufferRegistry;
631  _DispatchBufferRegistry _dispatchBufferRegistry;
632 
633  typedef std::vector<HdStBufferResourceSharedPtr>
634  _BufferResourceRegistry;
635  _BufferResourceRegistry _bufferResourceRegistry;
636 
637  // Register mesh topology.
639  _meshTopologyRegistry;
640 
641  // Register basisCurves topology.
643  _basisCurvesTopologyRegistry;
644 
645  // Register vertex adjacency.
647  _vertexAdjacencyBuilderRegistry;
648 
649  // Register topology index buffers.
651  _TopologyIndexRangeInstanceRegistry;
652  typedef tbb::concurrent_unordered_map< TfToken,
653  _TopologyIndexRangeInstanceRegistry,
655  _TopologyIndexRangeInstanceRegMap;
656 
657  _TopologyIndexRangeInstanceRegMap _meshTopologyIndexRangeRegistry;
658  _TopologyIndexRangeInstanceRegMap _basisCurvesTopologyIndexRangeRegistry;
659 
660  // Register shared primvar buffers.
662  _primvarRangeRegistry;
663 
664  // Register ext computation resource.
666  _extComputationDataRangeRegistry;
667 
668  // geometric shader registry
670  _geometricShaderRegistry;
671 
672  // render pass shader registry
674  _renderPassShaderRegistry;
675 
676  // glsl shader program registry
678  _glslProgramRegistry;
679 
680  // glslfx file registry
682  _glslfxFileRegistry;
683 
684 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
685  // MaterialX glslfx shader registry
686  HdInstanceRegistry<MaterialX::ShaderPtr> _materialXShaderRegistry;
687 #endif
688 
689  // texture handle registry
690  std::unique_ptr<class HdSt_TextureHandleRegistry> _textureHandleRegistry;
691 
692  // Hgi resource bindings registry
694  _resourceBindingsRegistry;
695 
696  // Hgi graphics pipeline registry
698  _graphicsPipelineRegistry;
699 
700  // Hgi compute pipeline registry
702  _computePipelineRegistry;
703 
704  using _SubResourceRegistryMap =
705  tbb::concurrent_unordered_map<std::string,
706  std::unique_ptr<HdResourceRegistry>>;
707  _SubResourceRegistryMap _subResourceRegistries;
708 
709  HgiBlitCmdsUniquePtr _blitCmds;
710  HgiComputeCmdsUniquePtr _computeCmds;
711 
712  std::unique_ptr<HdStStagingBuffer> _stagingBuffer;
713 };
714 
715 
717 
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)
GLenum GLint * range
Definition: glcorearb.h:1925
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
Definition: basisCurves.h:27
std::weak_ptr< class HdStShaderCode > HdStShaderCodePtr
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
HDST_API HdStTextureObjectSharedPtr AllocateTextureObject(const HdStTextureIdentifier &textureId, HdStTextureType textureType)
std::shared_ptr< class HdSt_GeometricShader > HdSt_GeometricShaderSharedPtr
Definition: drawItem.h:19
HDST_API void GarbageCollectBufferResources()
Remove any entries associated with expired misc buffers.
Functor to use for hash maps from tokens to other things.
Definition: token.h:149
std::vector< HdBufferSourceSharedPtr > HdBufferSourceSharedPtrVector
Definition: bufferSource.h:27
HF_MALLOC_TAG_NEW("new HdStResourceRegistry")
HDST_API HdBufferArrayRangeSharedPtr AllocateShaderStorageBufferArrayRange(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
**But if you need a result
Definition: thread.h:622
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.
HgiSubmitWaitType
Definition: enums.h:650
GLsizei GLenum * sources
Definition: glcorearb.h:2542
Definition: token.h:70
std::shared_ptr< class HdSt_MeshTopology > HdSt_MeshTopologySharedPtr
Definition: mesh.h:32
HDST_API HdBufferArrayRangeSharedPtr AllocateNonUniformBufferArrayRange(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
HgiComputeDispatch
Definition: enums.h:812
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
Definition: glcorearb.h:803
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
Definition: computation.h:24
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
Definition: thread.h:632
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
Definition: glcorearb.h:786
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.
HdStComputeQueue
std::shared_ptr< class HdStTextureObject > HdStTextureObjectSharedPtr
std::unique_ptr< class HgiComputeCmds > HgiComputeCmdsUniquePtr
Definition: computeCmds.h:19
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)
*tasks wait()
HDST_API HdBufferArrayRangeSharedPtr UpdateNonUniformBufferArrayRange(TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
Definition: hgi.h:93
HDST_API void ReloadResource(TfToken const &resourceType, std::string const &path) override
std::unique_ptr< class HgiBlitCmds > HgiBlitCmdsUniquePtr
Definition: blitCmds.h:28
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
Definition: path.h:1425
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.
HgiBits HgiBufferUsage
Definition: enums.h:315
std::shared_ptr< class HdStTextureHandle > HdStTextureHandleSharedPtr
#define HDST_API
Definition: api.h:23
HDST_API HdInstance< HdSt_BasisCurvesTopologySharedPtr > RegisterBasisCurvesTopology(HdInstance< HdSt_BasisCurvesTopologySharedPtr >::ID id)
uint32_t HdBufferArrayUsageHint
Definition: bufferArray.h:60
std::shared_ptr< class HioGlslfx > HioGlslfxSharedPtr
Definition: glslfxShader.h:17
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
HDST_API HdStDispatchBufferSharedPtr RegisterDispatchBuffer(TfToken const &role, int count, int commandNumUints)
std::shared_ptr< HdBufferArrayRange > HdBufferArrayRangeSharedPtr
Definition: bufferArray.h:27
void _GarbageCollect() override
HdStTextureType
Definition: enums.h:30
std::shared_ptr< class HdSt_VertexAdjacencyBuilder > HdSt_VertexAdjacencyBuilderSharedPtr
Definition: mesh.h:30
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:33
void SetNonUniformImmutableAggregationStrategy(std::unique_ptr< HdStAggregationStrategy > &&strategy)
HDST_API HgiBlitCmds * GetGlobalBlitCmds()
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
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
Definition: commandBuffer.h:30
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.
GLint GLsizei count
Definition: glcorearb.h:405