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

MAYA-114247 Mark everything dirty when display modes change. #1891

Merged
merged 6 commits into from
Jan 5, 2022
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
7 changes: 6 additions & 1 deletion lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ struct MayaPrimCommon
{
enum DirtyBits : HdDirtyBits
{
// The rprim has been added, removed or otherwise changed such that the selection highlight
// for the item is dirty
DirtySelectionHighlight = HdChangeTracker::CustomBitsBegin,
// Maya's selection mode has changed, for example into point snapping mode
DirtySelectionMode = (DirtySelectionHighlight << 1),
DirtyBitLast = DirtySelectionMode
// Maya's display mode has changed, for example for shaded to wireframe
DirtyDisplayMode = (DirtySelectionMode << 1),
DirtyBitLast = DirtyDisplayMode
};
};

Expand Down
21 changes: 15 additions & 6 deletions lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,13 +825,22 @@ void ProxyRenderDelegate::_Execute(const MHWRender::MFrameContext& frameContext)
}
}

if (_defaultCollection->GetReprSelector() != reprSelector) {
_defaultCollection->SetReprSelector(reprSelector);
_taskController->SetCollection(*_defaultCollection);
}

// if there are no repr's to update then don't even call sync.
if (reprSelector != HdReprSelector()) {
if (_defaultCollection->GetReprSelector() != reprSelector) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new point snapping support when we do a selection pass we often end up with an empty reprSelector. If that happens don't save it to _defaultCollection, because doing so trashes the previous reprSelector we had saved, and causes the full scene MarkRprimDirty to run. We want to avoid running that as much as possible because the cost of even the empty sync calls is non-zero.

_defaultCollection->SetReprSelector(reprSelector);
_taskController->SetCollection(*_defaultCollection);

// Mark everything "dirty" so that sync is called on everything
// If there are multiple views up with different viewport modes then
// this is slow.
auto& rprims = _renderIndex->GetRprimIds();
HdChangeTracker& changeTracker = _renderIndex->GetChangeTracker();
for (auto path : rprims) {
changeTracker.MarkRprimDirty(path, MayaPrimCommon::DirtyDisplayMode);
}
}

_engine.Execute(_renderIndex.get(), &_dummyTasks);
}
}
Expand Down Expand Up @@ -1263,7 +1272,7 @@ void ProxyRenderDelegate::_UpdateSelectionStates()

// now that the appropriate prims have been marked dirty trigger
// a sync so that they all update.
HdRprimCollection collection(HdTokens->geometry, kSmoothHullReprSelector);
HdRprimCollection collection(HdTokens->geometry, _defaultCollection->GetReprSelector());
collection.SetRootPaths(rootPaths);
_taskController->SetCollection(collection);
_engine.Execute(_renderIndex.get(), &_dummyTasks);
Expand Down