HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
changeTracker.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_CHANGE_TRACKER_H
25 #define PXR_IMAGING_HD_CHANGE_TRACKER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
31 #include "pxr/imaging/hd/types.h"
32 #include "pxr/usd/sdf/path.h"
33 #include "pxr/base/tf/hashmap.h"
34 
35 #include <tbb/concurrent_hash_map.h>
36 #include <atomic>
37 
39 
41 
42 /// \class HdChangeTracker
43 ///
44 /// Tracks changes from the HdSceneDelegate, providing invalidation cues to the
45 /// render engine.
46 ///
47 /// Changes flagged here are accumulated until the next time resource associated
48 /// with the change is required, at which point the resource is updated and the
49 /// flag is cleared.
50 ///
52 {
53 public:
54 
55  // Common dirty bits for Rprims
56  // XXX: Move this to HdRprim
58  Clean = 0,
59  InitRepr = 1 << 0,
60  Varying = 1 << 1,
62  DirtyPrimID = 1 << 2,
63  DirtyExtent = 1 << 3,
65  DirtyPoints = 1 << 5,
66  DirtyPrimvar = 1 << 6,
67  DirtyMaterialId = 1 << 7,
68  DirtyTopology = 1 << 8,
69  DirtyTransform = 1 << 9,
70  DirtyVisibility = 1 << 10,
71  DirtyNormals = 1 << 11,
72  DirtyDoubleSided = 1 << 12,
73  DirtyCullStyle = 1 << 13,
74  DirtySubdivTags = 1 << 14,
75  DirtyWidths = 1 << 15,
76  DirtyInstancer = 1 << 16,
77  DirtyInstanceIndex = 1 << 17,
78  DirtyRepr = 1 << 18,
79  DirtyRenderTag = 1 << 19,
81  DirtyCategories = 1 << 21,
82  DirtyVolumeField = 1 << 22,
83  AllSceneDirtyBits = ((1<<23) - 1),
84 
85  NewRepr = 1 << 23,
86 
87  CustomBitsBegin = 1 << 24,
88  CustomBitsEnd = 1 << 30,
89  CustomBitsMask = 0x7f << 24,
90  };
91 
92  // InstancerDirtybits are a subset of rprim dirty bits right now:
93  // DirtyPrimvar, DirtyTransform, DirtyInstanceIndex, DirtyInstancer.
94 
95  // Dirty bits for Tasks
96  // XXX: Move this to HdTask
98  DirtyParams = 1 << 2,
99  DirtyCollection = 1 << 3,
100  DirtyRenderTags = 1 << 4,
101  };
102 
103  HD_API
104  HdChangeTracker();
105  HD_API
106  virtual ~HdChangeTracker();
107 
108  // ---------------------------------------------------------------------- //
109  /// \name Rprim Object Tracking
110  /// @{
111  // ---------------------------------------------------------------------- //
112 
113  /// Start tracking Rprim with the given \p id.
114  HD_API
115  void RprimInserted(SdfPath const& id, HdDirtyBits initialDirtyState);
116 
117  /// Stop tracking Rprim with the given \p id.
118  HD_API
119  void RprimRemoved(SdfPath const& id);
120 
121  // ---------------------------------------------------------------------- //
122  /// @}
123  /// \name Rprim State Tracking
124  /// @{
125  // ---------------------------------------------------------------------- //
126 
127  /// Returns the dirty bits for the rprim with \p id.
128  HD_API
129  HdDirtyBits GetRprimDirtyBits(SdfPath const& id) const;
130 
131  /// Flag the Rprim with the given \p id as being dirty. Multiple calls with
132  /// different dirty bits accumulate.
133  HD_API
134  void MarkRprimDirty(SdfPath const& id, HdDirtyBits bits=AllDirty);
135 
136  /// Clear the dirty flags for an HdRprim. if inSync is true, set OutOfSync
137  /// flag to notify dirtyList will discover the prim to sync the residual
138  /// data for new repr.
139  HD_API
140  void MarkRprimClean(SdfPath const& id, HdDirtyBits newBits=Clean);
141 
142  /// Mark the primvar for the rprim with \p id as being dirty.
143  HD_API
144  void MarkPrimvarDirty(SdfPath const& id, TfToken const& name);
145 
146  /// Flag all the Rprim with the given \p id as being dirty. Multiple calls
147  /// with different dirty bits accumulate.
148  /// Doesn't touch varying state.
149  HD_API
150  void MarkAllRprimsDirty(HdDirtyBits bits);
151 
152  /// Clear Varying bit of all prims.
153  ///
154  /// The idea is that from frame to frame (update iteration), the set of
155  /// dirty rprims and their dirty bits do not change; that is, the same
156  /// rprims get dirtied with the same dirty bits.. The change tracker can
157  /// leverage this help build a stable dirty list and reduce the
158  /// overall cost of an update iteration.
159  HD_API
160  void ResetVaryingState();
161 
162  /// Reset the varying state on one Rprim
163  /// This is done for Rprims, where we choose not to clean them
164  /// (due to state like invisibility).
165  HD_API
166  void ResetRprimVaryingState(SdfPath const& id);
167 
168 
169  // ---------------------------------------------------------------------- //
170 
171  /// Returns true if the rprim identified by \p id has any dirty flags set.
172  HD_API
173  bool IsRprimDirty(SdfPath const& id);
174 
175  /// Returns true if the rprim identified by \p id has a dirty extent.
176  HD_API
177  bool IsExtentDirty(SdfPath const& id);
178 
179  /// Returns true if the rprim identified by \p id has a dirty display style.
180  HD_API
181  bool IsDisplayStyleDirty(SdfPath const& id);
182 
183  /// Returns true if the rprim identified by \p id with primvar \p name is
184  /// dirty.
185  HD_API
186  bool IsPrimvarDirty(SdfPath const& id, TfToken const& name);
187 
188  /// Returns true if the rprim identified by \p id has any dirty primvars.
189  HD_API
190  bool IsAnyPrimvarDirty(SdfPath const& id);
191 
192  /// Returns true if the rprim identified by \p id has a dirty topology.
193  HD_API
194  bool IsTopologyDirty(SdfPath const& id);
195 
196  /// Returns true if the rprim identified by \p id has dirty doubleSided state.
197  HD_API
198  bool IsDoubleSidedDirty(SdfPath const& id);
199 
200  /// Returns true if the rprim identified by \p id has dirty cullstyle.
201  HD_API
202  bool IsCullStyleDirty(SdfPath const& id);
203 
204  /// Returns true if the rprim identified by \p id has a dirty subdiv tags.
205  HD_API
206  bool IsSubdivTagsDirty(SdfPath const& id);
207 
208  /// Returns true if the rprim identified by \p id has a dirty transform.
209  HD_API
210  bool IsTransformDirty(SdfPath const& id);
211 
212  /// Returns true if the rprim identified by \p id has dirty visibility.
213  HD_API
214  bool IsVisibilityDirty(SdfPath const& id);
215 
216  /// Returns true if the rprim identified by \p id has a dirty primID.
217  HD_API
218  bool IsPrimIdDirty(SdfPath const& id);
219 
220  /// Returns true if the dirtyBits has any flags set other than the varying
221  /// flag.
222  static bool IsDirty(HdDirtyBits dirtyBits) {
223  return (dirtyBits & AllDirty) != 0;
224  }
225 
226  /// Returns true if the dirtyBits has no flags set except the varying flag.
227  static bool IsClean(HdDirtyBits dirtyBits) {
228  return (dirtyBits & AllDirty) == 0;
229  }
230 
231  /// Returns true if the varying flag is set.
232  static bool IsVarying(HdDirtyBits dirtyBits) {
233  return (dirtyBits & Varying) != 0;
234  }
235 
236  /// Returns true if the dirtyBits has a dirty extent. id is for perflog.
237  HD_API
238  static bool IsExtentDirty(HdDirtyBits dirtyBits, SdfPath const& id);
239 
240  /// Returns true if the dirtyBits has a dirty display style. id is for perflog.
241  HD_API
242  static bool IsDisplayStyleDirty(HdDirtyBits dirtyBits, SdfPath const& id);
243 
244  /// Returns true if the dirtyBits has a dirty subdiv tags. id is for perflog.
245  HD_API
246  static bool IsSubdivTagsDirty(HdDirtyBits dirtyBits, SdfPath const& id);
247 
248  /// Returns true if the dirtyBits has a dirty primvar \p name.
249  /// id is for perflog.
250  HD_API
251  static bool IsPrimvarDirty(HdDirtyBits dirtyBits, SdfPath const& id,
252  TfToken const& name);
253 
254  /// Returns true if the dirtyBits has any dirty primvars.
255  /// id is for perflog.
256  HD_API
257  static bool IsAnyPrimvarDirty(HdDirtyBits dirtyBits, SdfPath const& id);
258 
259  /// Returns true if the dirtyBits has a dirty topology. id is for perflog.
260  HD_API
261  static bool IsTopologyDirty(HdDirtyBits dirtyBits, SdfPath const& id);
262 
263  /// Returns true if the dirtyBits has dirty doubleSided state. id is for perflog.
264  HD_API
265  static bool IsDoubleSidedDirty(HdDirtyBits dirtyBits, SdfPath const& id);
266 
267  /// Returns true if the dirtyBits has dirty cullstyle. id is for perflog.
268  HD_API
269  static bool IsCullStyleDirty(HdDirtyBits dirtyBits, SdfPath const& id);
270 
271  /// Returns true if the dirtyBits has a dirty transform. id is for perflog.
272  HD_API
273  static bool IsTransformDirty(HdDirtyBits dirtyBits, SdfPath const& id);
274 
275  /// Returns true if the dirtyBits has dirty visibility. id is for perflog.
276  HD_API
277  static bool IsVisibilityDirty(HdDirtyBits dirtyBits, SdfPath const& id);
278 
279  /// Returns true if the dirtyBits has a dirty primID. id is for perflog.
280  HD_API
281  static bool IsPrimIdDirty(HdDirtyBits dirtyBits, SdfPath const& id);
282 
283  /// Returns true if the dirtyBits has a dirty instancer. id is for perflog.
284  HD_API
285  static bool IsInstancerDirty(HdDirtyBits dirtyBits, SdfPath const& id);
286 
287  /// Returns true if the dirtyBits has a dirty instance index. id is for perflog.
288  HD_API
289  static bool IsInstanceIndexDirty(HdDirtyBits dirtyBits, SdfPath const& id);
290 
291  HD_API
292  static bool IsReprDirty(HdDirtyBits dirtyBits, SdfPath const &id);
293 
294  // ---------------------------------------------------------------------- //
295 
296  /// Set the primvar dirty flag to \p dirtyBits.
297  HD_API
298  static void MarkPrimvarDirty(HdDirtyBits *dirtyBits, TfToken const &name);
299 
300  // ---------------------------------------------------------------------- //
301  /// @}
302  /// \name Task Object Tracking
303  /// @{
304  // ---------------------------------------------------------------------- //
305 
306  /// Start tracking Task with the given \p id.
307  HD_API
308  void TaskInserted(SdfPath const& id, HdDirtyBits initialDirtyState);
309 
310  /// Stop tracking Task with the given \p id.
311  HD_API
312  void TaskRemoved(SdfPath const& id);
313 
314  /// Set the dirty flags to \p bits.
315  HD_API
316  void MarkTaskDirty(SdfPath const& id, HdDirtyBits bits=AllDirty);
317 
318  /// Get the dirty bits for Task with the given \p id.
319  HD_API
321 
322  /// Set the dirty flags to \p newBits.
323  HD_API
324  void MarkTaskClean(SdfPath const& id, HdDirtyBits newBits=Clean);
325 
326  /// Retrieve the current version number of the rprim render tag set
327  /// XXX Rename to GetRprimRenderTagVersion
328  HD_API
329  unsigned GetRenderTagVersion() const;
330 
331  /// Retrieve the current version number of the task's render tags opinion.
332  HD_API
333  unsigned GetTaskRenderTagsVersion() const;
334 
335  // ---------------------------------------------------------------------- //
336  /// @}
337  /// \name Instancer State Tracking
338  /// @{
339  // ---------------------------------------------------------------------- //
340 
341  /// Start tracking Instancer with the given \p id.
342  HD_API
343  void InstancerInserted(SdfPath const& id, HdDirtyBits initialDirtyState);
344 
345  /// Stop tracking Instancer with the given \p id.
346  HD_API
347  void InstancerRemoved(SdfPath const& id);
348 
349  /// Returns the dirty bits for the instancer with \p id.
350  HD_API
352 
353  /// Flag the Instancer with the given \p id as being dirty. Multiple calls
354  /// with different dirty bits accumulate.
355  HD_API
356  void MarkInstancerDirty(SdfPath const& id, HdDirtyBits bits=AllDirty);
357 
358  /// Clean the specified dirty bits for the instancer with \p id.
359  HD_API
360  void MarkInstancerClean(SdfPath const& id, HdDirtyBits newBits=Clean);
361 
362  /// Insert a dependency between \p rprimId and parent instancer
363  /// \p instancerId. Changes to the latter mark the former with
364  /// DirtyInstancer.
365  HD_API
366  void AddInstancerRprimDependency(SdfPath const& instancerId,
367  SdfPath const& rprimId);
368 
369  /// Remove a dependency between \p rprimId and parent instancer
370  /// \p instancerId.
371  HD_API
372  void RemoveInstancerRprimDependency(SdfPath const& instancerId,
373  SdfPath const& rprimId);
374 
375  /// Insert a dependency between \p instancerId and parent instancer
376  /// \p parentInstancerId. Changes to the latter mark the former with
377  /// DirtyInstancer.
378  HD_API
379  void AddInstancerInstancerDependency(SdfPath const& parentInstancerId,
380  SdfPath const& instancerId);
381 
382  /// Remove a dependency between \p instancerId and parent instancer
383  /// \p parentInstancerId.
384  HD_API
385  void RemoveInstancerInstancerDependency(SdfPath const& parentInstancerId,
386  SdfPath const& instancerId);
387 
388  // ---------------------------------------------------------------------- //
389  /// @}
390  /// \name Sprim (scene state prim: camera, light, ...) state Tracking
391  /// @{
392  // ---------------------------------------------------------------------- //
393 
394  /// Start tracking sprim with the given \p id.
395  HD_API
396  void SprimInserted(SdfPath const& id, HdDirtyBits initialDirtyState);
397 
398  /// Stop tracking sprim with the given \p id.
399  HD_API
400  void SprimRemoved(SdfPath const& id);
401 
402  /// Get the dirty bits for sprim with the given \p id.
403  HD_API
405 
406  /// Set the dirty flags to \p bits.
407  HD_API
408  void MarkSprimDirty(SdfPath const& id, HdDirtyBits bits);
409 
410  /// Set the dirty flags to \p newBits.
411  HD_API
412  void MarkSprimClean(SdfPath const& id, HdDirtyBits newBits=Clean);
413 
414  /// Insert a dependency between \p sprimId and parent instancer
415  /// \p instancerId. Changes to the latter mark the former with
416  /// DirtyInstancer.
417  HD_API
418  void AddInstancerSprimDependency(SdfPath const& instancerId,
419  SdfPath const& sprimId);
420 
421  /// Remove a dependency between \p sprimId and parent instancer
422  /// \p instancerId.
423  HD_API
424  void RemoveInstancerSprimDependency(SdfPath const& instancerId,
425  SdfPath const& sprimId);
426 
427  /// Insert a dependency between \p sprimId and parent sprim
428  /// \p parentSprimId.
429  HD_API
430  void AddSprimSprimDependency(SdfPath const& parentSprimId,
431  SdfPath const& sprimId);
432 
433  /// Remove a dependency between \p sprimId and parent sprim
434  /// \p parentSprimId.
435  HD_API
436  void RemoveSprimSprimDependency(SdfPath const& parentSprimId,
437  SdfPath const& sprimId);
438 
439  /// Remove all dependencies involving \p sprimId as a parent or child.
440  HD_API
441  void RemoveSprimFromSprimSprimDependencies(SdfPath const& sprimId);
442 
443  // ---------------------------------------------------------------------- //
444  /// @}
445  /// \name Bprim (buffer prim: texture, buffer, ...) state Tracking
446  /// @{
447  // ---------------------------------------------------------------------- //
448 
449  /// Start tracking bprim with the given \p id.
450  HD_API
451  void BprimInserted(SdfPath const& id, HdDirtyBits initialDirtyState);
452 
453  /// Stop tracking bprim with the given \p id.
454  HD_API
455  void BprimRemoved(SdfPath const& id);
456 
457  /// Get the dirty bits for bprim with the given \p id.
458  HD_API
460 
461  /// Set the dirty flags to \p bits.
462  HD_API
463  void MarkBprimDirty(SdfPath const& id, HdDirtyBits bits);
464 
465  /// Set the dirty flags to \p newBits.
466  HD_API
467  void MarkBprimClean(SdfPath const& id, HdDirtyBits newBits=Clean);
468 
469  // ---------------------------------------------------------------------- //
470  /// @}
471  /// \name RprimCollection Tracking
472  /// @{
473  // ---------------------------------------------------------------------- //
474 
475  /// Adds a named collection for tracking.
476  HD_API
477  void AddCollection(TfToken const& collectionName);
478 
479  /// Marks a named collection as being dirty, this bumps the version of the
480  /// collection.
481  HD_API
482  void MarkCollectionDirty(TfToken const& collectionName);
483 
484  /// Returns the current version of the named collection.
485  HD_API
486  unsigned GetCollectionVersion(TfToken const& collectionName) const;
487 
488  /// Returns the number of changes to visibility. This is intended to be used
489  /// to detect when visibility has changed for *any* Rprim.
490  HD_API
491  unsigned GetVisibilityChangeCount() const;
492 
493  /// Returns the number of changes to instance index. This is intended to be used
494  /// to detect when instance indices changed for *any* Rprim. Use in with
495  /// GetInstancerIndexVersion() to detect all changes to instance indices.
496  HD_API
497  unsigned GetInstanceIndicesChangeCount() const;
498 
499  /// Returns the current version of varying state. This is used to refresh
500  /// cached DirtyLists
501  unsigned GetVaryingStateVersion() const {
502  return _varyingStateVersion;
503  }
504 
505  // ---------------------------------------------------------------------- //
506  /// @}
507  /// \name Render Index Versioning
508  /// @{
509  // ---------------------------------------------------------------------- //
510 
511  /// Returns the current version of the Render Index's RPrim set.
512  /// This version number changes when Rprims are inserted or removed
513  /// from the render index. Invalidating any cached gather operations.
514  unsigned GetRprimIndexVersion() const {
515  return _rprimIndexVersion;
516  }
517 
518  /// Returns the current version of the Render Index's SPrim set.
519  /// This version number changes when Sprims are inserted or removed
520  /// from the render index. Invalidating any cached gather operations.
521  unsigned GetSprimIndexVersion() const {
522  return _sprimIndexVersion;
523  }
524 
525  /// Returns the current version of the Render Index's BPrim set.
526  /// This version number changes when Bprims are inserted or removed
527  /// from the render index. Invalidating any cached gather operations.
528  unsigned GetBprimIndexVersion() const {
529  return _bprimIndexVersion;
530  }
531 
532  /// Returns the current version of the Render Index's Instancer set.
533  /// This version number changes when Instancers are inserted or removed
534  /// from the render index. Invalidating any cached gather operations.
535  unsigned GetInstancerIndexVersion() const {
536  return _instancerIndexVersion;
537  }
538 
539 
540  /// Returns the current version of the scene state.
541  /// This version number changes whenever any prims are inserted, removed
542  /// or marked dirty.
543  /// The use case is to detect that nothing has changed, so the Sync
544  /// phase can be avoided.
545  unsigned GetSceneStateVersion() const {
546  return _sceneStateVersion;
547  }
548 
549  // ---------------------------------------------------------------------- //
550  /// @}
551  /// \name General state tracking
552  /// @{
553  // ---------------------------------------------------------------------- //
554 
555  /// Adds a named state for tracking.
556  HD_API
557  void AddState(TfToken const& name);
558 
559  /// Marks a named state as being dirty., this bumps the version of the
560  /// state.
561  HD_API
562  void MarkStateDirty(TfToken const& name);
563 
564  /// Returns the current version of the named state.
565  HD_API
566  unsigned GetStateVersion(TfToken const &name) const;
567 
568  // ---------------------------------------------------------------------- //
569  /// @}
570  /// \name Debug
571  /// @{
572  // ---------------------------------------------------------------------- //
573  HD_API
574  static std::string StringifyDirtyBits(HdDirtyBits dirtyBits);
575 
576  HD_API
577  static void DumpDirtyBits(HdDirtyBits dirtyBits);
578 
579  /// @}
580 
581 private:
582 
583  // Don't allow copies
584  HdChangeTracker(const HdChangeTracker &) = delete;
585  HdChangeTracker &operator=(const HdChangeTracker &) = delete;
586 
587 
588  static void _LogCacheAccess(TfToken const& cacheName,
589  SdfPath const& id, bool hit);
590 
592  typedef TfHashMap<TfToken, int, TfToken::HashFunctor> _CollectionStateMap;
594 
595  struct _PathHashCompare {
596  static bool equal(const SdfPath& a, const SdfPath& b)
597  { return a == b; }
598 
599  static size_t hash(const SdfPath& path)
600  { return hash_value(path); }
601  };
602  typedef tbb::concurrent_hash_map<SdfPath, SdfPathSet, _PathHashCompare>
603  _DependencyMap;
604 
605  // Core dirty state.
606  _IDStateMap _rprimState;
607  _IDStateMap _instancerState;
608  _IDStateMap _taskState;
609  _IDStateMap _sprimState;
610  _IDStateMap _bprimState;
611  _GeneralStateMap _generalState;
612 
613  // Collection versions / state.
614  _CollectionStateMap _collectionState;
615 
616  // Provides reverse-association between instancers and the child
617  // instancers/prims that use them.
618  _DependencyMap _instancerRprimDependencies;
619  _DependencyMap _instancerSprimDependencies;
620  _DependencyMap _instancerInstancerDependencies;
621 
622  // Provides forward and reverse-association between sprims and the child
623  // sprims that reference them. For example, a light prim (child) who needs
624  // to know when its light filter (parent) is modified.
625  // Maps parent sprim to child sprim.
626  _DependencyMap _sprimSprimTargetDependencies;
627  // Maps child sprim to parent sprim.
628  _DependencyMap _sprimSprimSourceDependencies;
629 
630  // Dependency map helpers
631  void _AddDependency(_DependencyMap &depMap,
632  SdfPath const& parent, SdfPath const& child);
633  void _RemoveDependency(_DependencyMap &depMap,
634  SdfPath const& parent, SdfPath const& child);
635 
636  // Typically the Rprims that get marked dirty per update iteration end up
637  // being a stable set of objects; to leverage this fact, we require the
638  // delegate notify the change tracker when that state changes, which bumps
639  // the varyingStateVersion, which triggers downstream invalidation.
640  unsigned _varyingStateVersion;
641 
642  // Tracks changes (insertions/removals) of prims in the render index.
643  // This is used to indicating that cached gather operations need to be
644  // re-evaluated, such as dirty lists or batch building.
645  unsigned _rprimIndexVersion;
646  unsigned _sprimIndexVersion;
647  unsigned _bprimIndexVersion;
648  unsigned _instancerIndexVersion;
649 
650  // The following tracks any changes of state. As a result it is very broad.
651  // The use case to detect, when no changes have been made, as to
652  // avoid the need to sync or reset progressive renderers.
653  unsigned _sceneStateVersion;
654 
655  // Used to detect that visibility changed somewhere in the render index.
656  unsigned _visChangeCount;
657 
658  // Used to detect that instance indices changed somewhere in the render index.
659  unsigned _instanceIndicesChangeCount;
660 
661  // Used to detect changes to the render tag opinion of rprims.
662  unsigned _rprimRenderTagVersion;
663 
664  // Used to detect changes to the render tags opinion of tasks.
665  unsigned _taskRenderTagsVersion;
666 
667  // Allow HdRenderIndex to provide a scene index to forward dirty
668  // information. This is necessary to accommodate legacy HdSceneDelegate
669  // based applications that rely on the HdChangeTracker for invalidating
670  // state on Hydra prims.
671  friend class HdRenderIndex;
672  // Does not take ownership. The HdRenderIndex manages the lifetime of this
673  // scene index.
674  HdRetainedSceneIndex * _emulationSceneIndex;
675  void _SetTargetSceneIndex(HdRetainedSceneIndex *emulationSceneIndex);
676 
677  // Private methods which implement the behaviors of their public
678  // equivalents. The public versions check to see if legacy emulation is
679  // active. If so, they dirty the HdRetainedSceneIndex member instead
680  // of directly acting. If legacy render delegate emulation is active, these
681  // will eventually make their way back to the private methods via
682  // HdSceneIndexAdapterSceneDelegate. This prevents dirtying cycles while
683  // allowing single HdRenderIndex/HdChangeTracker instances to be used for
684  // both ends of emulation.
686  void _MarkRprimDirty(SdfPath const& id, HdDirtyBits bits=AllDirty);
687  void _MarkSprimDirty(SdfPath const& id, HdDirtyBits bits=AllDirty);
688  void _MarkBprimDirty(SdfPath const& id, HdDirtyBits bits=AllDirty);
689  void _MarkInstancerDirty(SdfPath const& id, HdDirtyBits bits=AllDirty);
690 };
691 
692 
694 
695 #endif //PXR_IMAGING_HD_CHANGE_TRACKER_H
HD_API void AddInstancerRprimDependency(SdfPath const &instancerId, SdfPath const &rprimId)
HD_API void RprimRemoved(SdfPath const &id)
Stop tracking Rprim with the given id.
HD_API unsigned GetTaskRenderTagsVersion() const
Retrieve the current version number of the task's render tags opinion.
HD_API void RemoveSprimFromSprimSprimDependencies(SdfPath const &sprimId)
Remove all dependencies involving sprimId as a parent or child.
HD_API bool IsSubdivTagsDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty subdiv tags.
HD_API bool IsExtentDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty extent.
HD_API void SprimRemoved(SdfPath const &id)
Stop tracking sprim with the given id.
HD_API void RemoveInstancerInstancerDependency(SdfPath const &parentInstancerId, SdfPath const &instancerId)
HD_API void RemoveInstancerSprimDependency(SdfPath const &instancerId, SdfPath const &sprimId)
HD_API void ResetRprimVaryingState(SdfPath const &id)
virtual HD_API ~HdChangeTracker()
uint32_t HdDirtyBits
Definition: types.h:158
static HD_API bool IsInstanceIndexDirty(HdDirtyBits dirtyBits, SdfPath const &id)
Returns true if the dirtyBits has a dirty instance index. id is for perflog.
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static bool IsDirty(HdDirtyBits dirtyBits)
unsigned GetSceneStateVersion() const
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
#define HD_API
Definition: api.h:40
HD_API void MarkTaskClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Set the dirty flags to newBits.
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
Definition: ImathFun.h:105
HD_API bool IsPrimIdDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty primID.
HD_API HdDirtyBits GetInstancerDirtyBits(SdfPath const &id)
Returns the dirty bits for the instancer with id.
HD_API unsigned GetVisibilityChangeCount() const
HD_API void MarkInstancerClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Clean the specified dirty bits for the instancer with id.
HD_API void MarkAllRprimsDirty(HdDirtyBits bits)
HD_API void BprimRemoved(SdfPath const &id)
Stop tracking bprim with the given id.
HD_API void MarkCollectionDirty(TfToken const &collectionName)
HD_API bool IsTransformDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty transform.
static bool IsClean(HdDirtyBits dirtyBits)
Returns true if the dirtyBits has no flags set except the varying flag.
HD_API void RprimInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking Rprim with the given id.
HD_API unsigned GetStateVersion(TfToken const &name) const
Returns the current version of the named state.
HD_API void MarkSprimDirty(SdfPath const &id, HdDirtyBits bits)
Set the dirty flags to bits.
HD_API HdChangeTracker()
HD_API void MarkPrimvarDirty(SdfPath const &id, TfToken const &name)
Mark the primvar for the rprim with id as being dirty.
HD_API void MarkTaskDirty(SdfPath const &id, HdDirtyBits bits=AllDirty)
Set the dirty flags to bits.
HD_API HdDirtyBits GetBprimDirtyBits(SdfPath const &id)
Get the dirty bits for bprim with the given id.
Definition: token.h:87
HD_API void BprimInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking bprim with the given id.
HD_API bool IsPrimvarDirty(SdfPath const &id, TfToken const &name)
HD_API bool IsRprimDirty(SdfPath const &id)
Returns true if the rprim identified by id has any dirty flags set.
HD_API void MarkBprimDirty(SdfPath const &id, HdDirtyBits bits)
Set the dirty flags to bits.
static HD_API bool IsReprDirty(HdDirtyBits dirtyBits, SdfPath const &id)
Returns the dirty bits for the rprim with id.
HD_API HdDirtyBits GetTaskDirtyBits(SdfPath const &id)
Get the dirty bits for Task with the given id.
HD_API bool IsTopologyDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty topology.
HD_API HdDirtyBits GetRprimDirtyBits(SdfPath const &id) const
Returns the dirty bits for the rprim with id.
HD_API void MarkRprimDirty(SdfPath const &id, HdDirtyBits bits=AllDirty)
HD_API void AddCollection(TfToken const &collectionName)
Adds a named collection for tracking.
HD_API void AddInstancerSprimDependency(SdfPath const &instancerId, SdfPath const &sprimId)
static bool IsVarying(HdDirtyBits dirtyBits)
Returns true if the varying flag is set.
HD_API void RemoveInstancerRprimDependency(SdfPath const &instancerId, SdfPath const &rprimId)
GLuint const GLchar * name
Definition: glcorearb.h:786
unsigned GetRprimIndexVersion() const
Definition: path.h:290
HD_API void TaskInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking Task with the given id.
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
unsigned GetVaryingStateVersion() const
HD_API void TaskRemoved(SdfPath const &id)
Stop tracking Task with the given id.
HD_API void SprimInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking sprim with the given id.
HD_API unsigned GetRenderTagVersion() const
HD_API void RemoveSprimSprimDependency(SdfPath const &parentSprimId, SdfPath const &sprimId)
static HD_API void DumpDirtyBits(HdDirtyBits dirtyBits)
unsigned GetBprimIndexVersion() const
HD_API void MarkRprimClean(SdfPath const &id, HdDirtyBits newBits=Clean)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
HD_API unsigned GetInstanceIndicesChangeCount() const
HD_API void MarkInstancerDirty(SdfPath const &id, HdDirtyBits bits=AllDirty)
HD_API void AddState(TfToken const &name)
Adds a named state for tracking.
HD_API void AddInstancerInstancerDependency(SdfPath const &parentInstancerId, SdfPath const &instancerId)
static HD_API std::string StringifyDirtyBits(HdDirtyBits dirtyBits)
HD_API void AddSprimSprimDependency(SdfPath const &parentSprimId, SdfPath const &sprimId)
unsigned GetInstancerIndexVersion() const
HD_API bool IsCullStyleDirty(SdfPath const &id)
Returns true if the rprim identified by id has dirty cullstyle.
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
HD_API HdDirtyBits GetSprimDirtyBits(SdfPath const &id)
Get the dirty bits for sprim with the given id.
static HD_API bool IsInstancerDirty(HdDirtyBits dirtyBits, SdfPath const &id)
Returns true if the dirtyBits has a dirty instancer. id is for perflog.
HD_API void MarkStateDirty(TfToken const &name)
HD_API void InstancerRemoved(SdfPath const &id)
Stop tracking Instancer with the given id.
HD_API unsigned GetCollectionVersion(TfToken const &collectionName) const
Returns the current version of the named collection.
HD_API bool IsVisibilityDirty(SdfPath const &id)
Returns true if the rprim identified by id has dirty visibility.
HD_API bool IsAnyPrimvarDirty(SdfPath const &id)
Returns true if the rprim identified by id has any dirty primvars.
HD_API void MarkBprimClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Set the dirty flags to newBits.
HD_API bool IsDisplayStyleDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty display style.
size_t hash_value(const CH_ChannelRef &ref)
HD_API void InstancerInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking Instancer with the given id.
unsigned GetSprimIndexVersion() const
HD_API void MarkSprimClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Set the dirty flags to newBits.
HD_API void ResetVaryingState()
HD_API bool IsDoubleSidedDirty(SdfPath const &id)
Returns true if the rprim identified by id has dirty doubleSided state.