-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[DisplayList] Allow random access to ops through indexing #54484
Conversation
Alternative implementation using a "Bookmark" concept: #54299 |
Some notes on simplification, because it looks like a huge number of changes at first. The main source of diffs was reorganizing the way that culled dispatching is done. It used to be a complicated interaction between the dispatch method maintaining state in a All of that is deleted now and we simply get the vector of rects from the rtree, then a single method ( It is worth noting that the performance of culled dispatching is better with this new arrangement even though an extra vector is allocated. |
Dispatch benchmarks before chnages:
After:
Default dispatching took a minor 6% hit (keep in mind that these are microseconds and the DisplayList is huge), but culled dispatching got faster by 22%. Dispatching manually by indices is slower, but the added flexibility of being able to control the dispatch order will hopefully make up for it - and these are measured in microseconds for a large display list. ---------------- Update ---------------- Made some good improvements by asserting the unsigned nature of the index type to prove that
The new data looks like default dispatch is better by a couple of %, but I think that is just run-to-run variance. |
Overhead in us seems small enough to not worry about. Will take more look at the code next week, but I like the idea and seems fairly straightforward |
DlIndex end = display_list->record_count(); | ||
for (DlIndex i = 0u; i < end; i++) { | ||
display_list->Dispatch(receiver, i); | ||
} |
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.
So this is really the meat of what this change allows: dispatch takes an offset and so I can choose to dispatch at any particular offset.
The tricky part is the op kinds right? We'd still need to manage things like paint state, clip state, transform state and distinguish between them when re-dispatching, 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.
That's where GetOpCategory comes into play. You can easily figure out if it is a Save/Restore or a Rendering op or an Attribute/Transform/Clip op.
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 the latest change you can also do for (DlIndex i : *display_list)
- woot...
d2d0527
to
b65b742
Compare
Some other potential usage of this: we may compute that a saveLayer could be edlided during dispatch: it would be nice if we could manipulate the dispatch/iterator structure to skip to the corresponding restore. Right now with experimental canvas we need to rely on the cull rect checks |
You just skip the Check out the new |
Is there a reason why this wouldn't already be culled by the culling form of dispatch? (You can still do culling with indexed dispatches, btw - you just use the new |
I'm not certain why it doesn't happen. I can say that there are scenarios with the aiks canvas today where aiks will cull save layers that display list does not. |
Oh, right, like when the DL had to make a pessimal assumption about the destination size because it didn't actually have a destination in mind when it was recorded. Thus, there may be additional culling that can happen in the final stages like Impeller. |
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.
LGTM with minor nit
display_list/display_list.cc
Outdated
// then gets reset to the value stored in the stack top | ||
if (info.save_was_needed) { | ||
FML_DCHECK(next_restore_index < offsets_.size()); | ||
indices.emplace_back(next_restore_index); |
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.
Minor nit, but I would prefer push_back if we're not using the aggregate initialization features of emplace_back.
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.
There were other places that also used emplace_back with a simple integer type (all in this PR) so I changed them all. Only one emplace_back that was actually invoking an aggregate constructor.
…sions) (#153413) Manual roll requested by zra@google.com flutter/engine@019f9e3...5909666 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (#54541)" (flutter/engine#54552) 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: Clean up create_ios_framework.py (#54543)" (flutter/engine#54550) 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: refactor create_macos_framework.py (#54546)" (flutter/engine#54549) 2024-08-14 chris@bracken.jp macOS: refactor create_macos_framework.py (flutter/engine#54546) 2024-08-13 flar@google.com [DisplayList] Allow random access to ops through indexing (flutter/engine#54484) 2024-08-13 mit@google.com Update dartdoc for gpu.dart (flutter/engine#54529) 2024-08-13 chris@bracken.jp macOS: Clean up create_ios_framework.py (flutter/engine#54543) 2024-08-13 skia-flutter-autoroll@skia.org Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter/engine#54541) 2024-08-13 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 2LTVy4Gv76DcMpz4V... to MeV5i7xXXFPHF5sBK... (flutter/engine#54542) 2024-08-13 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Add animation detection for GIFs (flutter/engine#54483) 2024-08-13 matej.knopp@gmail.com Preserve background frame damage (flutter/engine#54540) 2024-08-13 68449066+zijiehe-google-com@users.noreply.github.com [fuchsia] Use BundledTestRunner from test-scripts (flutter/engine#54404) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 2LTVy4Gv76Dc to MeV5i7xXXFPH 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 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
…sions) (flutter#153413) Manual roll requested by zra@google.com flutter/engine@019f9e3...5909666 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter#54541)" (flutter/engine#54552) 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: Clean up create_ios_framework.py (flutter#54543)" (flutter/engine#54550) 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: refactor create_macos_framework.py (flutter#54546)" (flutter/engine#54549) 2024-08-14 chris@bracken.jp macOS: refactor create_macos_framework.py (flutter/engine#54546) 2024-08-13 flar@google.com [DisplayList] Allow random access to ops through indexing (flutter/engine#54484) 2024-08-13 mit@google.com Update dartdoc for gpu.dart (flutter/engine#54529) 2024-08-13 chris@bracken.jp macOS: Clean up create_ios_framework.py (flutter/engine#54543) 2024-08-13 skia-flutter-autoroll@skia.org Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter/engine#54541) 2024-08-13 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 2LTVy4Gv76DcMpz4V... to MeV5i7xXXFPHF5sBK... (flutter/engine#54542) 2024-08-13 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Add animation detection for GIFs (flutter/engine#54483) 2024-08-13 matej.knopp@gmail.com Preserve background frame damage (flutter/engine#54540) 2024-08-13 68449066+zijiehe-google-com@users.noreply.github.com [fuchsia] Use BundledTestRunner from test-scripts (flutter/engine#54404) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 2LTVy4Gv76Dc to MeV5i7xXXFPH 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 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
…lutter#54484) This reverts commit a6508d6.
…sions) (flutter#153413) Manual roll requested by zra@google.com flutter/engine@019f9e3...5909666 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter#54541)" (flutter/engine#54552) 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: Clean up create_ios_framework.py (flutter#54543)" (flutter/engine#54550) 2024-08-14 98614782+auto-submit[bot]@users.noreply.github.com Reverts "macOS: refactor create_macos_framework.py (flutter#54546)" (flutter/engine#54549) 2024-08-14 chris@bracken.jp macOS: refactor create_macos_framework.py (flutter/engine#54546) 2024-08-13 flar@google.com [DisplayList] Allow random access to ops through indexing (flutter/engine#54484) 2024-08-13 mit@google.com Update dartdoc for gpu.dart (flutter/engine#54529) 2024-08-13 chris@bracken.jp macOS: Clean up create_ios_framework.py (flutter/engine#54543) 2024-08-13 skia-flutter-autoroll@skia.org Roll Dart SDK from 44635f897535 to 733062367c2e (1 revision) (flutter/engine#54541) 2024-08-13 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 2LTVy4Gv76DcMpz4V... to MeV5i7xXXFPHF5sBK... (flutter/engine#54542) 2024-08-13 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Add animation detection for GIFs (flutter/engine#54483) 2024-08-13 matej.knopp@gmail.com Preserve background frame damage (flutter/engine#54540) 2024-08-13 68449066+zijiehe-google-com@users.noreply.github.com [fuchsia] Use BundledTestRunner from test-scripts (flutter/engine#54404) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from 2LTVy4Gv76Dc to MeV5i7xXXFPH 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 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
Being able to reorder rendering commands leads to optimization opportunities in the graphics package. A graphics package being fed from a DisplayList either has to take the commands in the order given or implement their own storage format for the rendering data.
With this new dispatching mechanism, the graphics package can both query basic information about the recorded ops and even dispatch them by the index into the list. Query information includes either the "category" of the op (clip/transform/render, etc.) or a specific op type enum. The package can dispatch some categories (or ops) immediately and remember other categories (or ops) along with their state for dispatching later.