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] Optimize the calculation of interpolant value of linear gradient #40085

Merged
merged 3 commits into from Mar 8, 2023

Conversation

ColdPaleLight
Copy link
Member

@ColdPaleLight ColdPaleLight commented Mar 6, 2023

Optimized the calculation method of t to avoid sqrt caused by calling the function length.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

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.

It would be great to have malioc traces of this.

@jonahwilliams
Copy link
Member

I suspect we didn't get any malioc traces because there was no change in the statistics?

@ColdPaleLight
Copy link
Member Author

Sorry, there are no malioc traces of this. This PR is purely from the level of code optimization.
The implementation of this PR is consistent with Skia.
https://github.com/google/skia/blob/main/src/sksl/sksl_graphite_frag.sksl#L392-L397

@ColdPaleLight ColdPaleLight added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 7, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 7, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 7, 2023

auto label is removed for flutter/engine, pr: 40085, due to - The status or check suite Linux Fuchsia FEMU has failed. Please fix the issues identified (or deflake) before re-applying this label.

@jonahwilliams
Copy link
Member

Sorry, there are no malioc traces of this. This PR is purely from the level of code optimization.
The implementation of this PR is consistent with Skia.

We run malioc automatically on CI, so the fact that there was no test failure indicates that both this shader and the original compile to roughly the same code, at least for GLSL shaders

@ColdPaleLight
Copy link
Member Author

Sorry, there are no malioc traces of this. This PR is purely from the level of code optimization.
The implementation of this PR is consistent with Skia.

We run malioc automatically on CI, so the fact that there was no test failure indicates that both this shader and the original compile to roughly the same code, at least for GLSL shaders

Ahh, I see. I ran malioc locally, and the result after the change is indeed the same as before. I guess it might be that the sqrt on the gpu is not as time consuming as I thought. Based on this fact, I think this PR can be closed.

@chinmaygarde
Copy link
Member

@ColdPaleLight I think in this case, it could just be that the compiler applied the same optimizations you did. But this is again the ARM Mali Compiler and different compilers are different. We just use malioc to ensure we are making measurable improvements. But, sadly, we cannot measure everything everywhere. I still think this is a good optimization and its readable and maintainable. I'd vote to keep this in even if its a wash for malioc.

I'm glad you are considering shader quality and we could certainly use all the help we can get. This work will come in handy especially on Android. A quick introduction to reading malioc traces is here. An instance of measurable performance optimizations based on malioc traces is here. If you know of other ways of measurably improving shader quality, let's chat! We wired up malioc just as one way of giving us some guidance so there is less guesswork. There may be other better ways as well.

@ColdPaleLight ColdPaleLight reopened this Mar 8, 2023
@ColdPaleLight
Copy link
Member Author

@chinmaygarde Thanks for your information!

@ColdPaleLight ColdPaleLight added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 8, 2023
@auto-submit auto-submit bot merged commit 694a14c into flutter:main Mar 8, 2023
35 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 8, 2023
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
No open projects
Archived in project
3 participants