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

Add setImageSampler (for replacing setSampler) #37821

Merged
merged 11 commits into from
Nov 22, 2022

Conversation

bdero
Copy link
Member

@bdero bdero commented Nov 21, 2022

setImageSampler guarantees we don't need an additional texture/render pass per-sampler. It's possible for users to emulate the functionality of setSampler in-shader.

The intention is to do the following before the stable branch cut:

  1. Land this and roll into the framework.
  2. Migrate stuff in the framework from setSampler to setImageSampler.
  3. Remove setSampler.

I filed flutter/flutter#115794 along the way.

@bdero bdero self-assigned this Nov 21, 2022
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@bdero
Copy link
Member Author

bdero commented Nov 21, 2022

I'm working on testing this against the example apps we have floating around.

Copy link
Member

@zanderso zanderso left a comment

Choose a reason for hiding this comment

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

lgtm w/ nit.

@@ -4314,13 +4314,27 @@ class FragmentShader extends Shader {
_floats[index] = value;
}

/// Sets the sampler uniform at [index] to [image].
///
/// The index provided to setSampler is the index of the sampler uniform defined
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// The index provided to setSampler is the index of the sampler uniform defined
/// The index provided to setImageSampler is the index of the sampler uniform defined

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

/// Sets the sampler uniform at [index] to [sampler].
///
/// The index provided to setSampler is the index of the sampler uniform defined
/// in the fragment program, excluding all non-sampler uniforms.
///
/// All the sampler uniforms that a shader expects must be provided or the
/// results will be undefined.
///
/// Use of this method may result in poor performance with the Impeller backend.
Copy link
Member

Choose a reason for hiding this comment

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

I would be careful about describing something as having poor performance with no refernce point. I've seen users go to extensive lengths to avoid invoking apis that have warnings like this, sometimes exceeding the original performance cost.

Copy link
Member Author

Choose a reason for hiding this comment

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

SGTM, removed this.

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!

@bdero
Copy link
Member Author

bdero commented Nov 22, 2022

Added implementation for canvaskit

@bdero
Copy link
Member Author

bdero commented Nov 22, 2022

Smoke tested this on iOS and fixed an issue where the engine handle wasn't being passed in and it's working as expected now. Attempting to smoke test canvaskit.

@jonahwilliams
Copy link
Member

I wouldn't worry about canvaskit right now, the required Skia API isn't available in most engines and I'll probably disable shader compilation for the next stable

@bdero
Copy link
Member Author

bdero commented Nov 22, 2022

Alrighty, I'll go ahead and merge after this CI run then.

@bdero bdero added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 22, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Nov 22, 2022

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

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 22, 2022
@bdero bdero added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 22, 2022
@auto-submit auto-submit bot merged commit eba7ecd into flutter:main Nov 22, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 22, 2022
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Nov 22, 2022
…115842)

* eba7ecddc Add setImageSampler (for replacing setSampler) (flutter/engine#37821)

* 15dce5e11 Roll Skia from 57b4252cf211 to 550fd51bd254 (3 revisions) (flutter/engine#37830)

* 9b07044e7 Revert "[impeller] Remove declare_undefined_values (#37829)" (flutter/engine#37831)

* 1a6180869 Roll Dart SDK from 6b8e98070f26 to 27c45cd51796 (1 revision) (flutter/engine#37833)

* 8bc415423 Roll Skia from 550fd51bd254 to 94c63addc990 (1 revision) (flutter/engine#37834)

* 7b4291548 Roll Skia from 94c63addc990 to 0dec6d1823b3 (4 revisions) (flutter/engine#37836)

* a7fa7c6ec Roll Fuchsia Linux SDK from xBfEjlXUsix6Wka-i... to 5Xd8MJTM-pWPWCgUa... (flutter/engine#37840)

* b6e33b527 Roll Fuchsia Mac SDK from oaqX39ssn3PUxE9it... to mwKdD1jX_KVP1U76z... (flutter/engine#37844)

* 37e2aaa90 Roll Skia from 0dec6d1823b3 to 3b2d9e4bf668 (1 revision) (flutter/engine#37845)
shogohida pushed a commit to shogohida/flutter that referenced this pull request Dec 7, 2022
…lutter#115842)

* eba7ecddc Add setImageSampler (for replacing setSampler) (flutter/engine#37821)

* 15dce5e11 Roll Skia from 57b4252cf211 to 550fd51bd254 (3 revisions) (flutter/engine#37830)

* 9b07044e7 Revert "[impeller] Remove declare_undefined_values (flutter#37829)" (flutter/engine#37831)

* 1a6180869 Roll Dart SDK from 6b8e98070f26 to 27c45cd51796 (1 revision) (flutter/engine#37833)

* 8bc415423 Roll Skia from 550fd51bd254 to 94c63addc990 (1 revision) (flutter/engine#37834)

* 7b4291548 Roll Skia from 94c63addc990 to 0dec6d1823b3 (4 revisions) (flutter/engine#37836)

* a7fa7c6ec Roll Fuchsia Linux SDK from xBfEjlXUsix6Wka-i... to 5Xd8MJTM-pWPWCgUa... (flutter/engine#37840)

* b6e33b527 Roll Fuchsia Mac SDK from oaqX39ssn3PUxE9it... to mwKdD1jX_KVP1U76z... (flutter/engine#37844)

* 37e2aaa90 Roll Skia from 0dec6d1823b3 to 3b2d9e4bf668 (1 revision) (flutter/engine#37845)
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jan 19, 2023
…lutter#115842)

* eba7ecddc Add setImageSampler (for replacing setSampler) (flutter/engine#37821)

* 15dce5e11 Roll Skia from 57b4252cf211 to 550fd51bd254 (3 revisions) (flutter/engine#37830)

* 9b07044e7 Revert "[impeller] Remove declare_undefined_values (flutter#37829)" (flutter/engine#37831)

* 1a6180869 Roll Dart SDK from 6b8e98070f26 to 27c45cd51796 (1 revision) (flutter/engine#37833)

* 8bc415423 Roll Skia from 550fd51bd254 to 94c63addc990 (1 revision) (flutter/engine#37834)

* 7b4291548 Roll Skia from 94c63addc990 to 0dec6d1823b3 (4 revisions) (flutter/engine#37836)

* a7fa7c6ec Roll Fuchsia Linux SDK from xBfEjlXUsix6Wka-i... to 5Xd8MJTM-pWPWCgUa... (flutter/engine#37840)

* b6e33b527 Roll Fuchsia Mac SDK from oaqX39ssn3PUxE9it... to mwKdD1jX_KVP1U76z... (flutter/engine#37844)

* 37e2aaa90 Roll Skia from 0dec6d1823b3 to 3b2d9e4bf668 (1 revision) (flutter/engine#37845)
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 needs tests
Projects
No open projects
Archived in project
3 participants