Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@bdero
Copy link
Member

@bdero bdero commented Aug 18, 2023

Solves two problems:

  1. Fix the debug crash by restoring the clip after the EntityPass merge. I initially surrounded the merge with a Save and Restore, which was a mistake and is a no-op in this situation. This should have no excess impact on performance, since we ignore clips in EntityPass when we detect that they won't do anything.
  2. Picture subpasses weren't getting their stencil depth adjusted during the merge, which can result in subpass entities potentially receiving a clip depth that's too high.

Before:

[ RUN      ] Play/AiksTest.DrawPictureClipped/Metal
2023-08-17 19:23:34.204 impeller_unittests[83313:21896481] Metal API Validation Enabled
2023-08-17 19:23:34.204 impeller_unittests[83313:21896481] Metal GPU Validation Enabled
[FATAL:flutter/impeller/entity/entity_pass.cc(689)] Check failed: stencil_coverage_stack.back().stencil_depth == stencil_coverage_stack.size() - 1.
[1]    83313 abort      ../out/host_debug_unopt/impeller_unittests --timeout=0  --enable_playground

After:

Screenshot 2023-08-17 at 7 41 31 PM

@bdero bdero requested a review from dnfield August 18, 2023 03:16
@bdero bdero self-assigned this Aug 18, 2023
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #44835 at sha b3ccb0e


if (auto subpass = std::get_if<std::unique_ptr<EntityPass>>(&element)) {
subpass->get()->SetStencilDepth(subpass->get()->GetStencilDepth() +
GetStencilDepth());
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is the current stencil depth of the canvas that we are rendering the new picture into?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes indeed.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@bdero bdero added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 19, 2023
@bdero bdero merged commit e4ea62e into flutter:main Aug 20, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 21, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 21, 2023
GetCurrentPass().AddSubpassInline(std::move(pass));

RestoreToCount(save_count);
RestoreClip();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is what I was missing in my attempt - why is this right and the RestoreToCount wasn't?

Copy link
Member Author

@bdero bdero Aug 21, 2023

Choose a reason for hiding this comment

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

Because in-between the save and restore, we just merge the two passes without changing anything about the canvas transformation stack, and so the RestoreToCount doesn't result in any clip restores getting appended because it thinks we're still at the same stencil depth.

RestoreClip always inserts a clip restore that will flatten to the currently tracked stencil depth, which gets the pass back into alignment with the canvas state without us having to add (normally unnecessary) stencil cleanup at the end of the base pass.

gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
Solves two problems:
1. Fix the debug crash by restoring the clip after the `EntityPass`
merge. I initially surrounded the merge with a `Save` and `Restore`,
which was a mistake and is a no-op in this situation. This should have
no excess impact on performance, since we ignore clips in `EntityPass`
when we detect that they won't do anything.
2. Picture subpasses weren't getting their stencil depth adjusted during
the merge, which can result in subpass entities potentially receiving a
clip depth that's too high.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants