Skip to content

Conversation

@walley892
Copy link
Contributor

Create a few thin wrappers around UniformFloatSlot that allow users to get Vector uniforms by name and set all elements in one go.

Before:

shader.getUniformFloat('uColor', 0).set(color.r);
shader.getUniformFloat('uColor', 1).set(color.g);
shader.getUniformFloat('uColor', 2).set(color.b);

After:

shader.getUniformVec3('uColor').set(color.r, color.g, color.b);

This enforces that the requested vector is actually of the requested size. For example:

shader.getUniformVec2('someVec3Uniform');

will fail instead of allowing partial uniform access.

Follow up

This doesn't add list or matrix datatypes, those will come later.
Also doesn't have anything super fancy like accessors/setters for individual elements.

Pre-launch Checklist

  • [ x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • [ x] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • [ x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • [ x] I signed the [CLA].
  • [ x] I listed at least one issue that this PR fixes in the description above.
  • [ x] I updated/added relevant documentation (doc comments with ///).
  • [ x] I added new tests to check the change I am making, or this PR is [test-exempt].
  • [ x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • [ x] All existing and new tests are passing.

@github-actions github-actions bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically labels Dec 16, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces convenient wrappers for setting vector uniforms by name, which is a great improvement for shader development ergonomics. The implementation adds getUniformVec{2,3,4} methods and corresponding UniformVec*Slot classes, along with size validation to prevent partial uniform access.

My review focuses on improving code maintainability by reducing duplication and fixing an issue in one of the new tests. Specifically, I've pointed out repeated logic in the getUniformVec* methods across different files and suggested refactoring. I also found a test case that seems to be using incorrect data and assertions, which I've flagged as critical to ensure test reliability. The other tests look good and cover the new error-handling logic well.

@walley892 walley892 requested a review from gaaclarke December 16, 2025 08:40
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

Looking good, just some minor cleanup

Copy link
Contributor

@eyebrowsoffire eyebrowsoffire left a comment

Choose a reason for hiding this comment

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

Web changes look good!

@walley892 walley892 requested a review from gaaclarke December 17, 2025 22:11
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

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

Some comments about the efficiency of the implementation.

Also, I see a lot of negative tests (fails if ...), but I don't see some positive tests that it actually returns the object if you make the right request. Did I miss something?

}

List<UniformFloatSlot> _getSlotsForUniform(String name, int size) {
final int dataSize = _program._getUniformVectorSize(name);
Copy link
Contributor

@flar flar Dec 19, 2025

Choose a reason for hiding this comment

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

This implementation is causing 2 lookups by name, can they be combined? It's an internal function so what about having the getIndex function take the size and it gets verified before returning the index (size of 0 or -1 null to indicate "I don't care about the size")?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, the way to do an optional parameter in Dart is int? and pass null for the access that doesn't require a size constraint.

Copy link
Contributor Author

@walley892 walley892 Dec 19, 2025

Choose a reason for hiding this comment

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

How's that looking?

/// }
/// ```
UniformVec2Slot getUniformVec2(String name) {
final List<UniformFloatSlot> slots = _getSlotsForUniform(name, 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the cost of creating a list in the _getSlots function vs. just returning the index (after verifying the size) and then constructing the slots inline here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if there's a differing cost for that kind of thing in Dart. I have it this way for code reuse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I'm not sure if this comment is dovetailing with your comment above or if it's a comment about the efficiency of returning lists in Dart

Copy link
Contributor

Choose a reason for hiding this comment

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

It's about unnecessary creation of lists. Maybe Dart is smart enough to optimize that out, I don't know.

@walley892
Copy link
Contributor Author

Some comments about the efficiency of the implementation.

Also, I see a lot of negative tests (fails if ...), but I don't see some positive tests that it actually returns the object if you make the right request. Did I miss something?

Thanks for the review. Added some happy path tests

Copy link
Contributor

@flar flar left a comment

Choose a reason for hiding this comment

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

LGTM

Merged via the queue into flutter:master with commit b51ad9d Dec 30, 2025
181 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 1, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 1, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 2, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 3, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 3, 2026
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 4, 2026
Roll Flutter from 60d8165 to 13b2b91 (34 revisions)

flutter/flutter@60d8165...13b2b91

2026-01-03 engine-flutter-autoroll@skia.org Roll Skia from 229239fde9e9 to 2f257bbea23a (1 revision) (flutter/flutter#180461)
2026-01-03 engine-flutter-autoroll@skia.org Roll Dart SDK from be125a188f41 to 8e711d05b844 (1 revision) (flutter/flutter#180460)
2026-01-03 engine-flutter-autoroll@skia.org Roll Dart SDK from 0e6419d14382 to be125a188f41 (1 revision) (flutter/flutter#180454)
2026-01-02 engine-flutter-autoroll@skia.org Roll Dart SDK from 5e4b7dc3a134 to 0e6419d14382 (4 revisions) (flutter/flutter#180449)
2026-01-02 engine-flutter-autoroll@skia.org Roll Skia from 5a8d480365e2 to 229239fde9e9 (9 revisions) (flutter/flutter#180448)
2026-01-02 47866232+chunhtai@users.noreply.github.com Relands "Feat: Add a11y for loading indicators (#165173)" (flutter/flutter#178402)
2026-01-02 bungeman@chromium.org Add SK_SUPPORT_LEGACY_UNSPANNED_GRADIENTS to SkUserConfig.h (flutter/flutter#180443)
2026-01-02 jmccandless@google.com Some cleanup of cross library test imports (flutter/flutter#177029)
2026-01-02 engine-flutter-autoroll@skia.org Roll Dart SDK from df175c998021 to 5e4b7dc3a134 (1 revision) (flutter/flutter#180366)
2026-01-02 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from nzgy72aZ9kvHxTDM6... to 1pPgo5DrQ5ITdz3Uy... (flutter/flutter#180438)
2026-01-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 23suNuzNQCwRbDrys... to nzgy72aZ9kvHxTDM6... (flutter/flutter#180424)
2025-12-31 srawlins@google.com Remove @OverRide annotations from things which are not overrides (flutter/flutter#180417)
2025-12-31 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from t1eBl_kzKGV5K28OU... to 23suNuzNQCwRbDrys... (flutter/flutter#180409)
2025-12-31 engine-flutter-autoroll@skia.org Roll Skia from 8851d5318c9d to 5a8d480365e2 (1 revision) (flutter/flutter#180400)
2025-12-31 ahmedsameha1@gmail.com Make sure that a DecoratedBox doesn't crash in 0x0 environment (flutter/flutter#180329)
2025-12-31 engine-flutter-autoroll@skia.org Roll Skia from d0e12d575173 to 8851d5318c9d (2 revisions) (flutter/flutter#180399)
2025-12-31 iliyazelenkog@gmail.com Improve Container color/decoration error message clarity (flutter/flutter#178823)
2025-12-30 ahmedsameha1@gmail.com Make sure that a CheckedModeBanner doesn't crash in 0x0 environment (flutter/flutter#180280)
2025-12-30 engine-flutter-autoroll@skia.org Roll Skia from 32c27424accb to d0e12d575173 (1 revision) (flutter/flutter#180394)
2025-12-30 dkwingsmt@users.noreply.github.com [Framework] iOS style blurring and `ImageFilterConfig` (flutter/flutter#175473)
2025-12-30 evanwall@buffalo.edu Fix issue with getUniformFloat crashing with hot reload (flutter/flutter#180138)
2025-12-30 jmccandless@google.com Test cross import lint (flutter/flutter#178693)
2025-12-30 engine-flutter-autoroll@skia.org Roll Skia from d64da765cee6 to 32c27424accb (1 revision) (flutter/flutter#180393)
2025-12-30 engine-flutter-autoroll@skia.org Roll Skia from 4c438e0537fc to d64da765cee6 (1 revision) (flutter/flutter#180390)
2025-12-30 engine-flutter-autoroll@skia.org Roll Packages from b3c3ca8 to 30dd810 (1 revision) (flutter/flutter#180388)
2025-12-30 engine-flutter-autoroll@skia.org Roll Skia from 27b587c4b160 to 4c438e0537fc (1 revision) (flutter/flutter#180384)
2025-12-30 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from DdllqZRZYriOd7Q8v... to t1eBl_kzKGV5K28OU... (flutter/flutter#180378)
2025-12-30 engine-flutter-autoroll@skia.org Roll Skia from 11690456a90d to 27b587c4b160 (1 revision) (flutter/flutter#180377)
2025-12-30 evanwall@buffalo.edu Allow setting vector uniforms by name. (flutter/flutter#179927)
2025-12-30 engine-flutter-autoroll@skia.org Roll Skia from 7abf754bce14 to 11690456a90d (6 revisions) (flutter/flutter#180374)
2025-12-29 logic@deltaq.org Add support for Shift-Delete, Ctrl-Insert and Shift-Insert (flutter/flutter#178561)
2025-12-29 engine-flutter-autoroll@skia.org Roll Skia from c85d3e2b12d7 to 7abf754bce14 (1 revision) (flutter/flutter#180371)
2025-12-29 engine-flutter-autoroll@skia.org Roll Packages from 2164da9 to b3c3ca8 (2 revisions) (flutter/flutter#180365)
2025-12-29 engine-flutter-autoroll@skia.org Roll Skia from c29a475066f5 to c85d3e2b12d7 (1 revision) (flutter/flutter#180363)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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

...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels. platform-web Web applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants