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"
17 
18 #include "pxr/imaging/hgi/hgi.h"
19 
25 
26 #include <tbb/concurrent_vector.h>
27 
28 #include <atomic>
29 #include <map>
30 #include <memory>
31 
32 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
33 #include <MaterialXCore/Library.h>
35  using ShaderPtr = std::shared_ptr<class Shader>;
37 #endif
38 
40 
41 using HdStComputationSharedPtr = std::shared_ptr<class HdStComputation>;
42 using HdStDispatchBufferSharedPtr = std::shared_ptr<class HdStDispatchBuffer>;
43 using HdStGLSLProgramSharedPtr = std::shared_ptr<class HdStGLSLProgram>;
44 using HioGlslfxSharedPtr = std::shared_ptr<class HioGlslfx>;
45 
47  std::shared_ptr<class HdSt_BasisCurvesTopology>;
48 
49 using HdStShaderCodePtr =
50  std::weak_ptr<class HdStShaderCode>;
52  std::shared_ptr<class HdSt_GeometricShader>;
54  std::shared_ptr<class HdStRenderPassShader>;
55 
57  std::shared_ptr<class HdStTextureHandle>;
59  std::shared_ptr<class HdStTextureObject>;
61  std::shared_ptr<class HdStBufferResource>;
63  std::shared_ptr<class HdStResourceRegistry>;
65  std::shared_ptr<class HdSt_VertexAdjacencyBuilder>;
67  std::shared_ptr<class HdSt_MeshTopology>;
69  std::shared_ptr<HgiResourceBindingsHandle>;
71  std::shared_ptr<HgiGraphicsPipelineHandle>;
73  std::shared_ptr<HgiComputePipelineHandle>;
74 
77 class HdStStagingBuffer;
78 
79 /// \enum HdStComputeQueue
80 ///
81 /// Determines the 'compute queue' a computation should be added into.
82 ///
83 /// We only perform synchronization between queues, not within one queue.
84 /// In OpenGL terms that means we insert memory barriers between computations
85 /// of two queues, but not between two computations in the same queue.
86 ///
87 /// A prim determines the role for each queue based on its local knowledge of
88 /// compute dependencies. Eg. HdStMesh knows computing normals should wait
89 /// until the primvar refinement computation has fnished. It can assign one
90 /// queue to primvar refinement and a following queue for normal computations.
91 ///
98 
100  std::vector<std::pair<HdStComputationSharedPtr, HdStComputeQueue>>;
101 
102 
103 /// \class HdStResourceRegistry
104 ///
105 /// A central registry of all GPU resources.
106 ///
108 {
109 public:
110  HF_MALLOC_TAG_NEW("new HdStResourceRegistry");
111 
112  HDST_API
113  explicit HdStResourceRegistry(Hgi* hgi);
114 
115  HDST_API
116  ~HdStResourceRegistry() override;
117 
118  HDST_API
119  void InvalidateShaderRegistry() override;
120 
121  HDST_API
122  void ReloadResource(TfToken const& resourceType,
123  std::string const& path) override;
124 
125  HDST_API
126  VtDictionary GetResourceAllocation() const override;
127 
128  /// Returns Hgi used to create/destroy GPU resources.
129  HDST_API
130  Hgi* GetHgi();
131 
132  /// ------------------------------------------------------------------------
133  /// Texture allocation API
134  /// ------------------------------------------------------------------------
135  ///
136 
137  /// Allocate texture handle (encapsulates texture and sampler
138  /// object, memory request and callback to shader).
139  ///
140  /// The actual allocation of the associated GPU texture and
141  /// sampler resources and loading of the texture file is delayed
142  /// until the commit phase.
143  HDST_API
145  /// Path to file and information to identify a texture if the
146  /// file is a container for several textures (e.g., OpenVDB
147  /// file containing several grids, movie file containing frames).
148  const HdStTextureIdentifier &textureId,
149  /// Texture type, e.g., uv, ptex, ...
150  HdStTextureType textureType,
151  /// Sampling parameters such as wrapS, ...
152  /// wrapS, wrapT, wrapR mode, min filer, mag filter
153  const HdSamplerParameters &samplerParams,
154  /// Memory request. The texture is down-sampled to meet the
155  /// target memory which is the maximum of all memory requests
156  /// associated to the texture.
157  /// If all memory requests are 0, no down-sampling will happen.
158  size_t memoryRequest,
159  /// After the texture is committed (or after it has been
160  /// changed) the given shader code can add additional buffer
161  /// sources and computations using the texture metadata with
162  /// AddResourcesFromTextures.
163  HdStShaderCodePtr const &shaderCode);
164 
165  /// Allocate texture object.
166  ///
167  /// The actual allocation of the associated GPU texture and
168  /// sampler resources and loading of the texture file is delayed
169  /// until the commit phase.
170  HDST_API
172  /// Path to file and information to identify a texture if the
173  /// file is a container for several textures (e.g., OpenVDB
174  /// file containing several grids, movie file containing frames).
175  const HdStTextureIdentifier &textureId,
176  /// Texture type, e.g., uv, ptex, ...
177  HdStTextureType textureType);
178 
179  /// Allocate a RenderBuffer to be used only for this Render Graph's
180  /// execution
181  ///
182  /// Useful for instances where client code wants a RenderBuffer only
183  /// temporarily and doesn't care about its contents before or after
184  /// Ex: intermediary RenderBuffers or per Render Graph shadow maps
185  HDST_API
187  const SdfPath& graphPath,
188  HdFormat fmt,
189  GfVec2i dims,
190  bool multiSampled,
191  bool depth);
192 
193  /// Sets how much memory a single texture can consume in bytes by
194  /// texture type.
195  ///
196  /// Only has an effect if non-zero and only applies to textures if
197  /// no texture handle referencing the texture has a memory
198  /// request.
199  ///
200  HDST_API
202  HdStTextureType textureType,
203  size_t memoryRequest);
204 
205  /// ------------------------------------------------------------------------
206  /// BAR allocation API
207  /// ------------------------------------------------------------------------
208  ///
209  /// The Allocate* flavor of methods allocate a new BAR for the given buffer
210  /// specs using the chosen aggregation strategy.
211 
212  HDST_API
214  TfToken const &role,
215  HdBufferSpecVector const &bufferSpecs,
216  HdBufferArrayUsageHint usageHint);
217 
218  HDST_API
220  TfToken const &role,
221  HdBufferSpecVector const &bufferSpecs,
222  HdBufferArrayUsageHint usageHint);
223 
224  HDST_API
226  TfToken const &role,
227  HdBufferSpecVector const &bufferSpecs,
228  HdBufferArrayUsageHint usageHint);
229 
230  HDST_API
232  TfToken const &role,
233  HdBufferSpecVector const &bufferSpecs,
234  HdBufferArrayUsageHint usageHint);
235 
236  HDST_API
238  TfToken const &role,
239  HdBufferSpecVector const &bufferSpecs,
240  HdBufferArrayUsageHint usageHint);
241 
242  /// ------------------------------------------------------------------------
243  /// BAR allocation/migration/update API
244  /// ------------------------------------------------------------------------
245  ///
246  /// The Update* flavor of methods handle both allocation of a new BAR and
247  /// reallocation-migration based on the existing range, updated/added specs,
248  /// removed specs and usage hint. This allows client code to be less verbose
249  /// when a range's signature (specs) can change.
250  ///
251  /// If \p curRange is invalid, this is equivalent to calling Allocate*.
252  /// Otherwise, checks if \p curRange needs to be migrated to a new range
253  /// (based on \p updatedOrAddedSpecs and \p removedSpecs and \p usageHint).
254  /// If migration is necessary, allocate a new range and register necessary
255  /// migration computations and return the new range.
256  /// Otherwise, just return the same range.
257 
258  HDST_API
260  TfToken const &role,
261  HdBufferArrayRangeSharedPtr const& curRange,
262  HdBufferSpecVector const &updatedOrAddedSpecs,
263  HdBufferSpecVector const& removedSpecs,
264  HdBufferArrayUsageHint usageHint);
265 
266  HDST_API
268  TfToken const &role,
269  HdBufferArrayRangeSharedPtr const& curRange,
270  HdBufferSpecVector const &updatedOrAddedSpecs,
271  HdBufferSpecVector const& removedSpecs,
272  HdBufferArrayUsageHint usageHint);
273 
274  HDST_API
276  TfToken const &role,
277  HdBufferArrayRangeSharedPtr const& curRange,
278  HdBufferSpecVector const &updatedOrAddedSpecs,
279  HdBufferSpecVector const& removedSpecs,
280  HdBufferArrayUsageHint usageHint);
281 
282  HDST_API
284  TfToken const &role,
285  HdBufferArrayRangeSharedPtr const& curRange,
286  HdBufferSpecVector const &updatedOrAddedSpecs,
287  HdBufferSpecVector const& removedSpecs,
288  HdBufferArrayUsageHint usageHint);
289 
290  /// ------------------------------------------------------------------------
291  /// Resource update & computation queuing API
292  /// ------------------------------------------------------------------------
293 
294  /// Append source data for given range to be committed later.
295  HDST_API
298 
299  /// Append a source data for given range to be committed later.
300  HDST_API
301  void AddSource(HdBufferArrayRangeSharedPtr const &range,
303 
304  /// Append a source data just to be resolved (used for cpu computations).
305  HDST_API
306  void AddSource(HdBufferSourceSharedPtr const &source);
307 
308  /// Append a gpu computation into queue.
309  /// The parameter 'range' specifies the destination buffer range,
310  /// which has to be allocated by caller of this function.
311  ///
312  /// note: GPU computations will be executed in the order that
313  /// they are registered.
314  HDST_API
316  HdStComputationSharedPtr const &computation,
317  HdStComputeQueue const queue);
318 
319  /// ------------------------------------------------------------------------
320  /// Dispatch & buffer API
321  /// ------------------------------------------------------------------------
322 
323  /// Register a buffer allocated with \a count * \a commandNumUints *
324  /// sizeof(uint32_t) to be used as an indirect dispatch buffer.
325  HDST_API
327  TfToken const &role, int count, int commandNumUints);
328 
329  /// Register a misc buffer resource.
330  /// Usually buffers are part of a buffer array (buffer aggregation) and are
331  /// managed via buffer array APIs.
332  /// RegisterBufferResource lets you create a standalone buffer that can
333  /// be used for misc purposes (Eg. GPU frustum cull prim count read back).
334  HDST_API
336  TfToken const &role,
337  HdTupleType tupleType,
338  HgiBufferUsage bufferUsage,
339  std::string debugName = "");
340 
341  /// Remove any entries associated with expired dispatch buffers.
342  HDST_API
344 
345  /// Remove any entries associated with expired misc buffers.
346  HDST_API
348 
349  /// ------------------------------------------------------------------------
350  /// Instance Registries
351  /// ------------------------------------------------------------------------
352 
353  /// These registries implement sharing and deduplication of data based
354  /// on computed hash identifiers. Each returned HdInstance object retains
355  /// a shared pointer to a data instance. When an HdInstance is registered
356  /// for a previously unused ID, the data pointer will be null and it is
357  /// the caller's responsibility to set its value. The instance registries
358  /// are cleaned of unreferenced entries during garbage collection.
359  ///
360  /// Note: As entries can be registered from multiple threads, the returned
361  /// object holds a lock on the instance registry. This lock is held
362  /// until the returned HdInstance object is destroyed.
363 
364  /// Topology instancing
365  HDST_API
368 
369  HDST_API
373 
374  HDST_API
378 
379  /// Topology Index buffer array range instancing
380  /// Returns the HdInstance points to shared HdBufferArrayRange,
381  /// distinguished by given ID.
382  /// *Refer the comment on RegisterTopology for the same consideration.
383  HDST_API
387 
388  HDST_API
392 
393  /// Primvar array range instancing
394  /// Returns the HdInstance pointing to shared HdBufferArrayRange,
395  /// distinguished by given ID.
396  /// *Refer the comment on RegisterTopology for the same consideration.
397  HDST_API
401 
402  /// ExtComputation data array range instancing
403  /// Returns the HdInstance pointing to shared HdBufferArrayRange,
404  /// distinguished by given ID.
405  /// *Refer the comment on RegisterTopology for the same consideration.
406  HDST_API
410 
411  /// Register a geometric shader.
412  HDST_API
415 
416  /// Register a render pass shader.
417  HDST_API
420 
421  /// Register a GLSL program into the program registry.
422  HDST_API
425 
426  /// Register a GLSLFX file.
427  HDST_API
430 
431 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
432  /// Register MaterialX GLSLFX Shader.
433  HDST_API
435  RegisterMaterialXShader(HdInstance<MaterialX::ShaderPtr>::ID id);
436 #endif
437 
438  /// Register a Hgi resource bindings into the registry.
439  HDST_API
442 
443  /// Register a Hgi graphics pipeline into the registry.
444  HDST_API
447 
448  /// Register a Hgi compute pipeline into the registry.
449  HDST_API
452 
453  /// Finds a sub resource registry for the given identifier if it already
454  /// exists or creates one by invoking the provided factory function.
455  ///
456  /// A sub resource registry is simply another resource registry defined
457  /// externally but whose lifetime is tied to this HdStResourceRegistry and
458  /// can be retrieved via this function.
459  ///
460  /// Any sub resource registries will have their Commit functions invoked
461  /// when Commit is invoked on this instance, and their GarbageCollect
462  /// functions invoked when GarbageCollect is invoked on this instance.
463  HDST_API
466  const std::string& identifier,
467  const std::function<std::unique_ptr<HdResourceRegistry>()>& factory);
468 
469  /// Returns the global hgi blit command queue for recording blitting work.
470  /// When using this global cmd instead of creating a new HgiBlitCmds we
471  /// reduce the number of command buffers being created.
472  /// The returned pointer should not be held onto by the client as it is
473  /// only valid until the HgiBlitCmds has been submitted.
474  HDST_API
476 
477  /// Returns the global hgi compute cmd queue for recording compute work.
478  /// When using this global cmd instead of creating a new HgiComputeCmds we
479  /// reduce the number of command buffers being created.
480  /// The returned pointer should not be held onto by the client as it is
481  /// only valid until the HgiComputeCmds has been submitted.
482  HDST_API
485 
486  /// Submits blit work queued in global blit cmds for GPU execution.
487  /// We can call this when we want to submit some work to the GPU.
488  /// To stall the CPU and wait for the GPU to finish, 'wait' can be provided.
489  /// To insert a barrier to ensure memory writes are visible after the
490  /// barrier a HgiMemoryBarrier can be provided.
491  HDST_API
493 
494  /// Submits compute work queued in global compute cmds for GPU execution.
495  /// We can call this when we want to submit some work to the GPU.
496  /// To stall the CPU and wait for the GPU to finish, 'wait' can be provided.
497  /// To insert a barrier to ensure memory writes are visible after the
498  /// barrier a HgiMemoryBarrier can be provided.
499  HDST_API
501 
502  /// Returns the staging buffer used when committing data to the GPU.
503  HDST_API
505 
506 public:
507  //
508  // Unit test API
509  //
510 
511  /// Set the aggregation strategy for non uniform parameters
512  /// (vertex, varying, facevarying)
513  /// Takes ownership of the passed in strategy object.
515  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
516  _nonUniformAggregationStrategy = std::move(strategy);
517  }
518 
519  /// Set the aggregation strategy for non uniform immutable parameters
520  /// (vertex, varying, facevarying)
521  /// Takes ownership of the passed in strategy object.
523  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
524  _nonUniformImmutableAggregationStrategy = std::move(strategy);
525  }
526 
527  /// Set the aggregation strategy for uniform (shader globals)
528  /// Takes ownership of the passed in strategy object.
530  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
531  _uniformUboAggregationStrategy = std::move(strategy);
532  }
533 
534  /// Set the aggregation strategy for SSBO (uniform primvars)
535  /// Takes ownership of the passed in strategy object.
537  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
538  _uniformSsboAggregationStrategy = std::move(strategy);
539  }
540 
541  /// Set the aggregation strategy for single buffers (for nested instancer).
542  /// Takes ownership of the passed in strategy object.
544  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
545  _singleAggregationStrategy = std::move(strategy);
546  }
547 
548  /// Debug dump
549  HDST_API
550  friend std::ostream &operator <<(
551  std::ostream &out,
552  const HdStResourceRegistry& self);
553 
554 protected:
555  void _Commit() override;
556  void _GarbageCollect() override;
557 
558 private:
559  void _CommitTextures();
560  // Wrapper function for BAR allocation
561  HdBufferArrayRangeSharedPtr _AllocateBufferArrayRange(
562  HdStAggregationStrategy *strategy,
563  HdStBufferArrayRegistry &bufferArrayRegistry,
564  TfToken const &role,
565  HdBufferSpecVector const &bufferSpecs,
566  HdBufferArrayUsageHint usageHint);
567 
568  /// Wrapper function for BAR allocation/reallocation-migration.
569  HdBufferArrayRangeSharedPtr _UpdateBufferArrayRange(
570  HdStAggregationStrategy *strategy,
571  HdStBufferArrayRegistry &bufferArrayRegistry,
572  TfToken const &role,
573  HdBufferArrayRangeSharedPtr const& curRange,
574  HdBufferSpecVector const &updatedOrAddedSpecs,
575  HdBufferSpecVector const& removedSpecs,
576  HdBufferArrayUsageHint usageHint);
577 
578  // Tally resources by key into the given dictionary. Any additions should
579  // be cumulative with the existing key values.
580  void _TallyResourceAllocation(VtDictionary *result) const;
581 
582  // TODO: this is a transient structure. we'll revisit the BufferSource
583  // interface later.
584  struct _PendingSource {
585  _PendingSource(HdBufferArrayRangeSharedPtr const &range)
586  : range(range)
587  , sources()
588  {
589  }
590 
591  _PendingSource(HdBufferArrayRangeSharedPtr const &range,
592  HdBufferSourceSharedPtr const &source)
593  : range(range)
594  , sources(1, source)
595  {
596  }
597 
598  _PendingSource(HdBufferArrayRangeSharedPtr const &range,
600  : range(range)
601  , sources(std::move(sources))
602  {
603  }
604 
607  };
608 
609  Hgi* _hgi;
610 
611  using _PendingSourceList =
612  tbb::concurrent_vector<_PendingSource>;
613  // Contains (vector of sources we need to commit, BAR we need to commit them to).
614  _PendingSourceList _pendingSources;
615 
616  using _PendingResolveList =
617  tbb::concurrent_vector<std::pair<HdBufferSourceSharedPtr,bool>>;
618  // Contains (unresolved source, whether said source requires staging).
619  _PendingResolveList _pendingSourcesToResolve;
620 
621  // Size of the staging buffer we'll need for _pendingSources. Updated as sources
622  // are resolved.
623  std::atomic_size_t _pendingStagingSize;
624 
625  struct _PendingComputation{
626  _PendingComputation(HdBufferArrayRangeSharedPtr const &range,
627  HdStComputationSharedPtr const &computation)
628  : range(range), computation(computation) { }
630  HdStComputationSharedPtr computation;
631  };
632 
633  // If we need more 'compute queues' we can increase HdStComputeQueueCount.
634  // We could also consider tbb::concurrent_priority_queue if we want this
635  // to be dynamically scalable.
636  typedef tbb::concurrent_vector<_PendingComputation> _PendingComputationList;
637  _PendingComputationList _pendingComputations[HdStComputeQueueCount];
638 
639  // aggregated buffer array
640  HdStBufferArrayRegistry _nonUniformBufferArrayRegistry;
641  HdStBufferArrayRegistry _nonUniformImmutableBufferArrayRegistry;
642  HdStBufferArrayRegistry _uniformUboBufferArrayRegistry;
643  HdStBufferArrayRegistry _uniformSsboBufferArrayRegistry;
644  HdStBufferArrayRegistry _singleBufferArrayRegistry;
645 
646  // current aggregation strategies
647  std::unique_ptr<HdStAggregationStrategy> _nonUniformAggregationStrategy;
648  std::unique_ptr<HdStAggregationStrategy>
649  _nonUniformImmutableAggregationStrategy;
650  std::unique_ptr<HdStAggregationStrategy> _uniformUboAggregationStrategy;
651  std::unique_ptr<HdStAggregationStrategy> _uniformSsboAggregationStrategy;
652  std::unique_ptr<HdStAggregationStrategy> _singleAggregationStrategy;
653 
654  typedef std::vector<HdStDispatchBufferSharedPtr>
655  _DispatchBufferRegistry;
656  _DispatchBufferRegistry _dispatchBufferRegistry;
657 
658  typedef std::vector<HdStBufferResourceSharedPtr>
659  _BufferResourceRegistry;
660  _BufferResourceRegistry _bufferResourceRegistry;
661 
662  // Register mesh topology.
664  _meshTopologyRegistry;
665 
666  // Register basisCurves topology.
668  _basisCurvesTopologyRegistry;
669 
670  // Register vertex adjacency.
672  _vertexAdjacencyBuilderRegistry;
673 
674  // Register topology index buffers.
676  _TopologyIndexRangeInstanceRegistry;
677  typedef tbb::concurrent_unordered_map< TfToken,
678  _TopologyIndexRangeInstanceRegistry,
680  _TopologyIndexRangeInstanceRegMap;
681 
682  _TopologyIndexRangeInstanceRegMap _meshTopologyIndexRangeRegistry;
683  _TopologyIndexRangeInstanceRegMap _basisCurvesTopologyIndexRangeRegistry;
684 
685  // Register shared primvar buffers.
687  _primvarRangeRegistry;
688 
689  // Register ext computation resource.
691  _extComputationDataRangeRegistry;
692 
693  // geometric shader registry
695  _geometricShaderRegistry;
696 
697  // render pass shader registry
699  _renderPassShaderRegistry;
700 
701  // glsl shader program registry
703  _glslProgramRegistry;
704 
705  // glslfx file registry
707  _glslfxFileRegistry;
708 
709 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
710  // MaterialX glslfx shader registry
711  HdInstanceRegistry<MaterialX::ShaderPtr> _materialXShaderRegistry;
712 #endif
713 
714  // texture handle registry
715  std::unique_ptr<class HdSt_TextureHandleRegistry> _textureHandleRegistry;
716 
717  // Hgi resource bindings registry
719  _resourceBindingsRegistry;
720 
721  // Hgi graphics pipeline registry
723  _graphicsPipelineRegistry;
724 
725  // Hgi compute pipeline registry
727  _computePipelineRegistry;
728 
729  using _SubResourceRegistryMap =
730  tbb::concurrent_unordered_map<std::string,
731  std::unique_ptr<HdResourceRegistry>>;
732  _SubResourceRegistryMap _subResourceRegistries;
733 
734  HgiBlitCmdsUniquePtr _blitCmds;
735  HgiComputeCmdsUniquePtr _computeCmds;
736 
737  std::unique_ptr<HdStStagingBuffer> _stagingBuffer;
738 
739  HdStRenderBufferPool _renderBufferPool;
740 };
741 
742 
744 
745 #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)
HdFormat
Definition: types.h:408
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
Definition: vec2i.h:43
std::weak_ptr< class HdStShaderCode > HdStShaderCodePtr
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
HDST_API HdStTextureObjectSharedPtr AllocateTextureObject(const HdStTextureIdentifier &textureId, HdStTextureType textureType)
HDST_API HdStPooledRenderBufferUniquePtr AllocateTempRenderBuffer(const SdfPath &graphPath, HdFormat fmt, GfVec2i dims, bool multiSampled, bool depth)
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:657
GLsizei GLenum * sources
Definition: glcorearb.h:2542
Definition: token.h:70
std::shared_ptr< class HdSt_MeshTopology > HdSt_MeshTopologySharedPtr
Definition: mesh.h:32
std::unique_ptr< HdStPooledRenderBuffer > HdStPooledRenderBufferUniquePtr
HDST_API HdBufferArrayRangeSharedPtr AllocateNonUniformBufferArrayRange(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
HgiComputeDispatch
Definition: enums.h:822
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
Definition: path.h:280
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
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:476
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:94
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.
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:322
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:32
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