24 #ifndef PXR_IMAGING_HD_CHANGE_TRACKER_H 25 #define PXR_IMAGING_HD_CHANGE_TRACKER_H 28 #include "pxr/imaging/hd/api.h" 29 #include "pxr/imaging/hd/version.h" 30 #include "pxr/imaging/hd/rprimCollection.h" 31 #include "pxr/imaging/hd/types.h" 32 #include "pxr/usd/sdf/path.h" 33 #include "pxr/base/tf/hashmap.h" 35 #include <tbb/concurrent_hash_map.h> 38 PXR_NAMESPACE_OPEN_SCOPE
57 enum RprimDirtyBits : HdDirtyBits {
64 DirtyDisplayStyle = 1 << 4,
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,
79 DirtyRenderTag = 1 << 19,
80 DirtyComputationPrimvarDesc = 1 << 20,
81 DirtyCategories = 1 << 21,
82 DirtyVolumeField = 1 << 22,
83 AllSceneDirtyBits = ((1<<23) - 1),
87 CustomBitsBegin = 1 << 24,
88 CustomBitsEnd = 1 << 30,
89 CustomBitsMask = 0x7f << 24,
97 enum TaskDirtyBits : HdDirtyBits {
100 DirtyParams = 1 << 2,
101 DirtyCollection = 1 << 3,
102 DirtyRenderTags = 1 << 4,
225 return (dirtyBits & AllDirty) != 0;
230 return (dirtyBits & AllDirty) == 0;
235 return (dirtyBits & Varying) != 0;
294 static bool IsReprDirty(HdDirtyBits dirtyBits,
SdfPath const &
id);
491 return _varyingStateVersion;
504 return _rprimIndexVersion;
511 return _sprimIndexVersion;
518 return _bprimIndexVersion;
525 return _instancerIndexVersion;
535 return _sceneStateVersion;
563 static std::string StringifyDirtyBits(HdDirtyBits dirtyBits);
566 static void DumpDirtyBits(HdDirtyBits dirtyBits);
577 static void _LogCacheAccess(
TfToken const& cacheName,
580 typedef TfHashMap<SdfPath, HdDirtyBits, SdfPath::Hash> _IDStateMap;
581 typedef TfHashMap<TfToken, int, TfToken::HashFunctor> _CollectionStateMap;
582 typedef TfHashMap<TfToken, unsigned, TfToken::HashFunctor> _GeneralStateMap;
584 struct _PathHashCompare {
588 static size_t hash(
const SdfPath& path)
591 typedef tbb::concurrent_hash_map<SdfPath, SdfPathSet, _PathHashCompare>
595 _IDStateMap _rprimState;
596 _IDStateMap _instancerState;
597 _IDStateMap _taskState;
598 _IDStateMap _sprimState;
599 _IDStateMap _bprimState;
600 _GeneralStateMap _generalState;
603 _CollectionStateMap _collectionState;
607 _DependencyMap _instancerRprimDependencies;
608 _DependencyMap _instancerInstancerDependencies;
614 _DependencyMap _sprimSprimTargetDependencies;
616 _DependencyMap _sprimSprimSourceDependencies;
619 void _AddDependency(_DependencyMap &depMap,
621 void _RemoveDependency(_DependencyMap &depMap,
628 unsigned _varyingStateVersion;
633 unsigned _rprimIndexVersion;
634 unsigned _sprimIndexVersion;
635 unsigned _bprimIndexVersion;
636 unsigned _instancerIndexVersion;
641 unsigned _sceneStateVersion;
644 unsigned _visChangeCount;
647 unsigned _instanceIndicesChangeCount;
650 unsigned _rprimRenderTagVersion;
653 unsigned _taskRenderTagsVersion;
674 void _MarkRprimDirty(
SdfPath const&
id, HdDirtyBits bits=AllDirty);
675 void _MarkSprimDirty(
SdfPath const&
id, HdDirtyBits bits=AllDirty);
676 void _MarkBprimDirty(
SdfPath const&
id, HdDirtyBits bits=AllDirty);
677 void _MarkInstancerDirty(
SdfPath const&
id, HdDirtyBits bits=AllDirty);
681 PXR_NAMESPACE_CLOSE_SCOPE
683 #endif //PXR_IMAGING_HD_CHANGE_TRACKER_H HD_API void ResetRprimVaryingState(SdfPath const &id)
Reset the varying state on one Rprim This is done for Rprims, where we choose not to clean them (due ...
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
HD_API void MarkInstancerClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Clean the specified dirty bits for the instancer with id.
HD_API void MarkBprimDirty(SdfPath const &id, HdDirtyBits bits)
Set the dirty flags to bits.
HD_API HdDirtyBits GetTaskDirtyBits(SdfPath const &id)
Get the dirty bits for Task with the given id.
HD_API void MarkPrimvarDirty(SdfPath const &id, TfToken const &name)
Mark the primvar for the rprim with id as being dirty.
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine.
HD_API void RprimInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking Rprim with the given id.
HD_API void SprimRemoved(SdfPath const &id)
Stop tracking sprim with the given id.
HD_API void MarkTaskClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Set the dirty flags to newBits.
HD_API bool IsCullStyleDirty(SdfPath const &id)
Returns true if the rprim identified by id has dirty cullstyle.
static HD_API bool IsInstanceIndexDirty(HdDirtyBits dirtyBits, SdfPath const &id)
Returns true if the dirtyBits has a dirty instance index. id is for perflog.
static bool IsVarying(HdDirtyBits dirtyBits)
Returns true if the varying flag is set.
HD_API void MarkRprimClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Clear the dirty flags for an HdRprim.
HD_API HdDirtyBits GetInstancerDirtyBits(SdfPath const &id)
Returns the dirty bits for the instancer with id.
HD_API void BprimInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking bprim with the given id.
HD_API bool IsAnyPrimvarDirty(SdfPath const &id)
Returns true if the rprim identified by id has any dirty primvars.
HD_API unsigned GetStateVersion(TfToken const &name) const
Returns the current version of the named state.
HD_API void MarkInstancerDirty(SdfPath const &id, HdDirtyBits bits=AllDirty)
Flag the Instancer with the given id as being dirty.
HD_API HdDirtyBits GetSprimDirtyBits(SdfPath const &id)
Get the dirty bits for sprim with the given id.
HD_API void InstancerRemoved(SdfPath const &id)
Stop tracking Instancer with the given id.
Concrete scene container which can be externally populated and dirtied.
HD_API void TaskInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking Task with the given id.
HD_API void MarkStateDirty(TfToken const &name)
Marks a named state as being dirty., this bumps the version of the state.
HD_API bool IsDoubleSidedDirty(SdfPath const &id)
Returns true if the rprim identified by id has dirty doubleSided state.
HD_API unsigned GetTaskRenderTagsVersion() const
Retrieve the current version number of the task's render tags opinion.
HD_API HdDirtyBits GetBprimDirtyBits(SdfPath const &id)
Get the dirty bits for bprim with the given id.
Scene delegate which observes notices from an HdSceneIndex and applies them to an HdRenderIndex.
HD_API bool IsTransformDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty transform.
Token for efficient comparison, assignment, and hashing of known strings.
HD_API bool IsRprimDirty(SdfPath const &id)
Returns true if the rprim identified by id has any dirty flags set.
HD_API unsigned GetCollectionVersion(TfToken const &collectionName) const
Returns the current version of the named collection.
HD_API bool IsPrimIdDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty primID.
HD_API void RemoveSprimFromSprimSprimDependencies(SdfPath const &sprimId)
Remove all dependencies involving sprimId as a parent or child.
HD_API void MarkSprimDirty(SdfPath const &id, HdDirtyBits bits)
Set the dirty flags to bits.
unsigned GetInstancerIndexVersion() const
Returns the current version of the Render Index's Instancer set.
HD_API void ResetVaryingState()
Clear Varying bit of all prims.
HD_API void MarkTaskDirty(SdfPath const &id, HdDirtyBits bits=AllDirty)
Set the dirty flags to bits.
HD_API void MarkCollectionDirty(TfToken const &collectionName)
Marks a named collection as being dirty, this bumps the version of the collection.
static bool IsDirty(HdDirtyBits dirtyBits)
Returns true if the dirtyBits has any flags set other than the varying flag.
unsigned GetRprimIndexVersion() const
Returns the current version of the Render Index's RPrim set.
HD_API void AddInstancerRprimDependency(SdfPath const &instancerId, SdfPath const &rprimId)
Insert a dependency between rprimId and parent instancer instancerId.
HD_API void MarkBprimClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Set the dirty flags to newBits.
A path value used to locate objects in layers or scenegraphs.
HD_API void InstancerInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking Instancer with the given id.
HD_API bool IsTopologyDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty topology.
static bool IsClean(HdDirtyBits dirtyBits)
Returns true if the dirtyBits has no flags set except the varying flag.
HD_API void AddCollection(TfToken const &collectionName)
Adds a named collection for tracking.
HD_API void BprimRemoved(SdfPath const &id)
Stop tracking bprim with the given id.
HD_API void MarkRprimDirty(SdfPath const &id, HdDirtyBits bits=AllDirty)
Flag the Rprim with the given id as being dirty.
HD_API void MarkAllRprimsDirty(HdDirtyBits bits)
Flag all the Rprim with the given id as being dirty.
unsigned GetSceneStateVersion() const
Returns the current version of the scene state.
std::enable_if< std::is_same< Half, half >::value, size_t >::type hash_value(const Half &h)
Overload hash_value for half.
unsigned GetSprimIndexVersion() const
Returns the current version of the Render Index's SPrim set.
HD_API bool IsVisibilityDirty(SdfPath const &id)
Returns true if the rprim identified by id has dirty visibility.
HD_API bool IsSubdivTagsDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty subdiv tags.
HD_API unsigned GetInstanceIndicesChangeCount() const
Returns the number of changes to instance index.
HD_API void AddSprimSprimDependency(SdfPath const &parentSprimId, SdfPath const &sprimId)
Insert a dependency between sprimId and parent sprim parentSprimId.
HD_API void SprimInserted(SdfPath const &id, HdDirtyBits initialDirtyState)
Start tracking sprim with the given id.
HD_API bool IsExtentDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty extent.
HD_API bool IsDisplayStyleDirty(SdfPath const &id)
Returns true if the rprim identified by id has a dirty display style.
HD_API void MarkSprimClean(SdfPath const &id, HdDirtyBits newBits=Clean)
Set the dirty flags to newBits.
HD_API void AddState(TfToken const &name)
Adds a named state for tracking.
unsigned GetVaryingStateVersion() const
Returns the current version of varying state.
unsigned GetBprimIndexVersion() const
Returns the current version of the Render Index's BPrim set.
HD_API void RprimRemoved(SdfPath const &id)
Stop tracking Rprim with the given id.
HD_API void RemoveInstancerRprimDependency(SdfPath const &instancerId, SdfPath const &rprimId)
Remove a dependency between rprimId and parent instancer instancerId.
HD_API unsigned GetVisibilityChangeCount() const
Returns the number of changes to visibility.
HD_API HdDirtyBits GetRprimDirtyBits(SdfPath const &id) const
Returns the dirty bits for the rprim with id.
HD_API void RemoveInstancerInstancerDependency(SdfPath const &parentInstancerId, SdfPath const &instancerId)
Remove a dependency between instancerId and parent instancer parentInstancerId.
HD_API void RemoveSprimSprimDependency(SdfPath const &parentSprimId, SdfPath const &sprimId)
Remove a dependency between sprimId and parent sprim parentSprimId.
HD_API bool IsPrimvarDirty(SdfPath const &id, TfToken const &name)
Returns true if the rprim identified by id with primvar name is dirty.
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 AddInstancerInstancerDependency(SdfPath const &parentInstancerId, SdfPath const &instancerId)
Insert a dependency between instancerId and parent instancer parentInstancerId.
HD_API unsigned GetRenderTagVersion() const
Retrieve the current version number of the rprim render tag set XXX Rename to GetRprimRenderTagVersio...
HD_API void TaskRemoved(SdfPath const &id)
Stop tracking Task with the given id.