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