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] Use Wang's formula for quad/cubic subdivision. #52079

Merged

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Apr 12, 2024

Use a faster method to compute the number of subdivisions of quadradic and cubic curves. Unlike the adaptive subdivison we use this may give us more line segments around straight-ish parts of a curve ... but who cares! the rasterizer can handle it. This is enough to lop off about 2ms from the animated tessellation benchmark (5.5 to 3.5 on a Pixel 7), and there are some additional savings we can book by removing some of the incidental allocations. This part will be done in a follow up (#52078).

Before

image

After

image

From looking at the proproptions I think this is in the 3x-5x faster range.

Code originally taken from https://github.com/google/skia/blob/main/src/gpu/tessellate/WangsFormula.h

@jonahwilliams jonahwilliams marked this pull request as ready for review April 13, 2024 01:54
@@ -78,30 +78,6 @@ TEST(TessellatorTest, TessellatorBuilderReturnsCorrectResultStatus) {

ASSERT_EQ(result, Tessellator::Result::kInputError);
}

// More than uint16 points, odd fill mode.
{
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 testing a case that no longer matters since we don't use the tessellator. i suspect it broke because we're now generating fewer line segments, since our cubic division isn't as cranky.

As a follow up I plan to delete most of this code.

@jonahwilliams
Copy link
Member Author

Note: if you zoom in to the remaining overhead, it can be seen that most of it is temporary allocation related:

image

@jonahwilliams jonahwilliams changed the title [Impeller] use wangs formula for quad/cubic division. [Impeller] use Wang's formula for quad/cubic division. Apr 13, 2024
@jonahwilliams jonahwilliams changed the title [Impeller] use Wang's formula for quad/cubic division. [Impeller] Use Wang's formula for quad/cubic subdivision. Apr 13, 2024
@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 #52079 at sha a7288ec

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Just a minor nit but otherwise LGTM. I don't think we should care about the segment count either. This is great.

return std::sqrt(nn.x + nn.y);
}

static inline Point Max(Point a, Point b) {
Copy link
Member

Choose a reason for hiding this comment

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

Don't we already have Point::Max and Point::GetLength?

Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to Point::Max. The length measurement is different however.

@chinmaygarde
Copy link
Member

None of the golden diffs are unexpected either.

@flutter-dashboard
Copy link

Golden file changes are available for triage from new commit, Click here to view.

Changes reported for pull request #52079 at sha ff75dfd

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 15, 2024
@auto-submit auto-submit bot merged commit 96365c5 into flutter:main Apr 15, 2024
31 checks passed
@jonahwilliams jonahwilliams deleted the use_wangs_formula_for_division branch April 15, 2024 18:05
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 16, 2024
…146790)

flutter/engine@07ae93c...503e7e8

2024-04-15 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] moved to bgra10_xr (#52019)" (flutter/engine#52140)
2024-04-15 [email protected] Roll Skia from d27e288efd54 to 0b5df0201734 (1 revision) (flutter/engine#52132)
2024-04-15 [email protected] Roll Skia from 0fe107da5a4e to d27e288efd54 (6 revisions) (flutter/engine#52130)
2024-04-15 [email protected] [Impeller] moved to bgra10_xr (flutter/engine#52019)
2024-04-15 [email protected] Roll Skia from 9e20a146c024 to 0fe107da5a4e (33 revisions) (flutter/engine#52129)
2024-04-15 [email protected] [Impeller] Use Wang's formula for quad/cubic subdivision. (flutter/engine#52079)
2024-04-15 [email protected] [Impeller] organize shaders a bit, make filter shaders use same vertex source. (flutter/engine#52113)

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 [email protected],[email protected],[email protected] 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
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
…lutter#146790)

flutter/engine@07ae93c...503e7e8

2024-04-15 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] moved to bgra10_xr (flutter#52019)" (flutter/engine#52140)
2024-04-15 [email protected] Roll Skia from d27e288efd54 to 0b5df0201734 (1 revision) (flutter/engine#52132)
2024-04-15 [email protected] Roll Skia from 0fe107da5a4e to d27e288efd54 (6 revisions) (flutter/engine#52130)
2024-04-15 [email protected] [Impeller] moved to bgra10_xr (flutter/engine#52019)
2024-04-15 [email protected] Roll Skia from 9e20a146c024 to 0fe107da5a4e (33 revisions) (flutter/engine#52129)
2024-04-15 [email protected] [Impeller] Use Wang's formula for quad/cubic subdivision. (flutter/engine#52079)
2024-04-15 [email protected] [Impeller] organize shaders a bit, make filter shaders use same vertex source. (flutter/engine#52113)

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 [email protected],[email protected],[email protected] 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
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants