Skip to content

[Impeller] Allow transfer writes after the Vulkan mipmap layout barrier - #194989

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
Telosnex:impeller-vk-mipmap-barrier
Nov 4, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:masterfrom
Telosnex:impeller-vk-mipmap-barrier

Conversation

@jpohhhh

@jpohhhh jpohhhh commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

BlitPassVK::OnGenerateMipmapCommand first moves every mip level to TransferDst, then blits into levels 1..N. That first barrier allowed only transfer reads as its destination access, so the blits' writes weren't ordered after the layout transition.

This changes the destination access to transfer writes, which is what the blits do in that layout. The destination stage was already the transfer stage.

Found with VK_LAYER_KHRONOS_validation 1.4.309 and synchronization validation on, on a Raspberry Pi 5 / CM5 (V3D 7.1, Mesa 26.2.1) running Impeller Vulkan through a custom embedder (flutter_pi).

Fixes: #194987

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

BlitPassVK::OnGenerateMipmapCommand first moves every mip level to
TransferDst, then blits into levels 1..N. That barrier allowed only
transfer reads, so the blits' writes weren't ordered after the layout
transition. Synchronization validation reports
SYNC-HAZARD-WRITE-AFTER-WRITE on vkCmdBlitImage.

Allow transfer writes, which is what the blits do in that layout.
@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 21, 2026

@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 updates the destination access mask in BlitPassVK::OnGenerateMipmapCommand from eTransferRead to eTransferWrite to address a write-after-write synchronization hazard, and adds a unit test to verify the initial barrier configuration. The review feedback recommends replacing a reinterpret_cast with a static_cast in the new unit test when downcasting the command buffer, adhering to the Google C++ Style Guide.

@gaaclarke
gaaclarke self-requested a review October 26, 2026 18:27
@gaaclarke gaaclarke added the CICD Run CI/CD label Oct 27, 2026
EXPECT_EQ(barriers[7].subresourceRange.levelCount, 6u);
}

TEST(BlitPassVKTest, MipmapGenerationInitialBarrierAllowsTransferWrites) {

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.

I think the test we actually want for this is running the blit pass with the synchronization validation layers enabled. @andywolff I know you were just looking into this. How feasible is this? Do we have an issue for it, do we want to hand it off?

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.

I just filed #195502

I recommend we note this area in that issue as one of the ones we want to include in the new sync validation CI shard, and approve this PR to proceed without blocking on that work

@gaaclarke

Copy link
Copy Markdown
Member

#195698 has landed on main, you can rebase now

@jpohhhh

jpohhhh commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Thank you! Rebased on main, and re-enabled Play/RendererTest.CanGenerateMipmaps/Vulkan in the sync validation list.

@jpohhhh
jpohhhh requested a review from gaaclarke November 3, 2026 02:01
@andywolff andywolff added the CICD Run CI/CD label Nov 3, 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!

@gaaclarke
gaaclarke requested a review from andywolff November 3, 2026 16:39
@andywolff

Copy link
Copy Markdown
Contributor

LGTM but ci.yaml validation failed, which means you need to do a merge. If you push a merge commit instead of rebasing, it'll keep the approvals

@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 4, 2026
@andywolff andywolff added autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD labels Nov 4, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 4, 2026
Merged via the queue into flutter:master with commit 7915d9f Nov 4, 2026
30 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 4, 2026
chingjun added a commit to chingjun/flutter that referenced this pull request Nov 5, 2026
…migration/phase0

The branch was 61 commits behind master. Merged rather than rebased: the
branch's commits are pushed and under review (PR flutter#196005).

Conflicts, resolved by hand:
- dev/bots/test.dart: master's flutter#195863 balances tool_tests_commands and
  web_tool_tests by duration through _selectWeightedToolTests (one
  durations file, dev/bots/tool_test_durations.json, for the three tool
  shards); the Bazel branches of the three shard runners now cover the
  paths it selects, as before over selectIndexOfTotalSubshard's.

Regenerated for master's rolls and renames:
- build_defs/repositories/deps.lock.bzl (gen_deps.dart): the Dart SDK roll
  to c9153304136a and its package revisions, the Fuchsia SDK and test
  scripts.
- build_defs/dart/pub.lock.bzl (gen_pub_lock.dart after `dart pub get` at
  the root and in lib/web_ui): the pubspec changes of master.
- engine/src/flutter/lib/ui/BUILD.bazel (gn_to_bazel): the GLES
  compositing unit test renamed to impeller_gles_without_surface_unittests.cc.
- engine/src/flutter/impeller/BUILD.bazel (gn_to_bazel): run_tests.py's
  Vulkan synchronization-validation list grew by the tests flutter#194989 fixed.
  `gn_to_bazel --check` is current.

Adjusted by hand for master's renames:
- dev/bots/BUILD.bazel and packages/flutter_tools/BUILD.bazel: the durations
  test is tool_test_durations_test over tool_test_durations.json and the
  test files of the commands, integration and web shards
  (`durations_shard_test_files`, was `integration_shard_test_files`).
- dev/bots/test/test_test.dart: the `_bazel` subshard test expects master's
  "Selecting subshard 1 of 3 (N of M tests, estimated weight W)".

Checked: gclient sync clean (Skia f96be51af95d, Dart c9153304136a);
gn_to_bazel 282/282 and --check current; bazel_tools 46/46; bazel_ci_test.py
23; pylint clean; Bazel analysis of //:framework_tests //:tool_tests
//:dart_tests //dev/bots:tests and of ci_host_debug_unopt (+tests),
android_debug, wasm_release, ci_android_release_arm64; `bazel test
//dev/bots:tests` green; dev/bots test_test.dart's Bazel tests green (its
`--dry-run prints every test` test depends on SHARD being set in the
environment, on master as here).

Note: master's flutter#195868 adds the mac_unopt builds as standalone bringup
builders under ci/builders/standalone/ (GN; the converter does not read
that directory). mac_unopt.json itself still carries --bazel.
@jpohhhh
jpohhhh deleted the impeller-vk-mipmap-barrier branch November 5, 2026 21:52
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

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] Vulkan synchronization validation reports three hazards in BlitPassVK and RenderPassBuilderVK

3 participants