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-104542 Handle rprim purpose changing to a hidden purpose correctly #558

Merged
merged 4 commits into from
Jun 8, 2020

Conversation

williamkrick
Copy link
Contributor

No description provided.

// 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.
Copy link
Contributor Author

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.

Copy link

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?

Copy link
Contributor Author

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.

@kxl-adsk kxl-adsk added the vp2renderdelegate Related to VP2RenderDelegate label Jun 3, 2020
@williamkrick
Copy link
Contributor Author

MayaUsd - Build External GitHub Branch run 142

@cfmoore007
Copy link

cfmoore007 commented Jun 4, 2020

Here are my results ( note this post is updated from earlier ) :

PR558_Results2

Results are basically the same.

Christopher

…ep the set of render tags on our dummy render task small.
@williamkrick
Copy link
Contributor Author

There is a clear improvement in shaded guide display before/after.

Christopher

@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 Guide Purpose mode. My numbers before and after the change are similar to your 38c3ea+PR558 numbers. Am I correct in assuming that when you did this test only Guide Puropose and not Proxy Purpose? Anything else to reproduce this beyond create the proxy shape and set the file name?

@kxl-adsk kxl-adsk added the do-not-merge-yet Development is not finished, PR not ready for merge label Jun 4, 2020
// marking visibility dirty instead of render tag. See UsdImagingGprimAdapter::ProcessPropertyChange
// for where this happens.
*dirtyBits &= ~( HdChangeTracker::DirtyRenderTag | HdChangeTracker::DirtyVisibility );
return;
Copy link
Contributor Author

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.

Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

Copy link

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.
Copy link
Contributor Author

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.

@cfmoore007
Copy link

There is a clear improvement in shaded guide display before/after.
Christopher

@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 Guide Purpose mode. My numbers before and after the change are similar to your 38c3ea+PR558 numbers. Am I correct in assuming that when you did this test only Guide Puropose and not Proxy Purpose? Anything else to reproduce this beyond create the proxy shape and set the file name?

  • I've updated my previous post. Not sure what happened, but I can confirm the roughly match
    PR558_Results2

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.
Viewport size was the same in all tests.

continue;

_delegate->GetVP2ResourceRegistry().EnqueueCommit([renderItem]() {
renderItem->enable(false);
Copy link

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);
Copy link

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.

@kxl-adsk kxl-adsk removed the do-not-merge-yet Development is not finished, PR not ready for merge label Jun 8, 2020
@kxl-adsk kxl-adsk merged commit 4ea2f25 into dev Jun 8, 2020
@kxl-adsk kxl-adsk deleted the krickw/MAYA-104542/handle_rprim_purpose_changed branch June 8, 2020 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vp2renderdelegate Related to VP2RenderDelegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants