Skip to content

Change default pipeline options to match production draw calls - #194597

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
walley892:change_default_variants
Oct 28, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
walley892:change_default_variants

Conversation

@walley892

Copy link
Copy Markdown
Contributor

#193319 revealed that in our golden test suite, 0% of draw calls were handled by a prewarmed pipeline variant.

This causes a first-frame shader cache miss 100% of the time - causing in the worst case a full re-compilation + link.

This change changes our defaults to better match what we actually request at draw time.

Running impeller_golden_tests with --shader-report before this change:

Draws covered by warmed variants: 0 of 620,533 (0.0%)

Running impeller_golden_tests with --shader-report after this change:

Draws covered by warmed variants: 610,441 of 620,533 (98.4%)

Without compiling additional variants, we can't get full coverage in our golden suite, but this change is directionally correct toward the goal of eliminating first-frame shader cache misses.

Fixes #194595

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///).
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Oct 16, 2026
@walley892

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 refactors pipeline prewarming configurations in ContentContext by introducing more granular options tailored to specific draw characteristics, such as triangle lists, triangle strips, opaque content, and subpasses without MSAA or depth/stencil. The feedback suggests changing the prewarming configuration for the fast_gradient pipeline from options_triangle to options_trianglestrip to prevent potential shader compilation misses at draw time when filling common geometries.

pipelines_->solid_fill.CreateDefault(*context_,
options_opaque_trianglestrip);
pipelines_->texture.CreateDefault(*context_, options_trianglestrip);
pipelines_->fast_gradient.CreateDefault(*context_, options_triangle);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The fast_gradient pipeline is warmed up here using options_triangle. However, like all other gradient pipelines (e.g., linear_gradient_ssbo_fill, radial_gradient_ssbo_fill), fast gradients are primarily used to fill geometries such as rectangles, rounded rectangles, and circles, which are drawn as triangle strips (PrimitiveType::kTriangleStrip). Using options_triangle here will cause a shader compilation miss at draw time when a fast gradient is used with these common geometries. It should be changed to options_trianglestrip to match the other gradient pipelines and ensure proper prewarming coverage.

Suggested change
pipelines_->fast_gradient.CreateDefault(*context_, options_triangle);
pipelines_->fast_gradient.CreateDefault(*context_, options_trianglestrip);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The only use of the FastGradientPipeline pipeline is in LinearGradientContents, which uses triangles

@walley892 walley892 added the CICD Run CI/CD label Oct 16, 2026
@walley892
walley892 requested a review from gaaclarke October 16, 2026 22:02
@walley892
walley892 marked this pull request as ready for review October 16, 2026 22:02

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#193319 revealed that in our golden test suite, 0% of draw calls were handled by a prewarmed pipeline variant.

My concern here is about over optimizing to match the a test runner's needs instead of what real world apps need. Did you look at this for doing something like running gallery or wonderous?

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

Copy link
Copy Markdown
Contributor

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 refactors pipeline initialization in ContentContext by introducing and applying more specific ContentContextOptions configurations, such as triangle versus triangle strip primitives, opaque variants, and configurations without MSAA or depth/stencil attachments. Unit tests are updated to align with these changes. Review feedback recommends resetting stencil_compare to CompareFunction::kAlways to prevent pipeline variants from inheriting non-default stencil modes, and initializing the fast_gradient pipeline with options_trianglestrip instead of options_triangle to prevent runtime shader cache misses.

Comment on lines +462 to +463
front_stencil.stencil_failure = StencilOperation::kKeep;
front_stencil.depth_stencil_pass = StencilOperation::kKeep;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

When creating pipeline variants, they are initialized from the default variant's descriptor. If the default variant uses a non-default stencil mode (such as kCoverCompareInverted used by clips), any stencil fields modified by that mode will be inherited by variants that use StencilMode::kIgnore because kIgnore does not overwrite them. To prevent this, stencil_compare should be reset to CompareFunction::kAlways along with the other stencil operations.

Suggested change
front_stencil.stencil_failure = StencilOperation::kKeep;
front_stencil.depth_stencil_pass = StencilOperation::kKeep;
front_stencil.stencil_compare = CompareFunction::kAlways;
front_stencil.stencil_failure = StencilOperation::kKeep;
front_stencil.depth_stencil_pass = StencilOperation::kKeep;

@walley892

Copy link
Copy Markdown
Contributor Author

My concern here is about over optimizing to match the a test runner's needs instead of what real world apps need. Did you look at this for doing something like running gallery or wonderous?

You're right that the test runner is a proxy/imperfect signal, and it's what flagged out these defaults as bad initially. But, looking at the callstack, you can see that the defaults we used were in principle never able to be used.

For example, the CirclePipeline geometry is always specified as kTriangeStrip and never as kTrainge (the default before this change)

PrimitiveType::kTriangleStrip, 4,

and the depth mode is always set as kGreaterEqual and never as kAlways (the default before this change)

opts.depth_compare = CompareFunction::kGreaterEqual;

Because of the defaults before, no default pipelines matched the requested variant - so this change should be an improvement across all apps.

I ran an ad-hoc test on Wondrous:

Draws hitting a warmed variant: 0.0% before -> 76.2% with these changes

