Skip to content

[Impeller] protect onscreen cmd buffer with render ready semaphore. - #161140

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
jonahwilliams:protect_onscreen
Jan 6, 2025
Merged

auto-submit[bot] merged 5 commits into
flutter:masterfrom
jonahwilliams:protect_onscreen

Conversation

@jonahwilliams

@jonahwilliams jonahwilliams commented Jan 5, 2025 •

Copy link
Copy Markdown
Contributor

Ensures that the onscreen command buffer is blocked via the render ready semaphore, instead of just the layout transition. I can confirm this fixes the rendering artifacts on the Samsung a50 - which I suspect are the same as the issues these other devices are having. Essentially, without the semaphore protecting the onscreen pass we can end up writing to the color attachment while it is still being read.

@github-actions github-actions Bot added the engine flutter/engine related. See also e: labels. label Jan 5, 2025
@jonahwilliams
jonahwilliams marked this pull request as ready for review January 6, 2025 17:36
@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 6, 2025
@auto-submit
auto-submit Bot added this pull request to the merge queue Jan 6, 2025
Merged via the queue into flutter:master with commit ffc7ced Jan 6, 2025
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 6, 2025
@jonahwilliams
jonahwilliams deleted the protect_onscreen branch January 6, 2025 21:22
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 7, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 7, 2025
mattkae pushed a commit to canonical/flutter that referenced this pull request Nov 19, 2026
…96339)

Part of flutter#196096

Vulkan GPU frame time metrics were reporting 0 ms because swapchain
presentation closed the GPU tracer frame scope before the onscreen
command buffer ended.

When flutter#161140 moved onscreen
command buffer submission into swapchain presentation, both the AHB and
KHR swapchains called `MarkFrameEnd` before ending the onscreen command
buffer. On top of that, the KHR swapchain ended the raw Vulkan command
buffer directly instead of calling `CommandBufferVK::EndCommandBuffer`,
which is responsible for recording the end timestamp. Because end
timestamps for the onscreen pass were dropped, single-pass frames only
had a start timestamp (0 ms duration) and multi-pass frames missed the
onscreen pass.

Both swapchains now end the onscreen command buffer through
`CommandBufferVK::EndCommandBuffer` before calling `MarkFrameEnd`, using
a cleanup guard so early returns still close the frame.

Measured locally on a Pixel 7 (`cubic_bezier_perf__timeline_summary`
with `EnableVulkanGPUTracing` enabled). Enabling
`EnableVulkanGPUTracing` for default-Impeller Android devicelab
benchmarks will follow in a separate PR:

| Metric | Before | After |
| :--- | ---: | ---: |
| `average_gpu_frame_time` | 0.0 ms | 1.67 ms |
| `90th_percentile_gpu_frame_time` | 0.0 ms | 3.45 ms |
| `99th_percentile_gpu_frame_time` | 0.0 ms | 4.25 ms |
| `worst_gpu_frame_time` | 0.0 ms | 4.50 ms |

## 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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants