From f88ed42293a1a18b80f8dcbaf64b9aa43a246f0e Mon Sep 17 00:00:00 2001 From: krickw Date: Tue, 7 Dec 2021 16:05:50 -0500 Subject: [PATCH 1/6] Mark everything dirty when display modes change. --- lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h | 1 + .../render/vp2RenderDelegate/proxyRenderDelegate.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h index 05d374e9f1..3adb3da064 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h @@ -69,6 +69,7 @@ struct MayaPrimCommon { DirtySelectionHighlight = HdChangeTracker::CustomBitsBegin, DirtySelectionMode = (DirtySelectionHighlight << 1), + DirtyDisplayMode = (DirtySelectHighlight << 1), DirtyBitLast = DirtySelectionMode }; }; diff --git a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp index f843346a5f..f01d8d5d19 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -828,6 +828,13 @@ void ProxyRenderDelegate::_Execute(const MHWRender::MFrameContext& frameContext) if (_defaultCollection->GetReprSelector() != reprSelector) { _defaultCollection->SetReprSelector(reprSelector); _taskController->SetCollection(*_defaultCollection); + + // Mark everything "dirty" so that sync is called on everything + auto& rprims = _renderIndex->GetRprimIds(); + HdChangeTracker& changeTracker = _renderIndex->GetChangeTracker(); + for (auto path : rprims) { + changeTracker.MarkRprimDirty(path, MayaPrimCommon::DirtyDisplayMode); + } } // if there are no repr's to update then don't even call sync. From 512e4c18fbc7f22c8e125904477a9e4edd93a176 Mon Sep 17 00:00:00 2001 From: krickw Date: Tue, 7 Dec 2021 16:11:16 -0500 Subject: [PATCH 2/6] Clang format. --- lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp index f01d8d5d19..c791330da3 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -830,7 +830,7 @@ void ProxyRenderDelegate::_Execute(const MHWRender::MFrameContext& frameContext) _taskController->SetCollection(*_defaultCollection); // Mark everything "dirty" so that sync is called on everything - auto& rprims = _renderIndex->GetRprimIds(); + auto& rprims = _renderIndex->GetRprimIds(); HdChangeTracker& changeTracker = _renderIndex->GetChangeTracker(); for (auto path : rprims) { changeTracker.MarkRprimDirty(path, MayaPrimCommon::DirtyDisplayMode); From a1b6918e3246856cec73ecd7eadcb69eb741dc03 Mon Sep 17 00:00:00 2001 From: krickw Date: Tue, 7 Dec 2021 16:45:10 -0500 Subject: [PATCH 3/6] Fix the enum values, and document the parameters. --- lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h index 3adb3da064..4f130640c7 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h @@ -67,9 +67,13 @@ 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), - DirtyDisplayMode = (DirtySelectHighlight << 1), + // Maya's display mode has changed, for example for shaded to wireframe + DirtyDisplayMode = (DirtySelectionMode << 1), DirtyBitLast = DirtySelectionMode }; }; From f3ca771b5acc36a9d7bae7db6880aa717a195fe4 Mon Sep 17 00:00:00 2001 From: krickw Date: Wed, 8 Dec 2021 08:39:27 -0500 Subject: [PATCH 4/6] Fix enum again. --- lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h index 4f130640c7..151bb55ef3 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h +++ b/lib/mayaUsd/render/vp2RenderDelegate/mayaPrimCommon.h @@ -74,7 +74,7 @@ struct MayaPrimCommon DirtySelectionMode = (DirtySelectionHighlight << 1), // Maya's display mode has changed, for example for shaded to wireframe DirtyDisplayMode = (DirtySelectionMode << 1), - DirtyBitLast = DirtySelectionMode + DirtyBitLast = DirtyDisplayMode }; }; From b0a3e7a9b25344e6ce1b044ef8a4b4d1b159eadd Mon Sep 17 00:00:00 2001 From: krickw Date: Wed, 8 Dec 2021 16:14:38 -0500 Subject: [PATCH 5/6] Only mark things dirty in the case where we're going to call execute. --- .../vp2RenderDelegate/proxyRenderDelegate.cpp | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp index c791330da3..7506e211a0 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -825,20 +825,22 @@ void ProxyRenderDelegate::_Execute(const MHWRender::MFrameContext& frameContext) } } - if (_defaultCollection->GetReprSelector() != reprSelector) { - _defaultCollection->SetReprSelector(reprSelector); - _taskController->SetCollection(*_defaultCollection); - - // Mark everything "dirty" so that sync is called on everything - auto& rprims = _renderIndex->GetRprimIds(); - HdChangeTracker& changeTracker = _renderIndex->GetChangeTracker(); - for (auto path : rprims) { - changeTracker.MarkRprimDirty(path, MayaPrimCommon::DirtyDisplayMode); - } - } - // if there are no repr's to update then don't even call sync. if (reprSelector != HdReprSelector()) { + if (_defaultCollection->GetReprSelector() != reprSelector) { + _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); } } From e5625b5e904e7415fa3e60b4eb06655af9777133 Mon Sep 17 00:00:00 2001 From: krickw Date: Mon, 3 Jan 2022 11:33:33 -0500 Subject: [PATCH 6/6] Update all the current repr's, not just smooth hull. --- lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp index 7506e211a0..7e33485d87 100644 --- a/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp +++ b/lib/mayaUsd/render/vp2RenderDelegate/proxyRenderDelegate.cpp @@ -1272,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);