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

[Impeller] Reland: Implement draw order optimization. #54215

Merged
merged 7 commits into from
Jul 31, 2024

Conversation

bdero
Copy link
Member

@bdero bdero commented Jul 30, 2024

Original PR: #54136
Revert PR: #54067

Includes fixes for issue seen in these goldens.

The problem was that the scissor was ending up wrong after clip replay for opaque draws that are supposed to occur outside the parent clip scope(s).

To fix it, I made clip replay draws as well as the subpass texture draw apply lazily.
For the clip replay, there's no need to apply a given clip until we come across an entity that has a depth less than or equal to the clip.
And for the subpass texture (which is often translucent), we can defer drawing it until we come across another translucent draw. Deferring the subpass texture is important because if we draw it immediately, then all of the replay clips need to be drawn immediately too.

Description

For each clip scope, draw opaque items in reverse order and translucent/backdrop-independent items in their original order afterwards. Clips are treated as translucent by the parent scope.

Respects clips, subpass collapse, and the clear color optimization.

Local new_gallery before/after (iPhone 12 mini):

cd ~/projects/flutter/flutter/dev/integration_tests/new_gallery
flutter drive --profile --local-engine-src-path ~/projects/flutter/engine/src --local-engine=ios_profile --local-engine-host=host_profile_arm64 --trace-startup -t test_driver/transitions_perf.dart -d 00008101-000A59A93C10001E

image

@bdero bdero force-pushed the bdero/reland-draw-order-optimization branch from 5828898 to f6bcf1d Compare July 30, 2024 13:36
@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 #54215 at sha f6bcf1d

@@ -43,6 +43,8 @@ Entity::Entity(Entity&&) = default;

Entity::Entity(const Entity&) = default;

Entity& Entity::operator=(Entity&&) = default;
Copy link
Member

Choose a reason for hiding this comment

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

What are we using this for?

Copy link
Member

Choose a reason for hiding this comment

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

also what is this 🙃 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the move assignment operator. I just needed it for the deferred_entity = std::move(result.entity) assignment.
(In general, we should always add the move assignment when adding the move constructor to prevent it from getting implicitly deleted.)

Copy link
Member

@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

interesting fix! still interested in how we can port this over to experimental canvas. We may need to give up on not ever storing entities, but as long as all of the entity data is references into the display list we can still save on allocations.

@bdero bdero merged commit 11bce42 into flutter:main Jul 31, 2024
28 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 31, 2024
@bdero
Copy link
Member Author

bdero commented Jul 31, 2024

Reason for revert: Causing golden diffs in framework roll https://flutter-gold.skia.org/search?issue=152633&crs=github&patchsets=2&corpus=flutter

bdero added a commit that referenced this pull request Jul 31, 2024
@bdero bdero added the revert Label used to revert changes in a closed and merged pull request. label Jul 31, 2024
auto-submit bot pushed a commit that referenced this pull request Jul 31, 2024
@auto-submit auto-submit bot removed the revert Label used to revert changes in a closed and merged pull request. label Jul 31, 2024
auto-submit bot added a commit that referenced this pull request Jul 31, 2024
…" (#54261)

Reverts: #54215
Initiated by: bdero
Reason for reverting: Causing golden diffs in framework roll https://flutter-gold.skia.org/search?issue=152633&crs=github&patchsets=2&corpus=flutter
Original PR Author: bdero

Reviewed By: {jonahwilliams}

This change reverts the following previous change:
Original PR: #54136
Revert PR: #54067

