-
Notifications
You must be signed in to change notification settings - Fork 203
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-104542 Handle rprim purpose changing to a hidden purpose correctly #558
Conversation
// Set the render tags to be all the tags. Vp2RenderDelegate implements | ||
// render tags as a per-render item setting, so we always need to visit | ||
// all the rprims to handle cases when an rprim changes from a displayed | ||
// tag to a hidden tag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance downside of this change is for animated rprims which have a purpose which is not displayed. In that case we'll do all the updates for those rprims and then not draw the item, which is unfortunate.
We might be able to work around it by having a special case for visibility, where we update the visibility of an item first. Then, for hidden items don't bother updating anything else, just leave it all dirty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, it sounds like purpose will only allow us to save on drawing, but not on the cost to sync changes? What's the implication for memory usage of big static scenes, time to the first frame, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right we will create all the guide objects and then not draw them. Basically we have to poll every rprim every frame to see if it goes its visibility dirtied because it's purpose changed.
I checked again how HdSt handles the render tag on an rprim changing to a hidden tag:
-
HdChangeTracker::MarkRprimDirty() is called with DirtyRenderTag as one of the dirty bits, which increments rprimIndexVersion.
-
In HdSt_RenderPass::_PrepareDrawItems() they detect the change in rprimIndexVersion and rebuild the list of draw items to draw (filtered by render tags).
This is what we are missing. We don't have an equivalent search over all the draw items to only update their "visibility". Items get hidden by being left out of the _drawItems list, and therefore excluded from their draw batches in _PrepareCommandBuffers.
I'm trying use our existing pass over all the rprims in execute to turn items on and off as necessary, to do that I explicitly need to consider each MRenderItem and turn on or off its visibility.
I can improve it with a combination of two changes:
-
Have an early exit in Sync for rprims that are hidden by render tags, leaving the dirty bits intact so they update correctly when made visible. That prevents creating Maya stuff for guide items which are not drawn.
-
Only force the pass over all render tags when that HdChangeTracker::rprimIndexVersion has changed. That prevents visiting everything and checking its visibility every refresh (I'm assuming we'd have lots of dirty + hidden stuff because we skip the update for hidden things). We'd only visit the stuff that passes the render tags test.
This reverts commit 0a07070.
MayaUsd - Build External GitHub Branch run 142 |
…ep the set of render tags on our dummy render task small.
@cfmoore007 Your performance results surprised me, I wasn't expecting anything to go faster. I'm haven't been able to reproduce your slow result with 38c3ea in |
// marking visibility dirty instead of render tag. See UsdImagingGprimAdapter::ProcessPropertyChange | ||
// for where this happens. | ||
*dirtyBits &= ~( HdChangeTracker::DirtyRenderTag | HdChangeTracker::DirtyVisibility ); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the risky bit of the change. We don't have much experience or tests leaving items dirty & hidden. I tested a scene with animation where I change the purpose of the items so they are hidden, change time, and change the purpose so they are drawn, and that simple workflow is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern will have to be repeated in the other HdVP2 shapes because they all have the same problem. Ideally we can find a way for the different shapes to share code.
continue; | ||
|
||
_delegate->GetVP2ResourceRegistry().EnqueueCommit([renderItem]() { | ||
renderItem->enable(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting enable can change which world the renderItem in, we need those changes to be serialized so use the commit system to do it from the main thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soon we will need ThreadRun to free main-thread and get processing of commits started as soon as possible.
// any newly visible rprims will update and mark themselves visible. | ||
// When the render tag on an rprim changes we do a pass over all rprims to update | ||
// their visibility. The frame after we do the pass over all the tags, set the tags back to | ||
// the minimum set of tags. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the new version we call Execute once with all the tags (to hide those visible->hidden rprims) and the next update we go back to calling Execute with the minimum set of render tags.
I did my tests in both guide and proxy. And, yes all I did was create the proxyShape and hit 'F' to frame the viewport. |
continue; | ||
|
||
_delegate->GetVP2ResourceRegistry().EnqueueCommit([renderItem]() { | ||
renderItem->enable(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soon we will need ThreadRun to free main-thread and get processing of commits started as soon as possible.
@@ -102,6 +102,8 @@ class HdVP2Mesh final : public HdMesh { | |||
const HdMeshReprDesc& desc, | |||
bool requireSmoothNormals, bool requireFlatNormals); | |||
|
|||
void _HideAllDrawItems(const TfToken& reprToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't adopted _
as our naming convention for methods. No need to change it now, but we should stop using it.
No description provided.