Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetInstanceIndicesChangeCount to detect changes to instance indexing #1754

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pxr/imaging/hd/changeTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ HdChangeTracker::HdChangeTracker()
, _instancerIndexVersion(1)
, _sceneStateVersion(1)
, _visChangeCount(1)
, _instanceIndicesChangeCount(1)
, _rprimRenderTagVersion(1)
, _taskRenderTagsVersion(1)
, _emulationSceneIndex(nullptr)
Expand Down Expand Up @@ -194,6 +195,10 @@ void HdChangeTracker::_MarkRprimDirty(SdfPath const& id, HdDirtyBits bits)
++_visChangeCount;
}

if ((bits & DirtyInstanceIndex) != 0) {
++_instanceIndicesChangeCount;
}

if ((bits & DirtyRenderTag) != 0) {
++_rprimRenderTagVersion;
}
Expand Down Expand Up @@ -527,6 +532,7 @@ HdChangeTracker::_MarkInstancerDirty(SdfPath const& id, HdDirtyBits bits)
}
if (bits & DirtyInstanceIndex) {
toPropagate |= DirtyInstanceIndex;
++_instanceIndicesChangeCount;
}

// Now mark any associated rprims or instancers dirty.
Expand Down Expand Up @@ -1011,6 +1017,9 @@ HdChangeTracker::MarkAllRprimsDirty(HdDirtyBits bits)
if ((bits & DirtyVisibility) != 0) {
++_visChangeCount;
}
if ((bits & DirtyInstanceIndex) != 0) {
++_instanceIndicesChangeCount;
}
if ((bits & DirtyRenderTag) != 0) {
++_rprimRenderTagVersion;
}
Expand Down Expand Up @@ -1099,6 +1108,12 @@ HdChangeTracker::GetVisibilityChangeCount() const
return _visChangeCount;
}

unsigned
HdChangeTracker::GetInstanceIndicesChangeCount() const
{
return _instanceIndicesChangeCount;
}

void
HdChangeTracker::AddState(TfToken const& name)
{
Expand Down
9 changes: 9 additions & 0 deletions pxr/imaging/hd/changeTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ class HdChangeTracker
HD_API
unsigned GetVisibilityChangeCount() const;

/// Returns the number of changes to instance index. This is intended to be used
/// to detect when instance indices changed for *any* Rprim. Use in with
/// GetInstancerIndexVersion() to detect all changes to instance indices.
HD_API
unsigned GetInstanceIndicesChangeCount() const;

/// Returns the current version of varying state. This is used to refresh
/// cached DirtyLists
unsigned GetVaryingStateVersion() const {
Expand Down Expand Up @@ -637,6 +643,9 @@ class HdChangeTracker
// Used to detect that visibility changed somewhere in the render index.
unsigned _visChangeCount;

// Used to detect that instance indices changed somewhere in the render index.
unsigned _instanceIndicesChangeCount;

// Used to detect changes to the render tag opinion of rprims.
unsigned _rprimRenderTagVersion;

Expand Down