All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
valueCache.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_USD_IMAGING_USD_IMAGING_VALUE_CACHE_H
25 #define PXR_USD_IMAGING_USD_IMAGING_VALUE_CACHE_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usdImaging/usdImaging/api.h"
31 #include "pxr/imaging/hd/enums.h"
32 #include "pxr/imaging/hd/tokens.h"
33 #include "pxr/imaging/hd/materialParam.h"
34 #include "pxr/imaging/hd/sceneDelegate.h"
35 #include "pxr/imaging/hd/version.h"
36 
37 #include "pxr/usd/sdf/path.h"
38 #include "pxr/base/vt/value.h"
39 
40 #include "pxr/base/gf/matrix4d.h"
41 #include "pxr/base/gf/range3d.h"
42 #include "pxr/base/gf/vec4f.h"
43 #include "pxr/base/tf/token.h"
44 
45 #include <tbb/concurrent_unordered_map.h>
46 #include <tbb/concurrent_queue.h>
47 
48 PXR_NAMESPACE_OPEN_SCOPE
49 
50 
51 
57 public:
59  UsdImagingValueCache& operator=(const UsdImagingValueCache&) = delete;
60 
61  class Key {
62  friend class UsdImagingValueCache;
63  private:
64  SdfPath _path;
65  TfToken _attribute;
66  public:
67  Key(SdfPath const& path, TfToken const& attr)
68  : _path(path)
69  , _attribute(attr)
70  {}
71 
72  inline bool operator==(Key const& rhs) const {
73  return _path == rhs._path && _attribute == rhs._attribute;
74  }
75  inline bool operator!=(Key const& rhs) const {
76  return !(*this == rhs);
77  }
78 
79  struct Hash {
80  inline size_t operator()(Key const& key) const {
81  size_t hash = key._path.GetHash();
82  boost::hash_combine(hash, key._attribute.Hash());
83  return hash;
84  }
85  };
86 
87  private:
88  static Key Color(SdfPath const& path) {
89  static TfToken attr("displayColor");
90  return Key(path, attr);
91  }
92  static Key Opacity(SdfPath const& path) {
93  static TfToken attr("displayOpacity");
94  return Key(path, attr);
95  }
96  static Key DoubleSided(SdfPath const& path) {
97  static TfToken attr("doubleSided");
98  return Key(path, attr);
99  }
100  static Key CullStyle(SdfPath const& path) {
101  static TfToken attr("cullStyle");
102  return Key(path, attr);
103  }
104  static Key Extent(SdfPath const& path) {
105  static TfToken attr("extent");
106  return Key(path, attr);
107  }
108  static Key InstancerTransform(SdfPath const& path) {
109  static TfToken attr("instancerTransform");
110  return Key(path, attr);
111  }
112  static Key InstanceIndices(SdfPath const& path) {
113  static TfToken attr("instanceIndices");
114  return Key(path, attr);
115  }
116  static Key Points(SdfPath const& path) {
117  static TfToken attr("points");
118  return Key(path, attr);
119  }
120  static Key Purpose(SdfPath const& path) {
121  static TfToken attr("purpose");
122  return Key(path, attr);
123  }
124  static Key Primvars(SdfPath const& path) {
125  static TfToken attr("primvars");
126  return Key(path, attr);
127  }
128  static Key Topology(SdfPath const& path) {
129  static TfToken attr("topology");
130  return Key(path, attr);
131  }
132  static Key Transform(SdfPath const& path) {
133  static TfToken attr("transform");
134  return Key(path, attr);
135  }
136  static Key Visible(SdfPath const& path) {
137  static TfToken attr("visible");
138  return Key(path, attr);
139  }
140  static Key Widths(SdfPath const& path) {
141  static TfToken attr("widths");
142  return Key(path, attr);
143  }
144  static Key Normals(SdfPath const& path) {
145  static TfToken attr("normals");
146  return Key(path, attr);
147  }
148  static Key MaterialId(SdfPath const& path) {
149  static TfToken attr("materialId");
150  return Key(path, attr);
151  }
152  static Key MaterialResource(SdfPath const& path) {
153  static TfToken attr("materialResource");
154  return Key(path, attr);
155  }
156  static Key ExtComputationSceneInputNames(SdfPath const& path) {
157  static TfToken attr("extComputationSceneInputNames");
158  return Key(path, attr);
159  }
160  static Key ExtComputationInputs(SdfPath const& path) {
161  static TfToken attr("extComputationInputs");
162  return Key(path, attr);
163  }
164  static Key ExtComputationOutputs(SdfPath const& path) {
165  static TfToken attr("extComputationOutputs");
166  return Key(path, attr);
167  }
168  static Key ExtComputationPrimvars(SdfPath const& path) {
169  const TfToken attr("extComputationPrimvars");
170  return Key(path, attr);
171  }
172  static Key ExtComputationKernel(SdfPath const& path) {
173  const TfToken attr("extComputationKernel");
174  return Key(path, attr);
175  }
176  static Key CameraParamNames(SdfPath const& path) {
177  static TfToken attr("CameraParamNames");
178  return Key(path, attr);
179  }
180  };
181 
183  : _locked(false)
184  { }
185 
186 private:
187  template <typename Element>
188  struct _TypedCache
189  {
190  typedef tbb::concurrent_unordered_map<Key, Element, Key::Hash> _MapType;
191  typedef typename _MapType::iterator _MapIt;
192  typedef typename _MapType::const_iterator _MapConstIt;
193  typedef tbb::concurrent_queue<_MapIt> _QueueType;
194 
195  _MapType _map;
196  _QueueType _deferredDeleteQueue;
197  };
198 
199 
202  template <typename T>
203  bool _Find(Key const& key, T* value) const {
204  typedef _TypedCache<T> Cache_t;
205 
206  Cache_t *cache = nullptr;
207 
208  _GetCache(&cache);
209  typename Cache_t::_MapConstIt it = cache->_map.find(key);
210  if (it == cache->_map.end()) {
211  return false;
212  }
213  *value = it->second;
214  return true;
215  }
216 
224  template <typename T>
225  bool _Extract(Key const& key, T* value) {
226  if (!TF_VERIFY(!_locked)) {
227  return false;
228  }
229 
230  typedef _TypedCache<T> Cache_t;
231  Cache_t *cache = nullptr;
232 
233  _GetCache(&cache);
234  typename Cache_t::_MapIt it = cache->_map.find(key);
235 
236  if (it == cache->_map.end()) {
237  return false;
238  }
239 
240  // If we're going to erase the old value, swap to avoid a copy.
241  std::swap(it->second, *value);
242  cache->_deferredDeleteQueue.push(it);
243  return true;
244  }
245 
246 
247 
250  template <typename T>
251  void _Erase(Key const& key) {
252  if (!TF_VERIFY(!_locked)) {
253  return;
254  }
255 
256  typedef _TypedCache<T> Cache_t;
257 
258  Cache_t *cache = nullptr;
259  _GetCache(&cache);
260  cache->_map.unsafe_erase(key);
261  }
262 
266  template <typename T>
267  T& _Get(Key const& key) const {
268  typedef _TypedCache<T> Cache_t;
269 
270  Cache_t *cache = nullptr;
271  _GetCache(&cache);
272 
273  // With concurrent_unordered_map, multi-threaded insertion is safe.
274  std::pair<typename Cache_t::_MapIt, bool> res =
275  cache->_map.insert(std::make_pair(key, T()));
276 
277  return res.first->second;
278  }
279 
283  template <typename T>
284  void _GarbageCollect(_TypedCache<T> &cache) {
285  typedef _TypedCache<T> Cache_t;
286 
287  typename Cache_t::_MapIt it;
288 
289  while (cache._deferredDeleteQueue.try_pop(it)) {
290  cache._map.unsafe_erase(it);
291  }
292  }
293 
294 public:
295 
296  void EnableMutation() { _locked = false; }
297  void DisableMutation() { _locked = true; }
298 
300  void Clear(SdfPath const& path) {
301  _Erase<VtValue>(Key::Color(path));
302  _Erase<VtValue>(Key::Opacity(path));
303  _Erase<bool>(Key::DoubleSided(path));
304  _Erase<HdCullStyle>(Key::CullStyle(path));
305  _Erase<GfRange3d>(Key::Extent(path));
306  _Erase<VtValue>(Key::InstanceIndices(path));
307  _Erase<TfToken>(Key::Purpose(path));
308  _Erase<VtValue>(Key::Topology(path));
309  _Erase<GfMatrix4d>(Key::Transform(path));
310  _Erase<bool>(Key::Visible(path));
311  _Erase<VtValue>(Key::Points(path));
312  _Erase<VtValue>(Key::Widths(path));
313  _Erase<VtValue>(Key::Normals(path));
314  _Erase<VtValue>(Key::MaterialId(path));
315  _Erase<VtValue>(Key::MaterialResource(path));
316 
317  // PERFORMANCE: We're copying the primvar vector here, but we could
318  // access the map directly, if we need to for performance reasons.
319  HdPrimvarDescriptorVector vars;
320  if (FindPrimvars(path, &vars)) {
321  TF_FOR_ALL(pvIt, vars) {
322  _Erase<VtValue>(Key(path, pvIt->name));
323  }
324  _Erase<HdPrimvarDescriptorVector>(Key::Primvars(path));
325  }
326 
327  {
328  // ExtComputation related state
329  TfTokenVector sceneInputNames;
330  if (FindExtComputationSceneInputNames(path, &sceneInputNames)) {
331  // Add computation "config" params to the list of inputs
332  sceneInputNames.emplace_back(HdTokens->dispatchCount);
333  sceneInputNames.emplace_back(HdTokens->elementCount);
334  for (TfToken const& input : sceneInputNames) {
335  _Erase<VtValue>(Key(path, input));
336  }
337 
338  _Erase<TfTokenVector>(Key::ExtComputationSceneInputNames(path));
339  }
340 
341  // Computed inputs are tied to the computation that computes them.
342  // We don't walk the dependency chain to clear them.
343  _Erase<HdExtComputationInputDescriptorVector>(
344  Key::ExtComputationInputs(path));
345 
346  HdExtComputationOutputDescriptorVector outputDescs;
347  if (FindExtComputationOutputs(path, &outputDescs)) {
348  for (auto const& desc : outputDescs) {
349  _Erase<VtValue>(Key(path, desc.name));
350  }
351  _Erase<HdExtComputationOutputDescriptorVector>(
352  Key::ExtComputationOutputs(path));
353  }
354 
355  _Erase<HdExtComputationPrimvarDescriptorVector>(
356  Key::ExtComputationPrimvars(path));
357  _Erase<std::string>(Key::ExtComputationKernel(path));
358  }
359 
360  // Camera state
361  TfTokenVector CameraParamNames;
362  if (FindCameraParamNames(path, &CameraParamNames)) {
363  for (const TfToken& paramName : CameraParamNames) {
364  _Erase<VtValue>(Key(path, paramName));
365  }
366 
367  _Erase<TfTokenVector>(Key::CameraParamNames(path));
368  }
369  }
370 
371  VtValue& GetColor(SdfPath const& path) const {
372  return _Get<VtValue>(Key::Color(path));
373  }
374  VtValue& GetOpacity(SdfPath const& path) const {
375  return _Get<VtValue>(Key::Opacity(path));
376  }
377  bool& GetDoubleSided(SdfPath const& path) const {
378  return _Get<bool>(Key::DoubleSided(path));
379  }
380  HdCullStyle& GetCullStyle(SdfPath const& path) const {
381  return _Get<HdCullStyle>(Key::CullStyle(path));
382  }
383  GfRange3d& GetExtent(SdfPath const& path) const {
384  return _Get<GfRange3d>(Key::Extent(path));
385  }
386  GfMatrix4d& GetInstancerTransform(SdfPath const& path) const {
387  return _Get<GfMatrix4d>(Key::InstancerTransform(path));
388  }
389  VtValue& GetInstanceIndices(SdfPath const& path) const {
390  return _Get<VtValue>(Key::InstanceIndices(path));
391  }
392  VtValue& GetPoints(SdfPath const& path) const {
393  return _Get<VtValue>(Key::Points(path));
394  }
395  TfToken& GetPurpose(SdfPath const& path) const {
396  return _Get<TfToken>(Key::Purpose(path));
397  }
398  HdPrimvarDescriptorVector& GetPrimvars(SdfPath const& path) const {
399  return _Get<HdPrimvarDescriptorVector>(Key::Primvars(path));
400  }
401  VtValue& GetTopology(SdfPath const& path) const {
402  return _Get<VtValue>(Key::Topology(path));
403  }
404  GfMatrix4d& GetTransform(SdfPath const& path) const {
405  return _Get<GfMatrix4d>(Key::Transform(path));
406  }
407  bool& GetVisible(SdfPath const& path) const {
408  return _Get<bool>(Key::Visible(path));
409  }
410  VtValue& GetWidths(SdfPath const& path) const {
411  return _Get<VtValue>(Key::Widths(path));
412  }
413  VtValue& GetNormals(SdfPath const& path) const {
414  return _Get<VtValue>(Key::Normals(path));
415  }
416  VtValue& GetPrimvar(SdfPath const& path, TfToken const& name) const {
417  return _Get<VtValue>(Key(path, name));
418  }
419  SdfPath& GetMaterialId(SdfPath const& path) const {
420  return _Get<SdfPath>(Key::MaterialId(path));
421  }
422  VtValue& GetMaterialResource(SdfPath const& path) const {
423  return _Get<VtValue>(Key::MaterialResource(path));
424  }
425  TfTokenVector& GetExtComputationSceneInputNames(SdfPath const& path) const {
426  return _Get<TfTokenVector>(Key::ExtComputationSceneInputNames(path));
427  }
428  HdExtComputationInputDescriptorVector&
429  GetExtComputationInputs(SdfPath const& path) const {
430  return _Get<HdExtComputationInputDescriptorVector>(
431  Key::ExtComputationInputs(path));
432  }
433  HdExtComputationOutputDescriptorVector&
434  GetExtComputationOutputs(SdfPath const& path) const {
435  return _Get<HdExtComputationOutputDescriptorVector>(
436  Key::ExtComputationOutputs(path));
437  }
438  HdExtComputationPrimvarDescriptorVector&
439  GetExtComputationPrimvars(SdfPath const& path) const {
440  return _Get<HdExtComputationPrimvarDescriptorVector>(
441  Key::ExtComputationPrimvars(path));
442  }
443  VtValue& GetExtComputationInput(SdfPath const& path,
444  TfToken const& name) const {
445  return _Get<VtValue>(Key(path, name));
446  }
447  std::string& GetExtComputationKernel(SdfPath const& path) const {
448  return _Get<std::string>(Key::ExtComputationKernel(path));
449  }
450  VtValue& GetCameraParam(SdfPath const& path, TfToken const& name) const {
451  return _Get<VtValue>(Key(path, name));
452  }
453  TfTokenVector& GetCameraParamNames(SdfPath const& path) const {
454  return _Get<TfTokenVector>(Key::CameraParamNames(path));
455  }
456 
457  bool FindPrimvar(SdfPath const& path, TfToken const& name, VtValue* value) const {
458  return _Find(Key(path, name), value);
459  }
460  bool FindColor(SdfPath const& path, VtValue* value) const {
461  return _Find(Key::Color(path), value);
462  }
463  bool FindOpacity(SdfPath const& path, VtValue* value) const {
464  return _Find(Key::Opacity(path), value);
465  }
466  bool FindDoubleSided(SdfPath const& path, bool* value) const {
467  return _Find(Key::DoubleSided(path), value);
468  }
469  bool FindCullStyle(SdfPath const& path, HdCullStyle* value) const {
470  return _Find(Key::CullStyle(path), value);
471  }
472  bool FindExtent(SdfPath const& path, GfRange3d* value) const {
473  return _Find(Key::Extent(path), value);
474  }
475  bool FindInstancerTransform(SdfPath const& path, GfMatrix4d* value) const {
476  return _Find(Key::InstancerTransform(path), value);
477  }
478  bool FindInstanceIndices(SdfPath const& path, VtValue* value) const {
479  return _Find(Key::InstanceIndices(path), value);
480  }
481  bool FindPoints(SdfPath const& path, VtValue* value) const {
482  return _Find(Key::Points(path), value);
483  }
484  bool FindPurpose(SdfPath const& path, TfToken* value) const {
485  return _Find(Key::Purpose(path), value);
486  }
487  bool FindPrimvars(SdfPath const& path, HdPrimvarDescriptorVector* value) const {
488  return _Find(Key::Primvars(path), value);
489  }
490  bool FindTopology(SdfPath const& path, VtValue* value) const {
491  return _Find(Key::Topology(path), value);
492  }
493  bool FindTransform(SdfPath const& path, GfMatrix4d* value) const {
494  return _Find(Key::Transform(path), value);
495  }
496  bool FindVisible(SdfPath const& path, bool* value) const {
497  return _Find(Key::Visible(path), value);
498  }
499  bool FindWidths(SdfPath const& path, VtValue* value) const {
500  return _Find(Key::Widths(path), value);
501  }
502  bool FindNormals(SdfPath const& path, VtValue* value) const {
503  return _Find(Key::Normals(path), value);
504  }
505  bool FindMaterialId(SdfPath const& path, SdfPath* value) const {
506  return _Find(Key::MaterialId(path), value);
507  }
508  bool FindMaterialResource(SdfPath const& path, VtValue* value) const {
509  return _Find(Key::MaterialResource(path), value);
510  }
511  bool FindExtComputationSceneInputNames(SdfPath const& path,
512  TfTokenVector* value) const {
513  return _Find(Key::ExtComputationSceneInputNames(path), value);
514  }
515  bool FindExtComputationInputs(
516  SdfPath const& path,
517  HdExtComputationInputDescriptorVector* value) const {
518  return _Find(Key::ExtComputationInputs(path), value);
519  }
520  bool FindExtComputationOutputs(
521  SdfPath const& path,
522  HdExtComputationOutputDescriptorVector* value) const {
523  return _Find(Key::ExtComputationOutputs(path), value);
524  }
525  bool FindExtComputationPrimvars(
526  SdfPath const& path,
527  HdExtComputationPrimvarDescriptorVector* value) const {
528  return _Find(Key::ExtComputationPrimvars(path), value);
529  }
530  bool FindExtComputationInput(
531  SdfPath const& path, TfToken const& name, VtValue* value) const {
532  return _Find(Key(path, name), value);
533  }
534  bool FindExtComputationKernel(SdfPath const& path, std::string* value) const {
535  return _Find(Key::ExtComputationKernel(path), value);
536  }
537  bool FindCameraParam(SdfPath const& path, TfToken const& name,
538  VtValue* value) const {
539  return _Find(Key(path, name), value);
540  }
541  bool FindCameraParamNames(SdfPath const& path, TfTokenVector* value) const {
542  return _Find(Key::CameraParamNames(path), value);
543  }
544 
545  bool ExtractColor(SdfPath const& path, VtValue* value) {
546  return _Extract(Key::Color(path), value);
547  }
548  bool ExtractOpacity(SdfPath const& path, VtValue* value) {
549  return _Extract(Key::Opacity(path), value);
550  }
551  bool ExtractDoubleSided(SdfPath const& path, bool* value) {
552  return _Extract(Key::DoubleSided(path), value);
553  }
554  bool ExtractCullStyle(SdfPath const& path, HdCullStyle* value) {
555  return _Extract(Key::CullStyle(path), value);
556  }
557  bool ExtractExtent(SdfPath const& path, GfRange3d* value) {
558  return _Extract(Key::Extent(path), value);
559  }
560  bool ExtractInstancerTransform(SdfPath const& path, GfMatrix4d* value) {
561  return _Extract(Key::InstancerTransform(path), value);
562  }
563  bool ExtractInstanceIndices(SdfPath const& path, VtValue* value) {
564  return _Extract(Key::InstanceIndices(path), value);
565  }
566  bool ExtractPoints(SdfPath const& path, VtValue* value) {
567  return _Extract(Key::Points(path), value);
568  }
569  bool ExtractPurpose(SdfPath const& path, TfToken* value) {
570  return _Extract(Key::Purpose(path), value);
571  }
572  bool ExtractPrimvars(SdfPath const& path, HdPrimvarDescriptorVector* value) {
573  return _Extract(Key::Primvars(path), value);
574  }
575  bool ExtractTopology(SdfPath const& path, VtValue* value) {
576  return _Extract(Key::Topology(path), value);
577  }
578  bool ExtractTransform(SdfPath const& path, GfMatrix4d* value) {
579  return _Extract(Key::Transform(path), value);
580  }
581  bool ExtractVisible(SdfPath const& path, bool* value) {
582  return _Extract(Key::Visible(path), value);
583  }
584  bool ExtractWidths(SdfPath const& path, VtValue* value) {
585  return _Extract(Key::Widths(path), value);
586  }
587  bool ExtractNormals(SdfPath const& path, VtValue* value) {
588  return _Extract(Key::Normals(path), value);
589  }
590  bool ExtractMaterialId(SdfPath const& path, SdfPath* value) {
591  return _Extract(Key::MaterialId(path), value);
592  }
593  bool ExtractMaterialResource(SdfPath const& path, VtValue* value) {
594  return _Extract(Key::MaterialResource(path), value);
595  }
596  bool ExtractPrimvar(SdfPath const& path, TfToken const& name, VtValue* value) {
597  return _Extract(Key(path, name), value);
598  }
599  bool ExtractExtComputationSceneInputNames(SdfPath const& path,
600  TfTokenVector* value) {
601  return _Extract(Key::ExtComputationSceneInputNames(path), value);
602  }
603  bool ExtractExtComputationInputs(
604  SdfPath const& path,
605  HdExtComputationInputDescriptorVector* value) {
606  return _Extract(Key::ExtComputationInputs(path), value);
607  }
608  bool ExtractExtComputationOutputs(
609  SdfPath const& path,
610  HdExtComputationOutputDescriptorVector* value) {
611  return _Extract(Key::ExtComputationOutputs(path), value);
612  }
613  bool ExtractExtComputationPrimvars(
614  SdfPath const& path,
615  HdExtComputationPrimvarDescriptorVector* value) {
616  return _Extract(Key::ExtComputationPrimvars(path), value);
617  }
618  bool ExtractExtComputationInput(SdfPath const& path, TfToken const& name,
619  VtValue* value) {
620  return _Extract(Key(path, name), value);
621  }
622  bool ExtractExtComputationKernel(SdfPath const& path, std::string* value) {
623  return _Extract(Key::ExtComputationKernel(path), value);
624  }
625  bool ExtractCameraParam(SdfPath const& path, TfToken const& name,
626  VtValue* value) {
627  return _Extract(Key(path, name), value);
628  }
629  // Skip adding ExtractCameraParamNames as we don't expose scene delegate
630  // functionality to query all available parameters on a camera.
631 
634  {
635  _GarbageCollect(_boolCache);
636  _GarbageCollect(_tokenCache);
637  _GarbageCollect(_tokenVectorCache);
638  _GarbageCollect(_rangeCache);
639  _GarbageCollect(_cullStyleCache);
640  _GarbageCollect(_matrixCache);
641  _GarbageCollect(_vec4Cache);
642  _GarbageCollect(_valueCache);
643  _GarbageCollect(_pviCache);
644  _GarbageCollect(_sdfPathCache);
645  // XXX: shader type caches, shader API will be deprecated soon
646  _GarbageCollect(_stringCache);
647  _GarbageCollect(_extComputationInputsCache);
648  _GarbageCollect(_extComputationOutputsCache);
649  _GarbageCollect(_extComputationPrimvarsCache);
650  }
651 
652 private:
653  bool _locked;
654 
655  // visible, doubleSided
656  typedef _TypedCache<bool> _BoolCache;
657  mutable _BoolCache _boolCache;
658 
659  // purpose
660  typedef _TypedCache<TfToken> _TokenCache;
661  mutable _TokenCache _tokenCache;
662 
663  // extComputationSceneInputNames
664  typedef _TypedCache<TfTokenVector> _TokenVectorCache;
665  mutable _TokenVectorCache _tokenVectorCache;
666 
667  // extent
668  typedef _TypedCache<GfRange3d> _RangeCache;
669  mutable _RangeCache _rangeCache;
670 
671  // cullstyle
672  typedef _TypedCache<HdCullStyle> _CullStyleCache;
673  mutable _CullStyleCache _cullStyleCache;
674 
675  // transform
676  typedef _TypedCache<GfMatrix4d> _MatrixCache;
677  mutable _MatrixCache _matrixCache;
678 
679  // color (will be VtValue)
680  typedef _TypedCache<GfVec4f> _Vec4Cache;
681  mutable _Vec4Cache _vec4Cache;
682 
683  // sdfPath
684  typedef _TypedCache<SdfPath> _SdfPathCache;
685  mutable _SdfPathCache _sdfPathCache;
686 
687  // primvars, topology, materialResources, extCompInputs
688  typedef _TypedCache<VtValue> _ValueCache;
689  mutable _ValueCache _valueCache;
690 
691  typedef _TypedCache<HdPrimvarDescriptorVector> _PviCache;
692  mutable _PviCache _pviCache;
693 
694  typedef _TypedCache<std::string> _StringCache;
695  mutable _StringCache _stringCache;
696 
697  typedef _TypedCache<HdExtComputationInputDescriptorVector>
698  _ExtComputationInputsCache;
699  mutable _ExtComputationInputsCache _extComputationInputsCache;
700 
701  typedef _TypedCache<HdExtComputationOutputDescriptorVector>
702  _ExtComputationOutputsCache;
703  mutable _ExtComputationOutputsCache _extComputationOutputsCache;
704 
705  typedef _TypedCache<HdExtComputationPrimvarDescriptorVector>
706  _ExtComputationPrimvarsCache;
707  mutable _ExtComputationPrimvarsCache _extComputationPrimvarsCache;
708 
709  void _GetCache(_BoolCache **cache) const {
710  *cache = &_boolCache;
711  }
712  void _GetCache(_TokenCache **cache) const {
713  *cache = &_tokenCache;
714  }
715  void _GetCache(_TokenVectorCache **cache) const {
716  *cache = &_tokenVectorCache;
717  }
718  void _GetCache(_RangeCache **cache) const {
719  *cache = &_rangeCache;
720  }
721  void _GetCache(_CullStyleCache **cache) const {
722  *cache = &_cullStyleCache;
723  }
724  void _GetCache(_MatrixCache **cache) const {
725  *cache = &_matrixCache;
726  }
727  void _GetCache(_Vec4Cache **cache) const {
728  *cache = &_vec4Cache;
729  }
730  void _GetCache(_ValueCache **cache) const {
731  *cache = &_valueCache;
732  }
733  void _GetCache(_PviCache **cache) const {
734  *cache = &_pviCache;
735  }
736  void _GetCache(_SdfPathCache **cache) const {
737  *cache = &_sdfPathCache;
738  }
739  void _GetCache(_StringCache **cache) const {
740  *cache = &_stringCache;
741  }
742  void _GetCache(_ExtComputationInputsCache **cache) const {
743  *cache = &_extComputationInputsCache;
744  }
745  void _GetCache(_ExtComputationOutputsCache **cache) const {
746  *cache = &_extComputationOutputsCache;
747  }
748  void _GetCache(_ExtComputationPrimvarsCache **cache) const {
749  *cache = &_extComputationPrimvarsCache;
750  }
751 };
752 
753 
754 PXR_NAMESPACE_CLOSE_SCOPE
755 
756 #endif // PXR_USD_IMAGING_USD_IMAGING_VALUE_CACHE_H
Basic type: 3-dimensional floating point range.
Definition: range3d.h:64
A heterogeneous value container without type erasure.
Definition: valueCache.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
void Clear(SdfPath const &path)
Clear all data associated with a specific path.
Definition: valueCache.h:300
#define TF_FOR_ALL(iter, c)
Macro for iterating over a container.
Definition: iterator.h:390
void swap(UsdStageLoadRules &l, UsdStageLoadRules &r)
Swap the contents of rules l and r.
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
#define TF_VERIFY(cond, format,...)
Checks a condition and reports an error if it evaluates false.
Definition: diagnostic.h:289
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:433
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
void GarbageCollect()
Remove any items from the cache that are marked for defered deletion.
Definition: valueCache.h:633
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182