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