Includes fixes for issue seen in [these goldens](https://flutter-gold.skia.org/search?issue=152354&crs=github&patchsets=2&corpus=flutter).

The problem was that the scissor was ending up wrong after clip replay for opaque draws that are supposed to occur outside the parent clip scope(s).

To fix it, I made clip replay draws as well as the subpass texture draw apply lazily.
For the clip replay, there's no need to apply a given clip until we come across an entity that has a depth less than or equal to the clip.
And for the subpass texture (which is often translucent), we can defer drawing it until we come across another translucent draw. Deferring the subpass texture is important because if we draw it immediately, then all of the replay clips need to be drawn immediately too.

## Description
For each clip scope, draw opaque items in reverse order and translucent/backdrop-independent items in their original order afterwards. Clips are treated as translucent by the parent scope.

Respects clips, subpass collapse, and the clear color optimization.

### Local new_gallery before/after (iPhone 12 mini):
```
cd ~/projects/flutter/flutter/dev/integration_tests/new_gallery
flutter drive --profile --local-engine-src-path ~/projects/flutter/engine/src --local-engine=ios_profile --local-engine-host=host_profile_arm64 --trace-startup -t test_driver/transitions_perf.dart -d 00008101-000A59A93C10001E
```
![image](https://github.com/user-attachments/assets/7372c128-ca71-44a6-8e6c-b0043025f751)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 31, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jul 31, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 1, 2024
…sions) (#152648)

Manual roll requested by jacksongardner@google.com

flutter/engine@1633272...32f7888

2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from 431b57332241 to b5ad5bf3696d (3 revisions) (flutter/engine#54259)
2024-07-31 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from cYjTzxe0MskG7PtkB... to uF76DfQgigt4utdBv... (flutter/engine#54258)
2024-07-31 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] Reland: Implement draw order optimization. (#54215)" (flutter/engine#54261)
2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from cd58e87c06f9 to 431b57332241 (2 revisions) (flutter/engine#54257)
2024-07-31 chris@bracken.jp [iOS][macOS] Eliminate use of bitcode_strip (flutter/engine#54254)
2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from e9e423457655 to cd58e87c06f9 (5 revisions) (flutter/engine#54253)
2024-07-31 matanlurey@users.noreply.github.com Cleanup the shell test, removing unused code (flutter/engine#54238)
2024-07-31 yjbanov@google.com [web] rename dialog to route to match the framework (flutter/engine#54228)
2024-07-31 skia-flutter-autoroll@skia.org Roll Dart SDK from edace067d950 to 5df6a6e0c037 (1 revision) (flutter/engine#54252)
2024-07-31 bdero@google.com [Impeller] Reland: Implement draw order optimization. (flutter/engine#54215)
2024-07-31 matanlurey@users.noreply.github.com Migrate the remaining real pub packages to pub workspaces. (flutter/engine#54232)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from cYjTzxe0MskG to uF76DfQgigt4

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
bdero added a commit that referenced this pull request Aug 1, 2024
This time for sure!

For each clip scope, draw opaque items in reverse order and
translucent/backdrop-independent items in their original order
afterwards. Clips are treated as translucent by the parent scope.

Respects clips, subpass collapse, and the clear color optimization.

Attempt 1: #54136
Revert 1: #54067
Attempt 2: #54215
Revert 2: #54261
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
…sions) (flutter#152648)

Manual roll requested by jacksongardner@google.com

flutter/engine@1633272...32f7888

2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from 431b57332241 to b5ad5bf3696d (3 revisions) (flutter/engine#54259)
2024-07-31 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from cYjTzxe0MskG7PtkB... to uF76DfQgigt4utdBv... (flutter/engine#54258)
2024-07-31 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] Reland: Implement draw order optimization. (flutter#54215)" (flutter/engine#54261)
2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from cd58e87c06f9 to 431b57332241 (2 revisions) (flutter/engine#54257)
2024-07-31 chris@bracken.jp [iOS][macOS] Eliminate use of bitcode_strip (flutter/engine#54254)
2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from e9e423457655 to cd58e87c06f9 (5 revisions) (flutter/engine#54253)
2024-07-31 matanlurey@users.noreply.github.com Cleanup the shell test, removing unused code (flutter/engine#54238)
2024-07-31 yjbanov@google.com [web] rename dialog to route to match the framework (flutter/engine#54228)
2024-07-31 skia-flutter-autoroll@skia.org Roll Dart SDK from edace067d950 to 5df6a6e0c037 (1 revision) (flutter/engine#54252)
2024-07-31 bdero@google.com [Impeller] Reland: Implement draw order optimization. (flutter/engine#54215)
2024-07-31 matanlurey@users.noreply.github.com Migrate the remaining real pub packages to pub workspaces. (flutter/engine#54232)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from cYjTzxe0MskG to uF76DfQgigt4

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…sions) (flutter#152648)

Manual roll requested by jacksongardner@google.com

flutter/engine@1633272...32f7888

2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from 431b57332241 to b5ad5bf3696d (3 revisions) (flutter/engine#54259)
2024-07-31 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from cYjTzxe0MskG7PtkB... to uF76DfQgigt4utdBv... (flutter/engine#54258)
2024-07-31 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] Reland: Implement draw order optimization. (flutter#54215)" (flutter/engine#54261)
2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from cd58e87c06f9 to 431b57332241 (2 revisions) (flutter/engine#54257)
2024-07-31 chris@bracken.jp [iOS][macOS] Eliminate use of bitcode_strip (flutter/engine#54254)
2024-07-31 skia-flutter-autoroll@skia.org Roll Skia from e9e423457655 to cd58e87c06f9 (5 revisions) (flutter/engine#54253)
2024-07-31 matanlurey@users.noreply.github.com Cleanup the shell test, removing unused code (flutter/engine#54238)
2024-07-31 yjbanov@google.com [web] rename dialog to route to match the framework (flutter/engine#54228)
2024-07-31 skia-flutter-autoroll@skia.org Roll Dart SDK from edace067d950 to 5df6a6e0c037 (1 revision) (flutter/engine#54252)
2024-07-31 bdero@google.com [Impeller] Reland: Implement draw order optimization. (flutter/engine#54215)
2024-07-31 matanlurey@users.noreply.github.com Migrate the remaining real pub packages to pub workspaces. (flutter/engine#54232)

Also rolling transitive DEPS:
  fuchsia/sdk/core/linux-amd64 from cYjTzxe0MskG to uF76DfQgigt4

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants