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] Compute UV coordinates lazily in PositionUVWriter #50879

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

flar
Copy link
Contributor

@flar flar commented Feb 22, 2024

The stroking code was performing texture coordinate conversion on each created vertex. Since there were often very few calculations needed for each vertex, interspersing a coordinate transform with each vertex append was clogging up the code.

This change will defer the calculation of the texture coordinates until the end of the stroking process so that the polyline widening code can do its job efficiently and then later the coordinate conversion code can do its job also efficiently in a tight loop. This change also opened up the opportunity to optimize a common case (no effect transform) even more than before.

@flar
Copy link
Contributor Author

flar commented Feb 22, 2024

Here is an example of the expected improvements in performance on the stroke..._uv benchmarks:

Performance of aggressive vs lazy UV computations


const std::vector<TextureFillVertexShader::PerVertexData>& GetData() const {
const std::vector<TextureFillVertexShader::PerVertexData>& GetData() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that I removed the "const" qualifier here so that the code could lazily update the data_ array. The corresponding method in the regular PositionWriter is still declared "const" because it has no such lazy work to do and these 2 classes are "related" but do not inherit from each other.

I was waffling on whether both should be consistent in whether they are declared "const", for symmetry, or not...

Copy link
Member

Choose a reason for hiding this comment

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

I think that is probably fine

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

@flar flar added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 23, 2024
@auto-submit auto-submit bot merged commit 5d1c0d4 into flutter:main Feb 23, 2024
29 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 23, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Feb 23, 2024
…144049)

flutter/engine@fbc9b88...5d1c0d4

2024-02-23 flar@google.com [Impeller] Compute UV coordinates lazily in PositionUVWriter (flutter/engine#50879)
2024-02-23 skia-flutter-autoroll@skia.org Roll Skia from 49dd7ed24bec to fde4d63c5e61 (3 revisions) (flutter/engine#50917)

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 jimgraham@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
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants