All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resourceRegistry.h
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/imaging/hdSt/api.h"
29 
30 #include "pxr/imaging/hd/instanceRegistry.h"
31 #include "pxr/imaging/hd/resourceRegistry.h"
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
35 typedef boost::shared_ptr<class HdStDispatchBuffer>
36  HdStDispatchBufferSharedPtr;
37 typedef boost::shared_ptr<class HdStGLSLProgram>
38  HdStGLSLProgramSharedPtr;
39 typedef boost::shared_ptr<class HdStPersistentBuffer>
40  HdStPersistentBufferSharedPtr;
41 typedef boost::shared_ptr<class HdStResourceRegistry>
42  HdStResourceRegistrySharedPtr;
43 typedef boost::shared_ptr<class HdStTextureResource>
44  HdStTextureResourceSharedPtr;
45 typedef boost::shared_ptr<class HdStTextureResourceHandle>
46  HdStTextureResourceHandleSharedPtr;
47 typedef boost::shared_ptr<class HdSt_BasisCurvesTopology>
48  HdSt_BasisCurvesTopologySharedPtr;
49 typedef boost::shared_ptr<class HdSt_GeometricShader>
50  HdSt_GeometricShaderSharedPtr;
51 typedef boost::shared_ptr<class HdSt_MeshTopology>
52  HdSt_MeshTopologySharedPtr;
53 typedef boost::shared_ptr<class Hd_VertexAdjacency>
54  Hd_VertexAdjacencySharedPtr;
55 
61 public:
62  HF_MALLOC_TAG_NEW("new HdStResourceRegistry");
63 
64  HDST_API
66 
67  HDST_API
68  virtual ~HdStResourceRegistry();
69 
72  HDST_API
73  HdStDispatchBufferSharedPtr RegisterDispatchBuffer(
74  TfToken const &role, int count, int commandNumUints);
75 
78  HDST_API
79  HdStPersistentBufferSharedPtr RegisterPersistentBuffer(
80  TfToken const &role, size_t dataSize, void *data);
81 
83  HDST_API
85 
87  HDST_API
89 
94  HDST_API
95  HdBufferArrayRangeSharedPtr MergeBufferArrayRange(
96  HdAggregationStrategy *strategy,
97  HdBufferArrayRegistry &bufferArrayRegistry,
98  TfToken const &role,
99  HdBufferSpecVector const &newBufferSpecs,
100  HdBufferArrayUsageHint newUsageHint,
101  HdBufferArrayRangeSharedPtr const &range);
102 
104  HDST_API
105  HdBufferArrayRangeSharedPtr MergeNonUniformBufferArrayRange(
106  TfToken const &role,
107  HdBufferSpecVector const &newBufferSpecs,
108  HdBufferArrayUsageHint newUsageHint,
109  HdBufferArrayRangeSharedPtr const &range);
110 
112  HDST_API
113  HdBufferArrayRangeSharedPtr MergeNonUniformImmutableBufferArrayRange(
114  TfToken const &role,
115  HdBufferSpecVector const &newBufferSpecs,
116  HdBufferArrayUsageHint newUsageHint,
117  HdBufferArrayRangeSharedPtr const &range);
118 
120  HDST_API
121  HdBufferArrayRangeSharedPtr MergeUniformBufferArrayRange(
122  TfToken const &role,
123  HdBufferSpecVector const &newBufferSpecs,
124  HdBufferArrayUsageHint newUsageHint,
125  HdBufferArrayRangeSharedPtr const &range);
126 
128  HDST_API
129  HdBufferArrayRangeSharedPtr MergeShaderStorageBufferArrayRange(
130  TfToken const &role,
131  HdBufferSpecVector const &newBufferSpecs,
132  HdBufferArrayUsageHint newUsageHint,
133  HdBufferArrayRangeSharedPtr const &range);
134 
135 
148 
150  HDST_API
152  RegisterMeshTopology(HdInstance<HdSt_MeshTopologySharedPtr>::ID id);
153 
154  HDST_API
156  RegisterBasisCurvesTopology(
157  HdInstance<HdSt_BasisCurvesTopologySharedPtr>::ID id);
158 
159  HDST_API
161  RegisterVertexAdjacency(HdInstance<Hd_VertexAdjacencySharedPtr>::ID id);
162 
167  HDST_API
170  HdInstance<HdBufferArrayRangeSharedPtr>::ID id, TfToken const &name);
171 
172  HDST_API
174  RegisterBasisCurvesIndexRange(
175  HdInstance<HdBufferArrayRangeSharedPtr>::ID id, TfToken const &name);
176 
181  HDST_API
184  HdInstance<HdBufferArrayRangeSharedPtr>::ID id);
185 
190  HDST_API
193  HdInstance<HdBufferArrayRangeSharedPtr>::ID id);
194 
202  HDST_API
205 
208  HDST_API
210  FindTextureResource(TextureKey id, bool *found);
211 
213  HDST_API
215  RegisterGeometricShader(HdInstance<HdSt_GeometricShaderSharedPtr>::ID id);
216 
218  HDST_API
220  RegisterGLSLProgram(HdInstance<HdStGLSLProgramSharedPtr>::ID id);
221 
223  HDST_API
226  HdInstance<HdStTextureResourceHandleSharedPtr>::ID id);
227 
229  HDST_API
232  HdInstance<HdStTextureResourceHandleSharedPtr>::ID id, bool *found);
233 
234  void InvalidateShaderRegistry() override;
235 
236 protected:
237  virtual void _GarbageCollect() override;
238  virtual void _GarbageCollectBprims() override;
239  virtual void _TallyResourceAllocation(VtDictionary *result) const override;
240 
241 private:
242 
243  typedef std::vector<HdStDispatchBufferSharedPtr>
244  _DispatchBufferRegistry;
245  _DispatchBufferRegistry _dispatchBufferRegistry;
246 
247  typedef std::vector<HdStPersistentBufferSharedPtr>
248  _PersistentBufferRegistry;
249  _PersistentBufferRegistry _persistentBufferRegistry;
250 
251  // Register mesh topology.
253  _meshTopologyRegistry;
254 
255  // Register basisCurves topology.
257  _basisCurvesTopologyRegistry;
258 
259  // Register vertex adjacency.
261  _vertexAdjacencyRegistry;
262 
263  // Register topology index buffers.
266  typedef tbb::concurrent_unordered_map< TfToken,
269  _TopologyIndexRangeInstanceRegMap;
270 
271  _TopologyIndexRangeInstanceRegMap _meshTopologyIndexRangeRegistry;
272  _TopologyIndexRangeInstanceRegMap _basisCurvesTopologyIndexRangeRegistry;
273 
274  // Register shared primvar buffers.
276  _primvarRangeRegistry;
277 
278  // Register ext computation resource.
280  _extComputationDataRangeRegistry;
281 
282  // texture resource registry
284  _textureResourceRegistry;
285  // geometric shader registry
287  _geometricShaderRegistry;
288 
289  // glsl shader program registry
291  _glslProgramRegistry;
292 
293  // texture resource handle registry
295  _textureResourceHandleRegistry;
296 
297 };
298 
299 
300 PXR_NAMESPACE_CLOSE_SCOPE
301 
302 #endif //PXR_IMAGING_HD_ST_RESOURCE_REGISTRY_H
The union provides a set of flags that provide hints to the memory management system about the proper...
Definition: bufferArray.h:74
void InvalidateShaderRegistry() override
Invalidate any shaders registered with this registry.
Aggregation strategy base class.
Definition: strategyBase.h:48
HDST_API HdInstance< HdBufferArrayRangeSharedPtr > RegisterPrimvarRange(HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
Primvar array range instancing Returns the HdInstance pointing to shared HdBufferArrayRange, distinguished by given ID.
A map with string keys and VtValue values.
Definition: dictionary.h:61
HDST_API HdInstance< HdStTextureResourceHandleSharedPtr > RegisterTextureResourceHandle(HdInstance< HdStTextureResourceHandleSharedPtr >::ID id)
Register a texture resource handle.
Functor to use for hash maps from tokens to other things.
Definition: token.h:168
HDST_API void GarbageCollectDispatchBuffers()
Remove any entries associated with expired dispatch buffers.
Manages the pool of buffer arrays.
HDST_API HdBufferArrayRangeSharedPtr MergeUniformBufferArrayRange(TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
MergeBufferArrayRange of uniform buffer.
virtual void _GarbageCollect() override
Hooks for derived registries to perform additional GC when GarbageCollect() or GarbageCollectBprims()...
HDST_API void GarbageCollectPersistentBuffers()
Remove any entries associated with expired persistently mapped buffers.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
virtual void _TallyResourceAllocation(VtDictionary *result) const override
A hook for derived registries to tally their resources by key into the given dictionary.
HDST_API HdBufferArrayRangeSharedPtr MergeNonUniformBufferArrayRange(TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
MergeBufferArrayRange of non uniform buffer.
HDST_API HdBufferArrayRangeSharedPtr MergeShaderStorageBufferArrayRange(TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
MergeBufferArrayRange of shader storage buffer.
A central registry of all GPU resources.
HDST_API HdInstance< HdStTextureResourceSharedPtr > FindTextureResource(TextureKey id, bool *found)
Find a texture in the texture registry.
HDST_API HdStPersistentBufferSharedPtr RegisterPersistentBuffer(TfToken const &role, size_t dataSize, void *data)
Register a buffer initialized with dataSize bytes of data to be used as a persistently mapped shader ...
A central registry of all GPU resources.
HDST_API HdBufferArrayRangeSharedPtr MergeNonUniformImmutableBufferArrayRange(TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
MergeBufferArrayRange of non uniform immutable buffer.
HDST_API HdStDispatchBufferSharedPtr RegisterDispatchBuffer(TfToken const &role, int count, int commandNumUints)
Register a buffer allocated with count * commandNumUints * sizeof(GLuint) to be used as an indirect d...
HDST_API HdBufferArrayRangeSharedPtr MergeBufferArrayRange(HdAggregationStrategy *strategy, HdBufferArrayRegistry &bufferArrayRegistry, TfToken const &role, HdBufferSpecVector const &newBufferSpecs, HdBufferArrayUsageHint newUsageHint, HdBufferArrayRangeSharedPtr const &range)
Check if range is compatible with newBufferSpecs.
HDST_API HdInstance< HdBufferArrayRangeSharedPtr > RegisterExtComputationDataRange(HdInstance< HdBufferArrayRangeSharedPtr >::ID id)
ExtComputation data array range instancing Returns the HdInstance pointing to shared HdBufferArrayRan...
HDST_API HdInstance< HdStTextureResourceHandleSharedPtr > FindTextureResourceHandle(HdInstance< HdStTextureResourceHandleSharedPtr >::ID id, bool *found)
Find a texture resource handle.
HDST_API HdInstance< HdStTextureResourceSharedPtr > RegisterTextureResource(TextureKey id)
Register a texture into the texture registry.
HDST_API HdInstance< HdSt_GeometricShaderSharedPtr > RegisterGeometricShader(HdInstance< HdSt_GeometricShaderSharedPtr >::ID id)
Register a geometric shader.
size_t TextureKey
Globally unique id for texture, see HdRenderIndex::GetTextureKey() for details.
HDST_API HdInstance< HdSt_MeshTopologySharedPtr > RegisterMeshTopology(HdInstance< HdSt_MeshTopologySharedPtr >::ID id)
Instance Registries.
This class is used as an interface to a shared instance in HdInstanceRegistry.
HDST_API HdInstance< HdBufferArrayRangeSharedPtr > RegisterMeshIndexRange(HdInstance< HdBufferArrayRangeSharedPtr >::ID id, TfToken const &name)
Topology Index buffer array range instancing Returns the HdInstance points to shared HdBufferArrayRan...
HDST_API HdInstance< HdStGLSLProgramSharedPtr > RegisterGLSLProgram(HdInstance< HdStGLSLProgramSharedPtr >::ID id)
Register a GLSL program into the program registry.