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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
25 #define PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/base/vt/dictionary.h"
29 
30 #include "pxr/imaging/hdSt/api.h"
32 
33 #include "pxr/imaging/hgi/hgi.h"
34 
38 #include "pxr/imaging/hd/enums.h"
41 
42 #include <tbb/concurrent_vector.h>
43 
44 #include <atomic>
45 #include <map>
46 #include <memory>
47 
48 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
49 #include <MaterialXCore/Library.h>
51  using ShaderPtr = std::shared_ptr<class Shader>;
53 #endif
54 
56 
57 using HdStComputationSharedPtr = std::shared_ptr<class HdStComputation>;
58 using HdStDispatchBufferSharedPtr = std::shared_ptr<class HdStDispatchBuffer>;
59 using HdStGLSLProgramSharedPtr = std::shared_ptr<class HdStGLSLProgram>;
60 using HioGlslfxSharedPtr = std::shared_ptr<class HioGlslfx>;
61 
63  std::shared_ptr<class HdSt_BasisCurvesTopology>;
64 
65 using HdStShaderCodePtr =
66  std::weak_ptr<class HdStShaderCode>;
68  std::shared_ptr<class HdSt_GeometricShader>;
69 
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>;
88 
91 class HdStStagingBuffer;
92 
93 /// \enum HdStComputeQueue
94 ///
95 /// Determines the 'compute queue' a computation should be added into.
96 ///
97 /// We only perform synchronization between queues, not within one queue.
98 /// In OpenGL terms that means we insert memory barriers between computations
99 /// of two queues, but not between two computations in the same queue.
100 ///
101 /// A prim determines the role for each queue based on its local knowledge of
102 /// compute dependencies. Eg. HdStMesh knows computing normals should wait
103 /// until the primvar refinement computation has fnished. It can assign one
104 /// queue to primvar refinement and a following queue for normal computations.
105 ///
112 
114  std::vector<std::pair<HdStComputationSharedPtr, HdStComputeQueue>>;
115 
116 
117 /// \class HdStResourceRegistry
118 ///
119 /// A central registry of all GPU resources.
120 ///
122 {
123 public:
124  HF_MALLOC_TAG_NEW("new HdStResourceRegistry");
125 
126  HDST_API
127  explicit HdStResourceRegistry(Hgi* hgi);
128 
129  HDST_API
130  ~HdStResourceRegistry() override;
131 
132  HDST_API
133  void InvalidateShaderRegistry() override;
134 
135  HDST_API
136  void ReloadResource(TfToken const& resourceType,
137  std::string const& path) override;
138 
139  HDST_API
140  VtDictionary GetResourceAllocation() const override;
141 
142  /// Returns Hgi used to create/destroy GPU resources.
143  HDST_API
144  Hgi* GetHgi();
145 
146  /// ------------------------------------------------------------------------
147  /// Texture allocation API
148  /// ------------------------------------------------------------------------
149  ///
150 
151  /// Allocate texture handle (encapsulates texture and sampler
152  /// object, memory request and callback to shader).
153  ///
154  /// The actual allocation of the associated GPU texture and
155  /// sampler resources and loading of the texture file is delayed
156  /// until the commit phase.
157  HDST_API
159  /// Path to file and information to identify a texture if the
160  /// file is a container for several textures (e.g., OpenVDB
161  /// file containing several grids, movie file containing frames).
162  const HdStTextureIdentifier &textureId,
163  /// Texture type, e.g., uv, ptex, ...
164  HdTextureType textureType,
165  /// Sampling parameters such as wrapS, ...
166  /// wrapS, wrapT, wrapR mode, min filer, mag filter
167  const HdSamplerParameters &samplerParams,
168  /// Memory request. The texture is down-sampled to meet the
169  /// target memory which is the maximum of all memory requests
170  /// associated to the texture.
171  /// If all memory requests are 0, no down-sampling will happen.
172  size_t memoryRequest,
173  /// After the texture is committed (or after it has been
174  /// changed) the given shader code can add additional buffer
175  /// sources and computations using the texture metadata with
176  /// AddResourcesFromTextures.
177  HdStShaderCodePtr const &shaderCode);
178 
179  /// Allocate texture object.
180  ///
181  /// The actual allocation of the associated GPU texture and
182  /// sampler resources and loading of the texture file is delayed
183  /// until the commit phase.
184  HDST_API
186  /// Path to file and information to identify a texture if the
187  /// file is a container for several textures (e.g., OpenVDB
188  /// file containing several grids, movie file containing frames).
189  const HdStTextureIdentifier &textureId,
190  /// Texture type, e.g., uv, ptex, ...
191  HdTextureType textureType);
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  HdTextureType 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 
340  /// Remove any entries associated with expired dispatch buffers.
341  HDST_API
343 
344  /// Remove any entries associated with expired misc buffers.
345  HDST_API
347 
348  /// ------------------------------------------------------------------------
349  /// Instance Registries
350  /// ------------------------------------------------------------------------
351 
352  /// These registries implement sharing and deduplication of data based
353  /// on computed hash identifiers. Each returned HdInstance object retains
354  /// a shared pointer to a data instance. When an HdInstance is registered
355  /// for a previously unused ID, the data pointer will be null and it is
356  /// the caller's responsibility to set its value. The instance registries
357  /// are cleaned of unreferenced entries during garbage collection.
358  ///
359  /// Note: As entries can be registered from multiple threads, the returned
360  /// object holds a lock on the instance registry. This lock is held
361  /// until the returned HdInstance object is destroyed.
362 
363  /// Topology instancing
364  HDST_API
367 
368  HDST_API
372 
373  HDST_API
377 
378  /// Topology Index buffer array range instancing
379  /// Returns the HdInstance points to shared HdBufferArrayRange,
380  /// distinguished by given ID.
381  /// *Refer the comment on RegisterTopology for the same consideration.
382  HDST_API
386 
387  HDST_API
391 
392  /// Primvar array range instancing
393  /// Returns the HdInstance pointing to shared HdBufferArrayRange,
394  /// distinguished by given ID.
395  /// *Refer the comment on RegisterTopology for the same consideration.
396  HDST_API
400 
401  /// ExtComputation data array range instancing
402  /// Returns the HdInstance pointing to shared HdBufferArrayRange,
403  /// distinguished by given ID.
404  /// *Refer the comment on RegisterTopology for the same consideration.
405  HDST_API
409 
410  /// Register a geometric shader.
411  HDST_API
414 
415  /// Register a GLSL program into the program registry.
416  HDST_API
419 
420  /// Register a GLSLFX file.
421  HDST_API
424 
425 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
426  /// Register MaterialX GLSLFX Shader.
427  HDST_API
429  RegisterMaterialXShader(HdInstance<MaterialX::ShaderPtr>::ID id);
430 #endif
431 
432  /// Register a Hgi resource bindings into the registry.
433  HDST_API
436 
437  /// Register a Hgi graphics pipeline into the registry.
438  HDST_API
441 
442  /// Register a Hgi compute pipeline into the registry.
443  HDST_API
446 
447  /// Returns the global hgi blit command queue for recording blitting work.
448  /// When using this global cmd instead of creating a new HgiBlitCmds we
449  /// reduce the number of command buffers being created.
450  /// The returned pointer should not be held onto by the client as it is
451  /// only valid until the HgiBlitCmds has been submitted.
452  HDST_API
454 
455  /// Returns the global hgi compute cmd queue for recording compute work.
456  /// When using this global cmd instead of creating a new HgiComputeCmds we
457  /// reduce the number of command buffers being created.
458  /// The returned pointer should not be held onto by the client as it is
459  /// only valid until the HgiComputeCmds has been submitted.
460  HDST_API
463 
464  /// Submits blit work queued in global blit cmds for GPU execution.
465  /// We can call this when we want to submit some work to the GPU.
466  /// To stall the CPU and wait for the GPU to finish, 'wait' can be provided.
467  /// To insert a barrier to ensure memory writes are visible after the
468  /// barrier a HgiMemoryBarrier can be provided.
469  HDST_API
471 
472  /// Submits compute work queued in global compute cmds for GPU execution.
473  /// We can call this when we want to submit some work to the GPU.
474  /// To stall the CPU and wait for the GPU to finish, 'wait' can be provided.
475  /// To insert a barrier to ensure memory writes are visible after the
476  /// barrier a HgiMemoryBarrier can be provided.
477  HDST_API
479 
480  /// Returns the staging buffer used when committing data to the GPU.
481  HDST_API
483 
484 public:
485  //
486  // Unit test API
487  //
488 
489  /// Set the aggregation strategy for non uniform parameters
490  /// (vertex, varying, facevarying)
491  /// Takes ownership of the passed in strategy object.
493  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
494  _nonUniformAggregationStrategy = std::move(strategy);
495  }
496 
497  /// Set the aggregation strategy for non uniform immutable parameters
498  /// (vertex, varying, facevarying)
499  /// Takes ownership of the passed in strategy object.
501  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
502  _nonUniformImmutableAggregationStrategy = std::move(strategy);
503  }
504 
505  /// Set the aggregation strategy for uniform (shader globals)
506  /// Takes ownership of the passed in strategy object.
508  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
509  _uniformUboAggregationStrategy = std::move(strategy);
510  }
511 
512  /// Set the aggregation strategy for SSBO (uniform primvars)
513  /// Takes ownership of the passed in strategy object.
515  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
516  _uniformSsboAggregationStrategy = std::move(strategy);
517  }
518 
519  /// Set the aggregation strategy for single buffers (for nested instancer).
520  /// Takes ownership of the passed in strategy object.
522  std::unique_ptr<HdStAggregationStrategy> &&strategy) {
523  _singleAggregationStrategy = std::move(strategy);
524  }
525 
526  /// Debug dump
527  HDST_API
528  friend std::ostream &operator <<(
529  std::ostream &out,
530  const HdStResourceRegistry& self);
531 
532 protected:
533  void _Commit() override;
534  void _GarbageCollect() override;
535 
536 private:
537  void _CommitTextures();
538  // Wrapper function for BAR allocation
539  HdBufferArrayRangeSharedPtr _AllocateBufferArrayRange(
540  HdStAggregationStrategy *strategy,
541  HdStBufferArrayRegistry &bufferArrayRegistry,
542  TfToken const &role,
543  HdBufferSpecVector const &bufferSpecs,
544  HdBufferArrayUsageHint usageHint);
545 
546  /// Wrapper function for BAR allocation/reallocation-migration.
547  HdBufferArrayRangeSharedPtr _UpdateBufferArrayRange(
548  HdStAggregationStrategy *strategy,
549  HdStBufferArrayRegistry &bufferArrayRegistry,
550  TfToken const &role,
551  HdBufferArrayRangeSharedPtr const& curRange,
552  HdBufferSpecVector const &updatedOrAddedSpecs,
553  HdBufferSpecVector const& removedSpecs,
554  HdBufferArrayUsageHint usageHint);
555 
556  // Tally resources by key into the given dictionary. Any additions should
557  // be cumulative with the existing key values.
558  void _TallyResourceAllocation(VtDictionary *result) const;
559 
560  // TODO: this is a transient structure. we'll revisit the BufferSource
561  // interface later.
562  struct _PendingSource {
563  _PendingSource(HdBufferArrayRangeSharedPtr const &range)
564  : range(range)
565  , sources()
566  {
567  }
568 
569  _PendingSource(HdBufferArrayRangeSharedPtr const &range,
570  HdBufferSourceSharedPtr const &source)
571  : range(range)
572  , sources(1, source)
573  {
574  }
575 
576  _PendingSource(HdBufferArrayRangeSharedPtr const &range,
578  : range(range)
579  , sources(std::move(sources))
580  {
581  }
582 
585  };
586 
587  Hgi* _hgi;
588 
589  typedef tbb::concurrent_vector<_PendingSource> _PendingSourceList;
590  _PendingSourceList _pendingSources;
591  std::atomic_size_t _numBufferSourcesToResolve;
592 
593  struct _PendingComputation{
594  _PendingComputation(HdBufferArrayRangeSharedPtr const &range,
595  HdStComputationSharedPtr const &computation)
596  : range(range), computation(computation) { }
598  HdStComputationSharedPtr computation;
599  };
600 
601  // If we need more 'compute queues' we can increase HdStComputeQueueCount.
602  // We could also consider tbb::concurrent_priority_queue if we want this
603  // to be dynamically scalable.
604  typedef tbb::concurrent_vector<_PendingComputation> _PendingComputationList;
605  _PendingComputationList _pendingComputations[HdStComputeQueueCount];
606 
607  // aggregated buffer array
608  HdStBufferArrayRegistry _nonUniformBufferArrayRegistry;
609  HdStBufferArrayRegistry _nonUniformImmutableBufferArrayRegistry;
610  HdStBufferArrayRegistry _uniformUboBufferArrayRegistry;
611  HdStBufferArrayRegistry _uniformSsboBufferArrayRegistry;
612  HdStBufferArrayRegistry _singleBufferArrayRegistry;
613 
614  // current aggregation strategies
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;
621 
622  typedef std::vector<HdStDispatchBufferSharedPtr>
623  _DispatchBufferRegistry;
624  _DispatchBufferRegistry _dispatchBufferRegistry;
625 
626  typedef std::vector<HdStBufferResourceSharedPtr>
627  _BufferResourceRegistry;
628  _BufferResourceRegistry _bufferResourceRegistry;
629 
630  // Register mesh topology.
632  _meshTopologyRegistry;
633 
634  // Register basisCurves topology.
636  _basisCurvesTopologyRegistry;
637 
638  // Register vertex adjacency.
640  _vertexAdjacencyBuilderRegistry;
641 
642  // Register topology index buffers.
644  _TopologyIndexRangeInstanceRegistry;
645  typedef tbb::concurrent_unordered_map< TfToken,
646  _TopologyIndexRangeInstanceRegistry,
648  _TopologyIndexRangeInstanceRegMap;
649 
650  _TopologyIndexRangeInstanceRegMap _meshTopologyIndexRangeRegistry;
651  _TopologyIndexRangeInstanceRegMap _basisCurvesTopologyIndexRangeRegistry;
652 
653  // Register shared primvar buffers.
655  _primvarRangeRegistry;
656 
657  // Register ext computation resource.
659  _extComputationDataRangeRegistry;
660 
661  // geometric shader registry
663  _geometricShaderRegistry;
664 
665  // glsl shader program registry
667  _glslProgramRegistry;
668 
669  // glslfx file registry
671  _glslfxFileRegistry;
672 
673 #ifdef PXR_MATERIALX_SUPPORT_ENABLED
674  // MaterialX glslfx shader registry
675  HdInstanceRegistry<MaterialX::ShaderPtr> _materialXShaderRegistry;
676 #endif
677 
678  // texture handle registry
679  std::unique_ptr<class HdSt_TextureHandleRegistry> _textureHandleRegistry;
680 
681  // Hgi resource bindings registry
683  _resourceBindingsRegistry;
684 
685  // Hgi graphics pipeline registry
687  _graphicsPipelineRegistry;
688 
689  // Hgi compute pipeline registry
691  _computePipelineRegistry;
692 
693  HgiBlitCmdsUniquePtr _blitCmds;
694  HgiComputeCmdsUniquePtr _computeCmds;
695 
696  std::unique_ptr<HdStStagingBuffer> _stagingBuffer;
697 };
698 
699 
701 
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)
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:44
std::weak_ptr< class HdStShaderCode > HdStShaderCodePtr
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
std::shared_ptr< class HdSt_GeometricShader > HdSt_GeometricShaderSharedPtr
Definition: drawItem.h:36
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.
Definition: token.h:166
std::vector< HdBufferSourceSharedPtr > HdBufferSourceSharedPtrVector
Definition: bufferSource.h:44
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:613
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:664
GLsizei GLenum * sources
Definition: glcorearb.h:2542
Definition: token.h:87
std::shared_ptr< class HdSt_MeshTopology > HdSt_MeshTopologySharedPtr
Definition: mesh.h:49
HDST_API HdBufferArrayRangeSharedPtr AllocateNonUniformBufferArrayRange(TfToken const &role, HdBufferSpecVector const &bufferSpecs, HdBufferArrayUsageHint usageHint)
HgiComputeDispatch
Definition: enums.h:826
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
HdTextureType
Definition: enums.h:221
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:41
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
Definition: thread.h:623
HDST_API void AddSources(HdBufferArrayRangeSharedPtr const &range, HdBufferSourceSharedPtrVector &&sources)
Append source data for given range to be committed later.
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:36
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)
*tasks wait()
HDST_API HdBufferArrayRangeSharedPtr UpdateNonUniformBufferArrayRange(TfToken const &role, HdBufferArrayRangeSharedPtr const &curRange, HdBufferSpecVector const &updatedOrAddedSpecs, HdBufferSpecVector const &removedSpecs, HdBufferArrayUsageHint usageHint)
Definition: hgi.h:110
HDST_API void ReloadResource(TfToken const &resourceType, std::string const &path) override
std::unique_ptr< class HgiBlitCmds > HgiBlitCmdsUniquePtr
Definition: blitCmds.h:45
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:1432
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:329
std::shared_ptr< class HdStTextureHandle > HdStTextureHandleSharedPtr
HDST_API HdStBufferResourceSharedPtr RegisterBufferResource(TfToken const &role, HdTupleType tupleType, HgiBufferUsage bufferUsage)
#define HDST_API
Definition: api.h:40
HDST_API HdInstance< HdSt_BasisCurvesTopologySharedPtr > RegisterBasisCurvesTopology(HdInstance< HdSt_BasisCurvesTopologySharedPtr >::ID id)
std::shared_ptr< class HioGlslfx > HioGlslfxSharedPtr
Definition: glslfxShader.h:34
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
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
Definition: bufferArray.h:44
void _GarbageCollect() override
std::shared_ptr< class HdSt_VertexAdjacencyBuilder > HdSt_VertexAdjacencyBuilderSharedPtr
Definition: mesh.h:47
shared_ptr< Shader > ShaderPtr
Shared pointer to a Shader.
Definition: Library.h:34
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 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
Definition: commandBuffer.h:47
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