@walley892
walley892 requested a review from gaaclarke October 16, 2026 23:13

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Okay, sounds good. Code is looking good. Let's get an automated devicelab test that reflects the thing you are optimizing and let's land it before this so we can get the measurement of the improvment. It's probably easiest to make a variant of the new_gallery test and measure the number of hit warmed up shaders.

@gaaclarke

Copy link
Copy Markdown
Member

Otherwise there's no way to make sure we maintain this if it is something we care about.

Although, are you expecting this to show up in some of the existing time benchmarks in a meaningful way?

@walley892

Copy link
Copy Markdown
Contributor Author

Although, are you expecting this to show up in some of the existing time benchmarks in a meaningful way?

Yeah, this should reduce the time to first frame rasterized metrics.

It's probably easiest to make a variant of the new_gallery test and measure the number of hit warmed up shaders

This is a good idea to prevent this happening again when we add new shaders. Will do

@gaaclarke

gaaclarke commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Yea, the nice thing about counting them directly is that it's less noisy.

@walley892
walley892 requested a review from gaaclarke October 27, 2026 18:06
gaaclarke
gaaclarke previously approved these changes Oct 27, 2026

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm!

@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2026
@auto-submit

auto-submit Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/194597, because - The status or check suite Presubmit has failed. Please fix the issues identified (or deflake) before re-applying this label.

@walley892

Copy link
Copy Markdown
Contributor Author

Oops. Test failure from the rebase on the benchmark PR

@walley892
walley892 requested a review from gaaclarke October 27, 2026 21:15
@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 28, 2026
Merged via the queue into flutter:master with commit 1e47dc5 Oct 28, 2026
24 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 28, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 28, 2026
flutter/flutter@d4c8577...0c2473c

2026-10-28 [email protected] Roll Packages from a8549ae to 13d38e0 (9 revisions) (flutter/flutter#195488)
2026-10-28 [email protected] Use int.oneBitCount in PersistentHashMap and scope 53-bit caps to JS (flutter/flutter#195005)
2026-10-28 [email protected] Roll pub packages (flutter/flutter#195483)
2026-10-28 [email protected] [iPhone Duo] Use the correct UIScreen to report the display size and update when fold/unfold (flutter/flutter#195199)
2026-10-28 [email protected] [fuchsia] Fix portable_ui_test.h includes for newer Fuchsia SDKs (flutter/flutter#195420)
2026-10-28 [email protected] Change default pipeline options to match production draw calls (flutter/flutter#194597)
2026-10-28 [email protected] Roll Fuchsia Test Scripts from 2T18KC7-LDQtmQiLP... to xl1LWBuppzu-BnOzV... (flutter/flutter#195450)
2026-10-27 [email protected] [flutter_tools] Inject dependencies into Darwin build targets, native assets, and Xcode build settings (flutter/flutter#194052)
2026-10-27 [email protected] Revert: Reland square corners fix (flutter/flutter#195436)
2026-10-27 [email protected] [flutter_tools] Add DeviceService app launch and flutter run support for tool extensions (flutter/flutter#194589)
2026-10-27 [email protected] [engine] Honor targetWidth/targetHeight for animated images (flutter/flutter#194615)
2026-10-27 [email protected] [Android][a11y] Set visibleToUser=false for hidden semantics nodes (flutter/flutter#194411)
2026-10-27 [email protected] Fix repo deletion test flake (flutter/flutter#195349)
2026-10-27 [email protected] Roll Packages from 23a05b6 to a8549ae (10 revisions) (flutter/flutter#195434)
2026-10-27 [email protected] [web] Capture pointers to the Flutter view so drags survive platform view iframes (flutter/flutter#195187)
2026-10-27 [email protected] [web] Add opt-in raw samples, measured sample count and warm-up phase hook to the web benchmark recorder (flutter/flutter#195118)
2026-10-27 [email protected] Link migration guide in deprecation messages (flutter/flutter#195361)
2026-10-27 [email protected] Pin basic_material_app_macos__compile to macOS 26 (flutter/flutter#195429)
2026-10-27 [email protected] Add benchmark for warmed pipeline usage (flutter/flutter#195001)
2026-10-27 [email protected] [flutter_tools] Add device log streaming support to DeviceService and ExtensionBackedDevice (flutter/flutter#194964)
2026-10-27 [email protected] Roll Dart SDK from 1d16c04dc346 to 65fc979759ca (4 revisions) (flutter/flutter#195383)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] 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

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…er#194597)

flutter#193319 revealed that in our
golden test suite, 0% of draw calls were handled by a prewarmed pipeline
variant.

This causes a first-frame shader cache miss 100% of the time - causing
in the worst case a full re-compilation + link.

This change changes our defaults to better match what we actually
request at draw time.

Running impeller_golden_tests with --shader-report before this change:

```
Draws covered by warmed variants: 0 of 620,533 (0.0%)
```

Running impeller_golden_tests with --shader-report after this change:

```
Draws covered by warmed variants: 610,441 of 620,533 (98.4%)
```

Without compiling additional variants, we can't get full coverage in our
golden suite, but this change is directionally correct toward the goal
of eliminating first-frame shader cache misses.

Fixes flutter#194595

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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 in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Change default pipeline options to better match production draw calls

2 participants