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