Repository navigation
[Flutter GPU] End each pass when the next command is recorded - #194167
Merged
Merged
Conversation
9 of 10 tasks
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the Flutter GPU command buffer to explicitly manage the lifecycle of render and blit passes, ensuring that open passes are ended before new passes or copies are recorded, or when the command buffer is submitted. Feedback on the changes highlights a critical issue in the OpenGL ES backend where deferred passes are never encoded during submission due to the removal of the encoding loop. It is recommended to explicitly encode these deferred passes during submission and update the unit tests to verify this behavior.
walley892
approved these changes
Oct 19, 2026
A command buffer now records one pass at a time. Creating the next render pass, recording a copy, or submitting ends the open pass, and RenderPass.end() ends it explicitly. On Metal and Vulkan the ended pass is encoded at that point, before the next backend pass is created, so one command buffer can hold any number of passes. OpenGL ES still encodes every pass in creation order at submit, on the raster thread. Any call on an ended RenderPass throws a StateError naming what ended it. Creating a pass or recording a copy after submit throws a StateError. Fixes #193867.
bdero
force-pushed
the
bdero/flutter-gpu-pass-lifecycle
branch
from
October 19, 2026 23:05
83e96f5 to
cb39a29
Compare
bdero
added a commit
to bdero/flutter
that referenced
this pull request
Oct 20, 2026
Brings in master through the pass lifecycle change (flutter#194167), which this branch was stacked on and already contains, so the PR diff shows only the compute changes.
This was referenced Oct 21, 2026
mohamedalsamrai
pushed a commit
to mohamedalsamrai/flutter
that referenced
this pull request
Oct 26, 2026
Fixes flutter#188477, fixes flutter#188479, fixes flutter#188480, fixes flutter#193868, fixes flutter#193869, fixes flutter#193872. Part of flutter#188474 and flutter#188481. Adds compute to Flutter GPU on Metal and Vulkan. Stacked on flutter#194167. - Shader bundles (format version 3) carry each shader's storage buffers and compute workgroup size. - `gpuContext.createComputePipeline`, `CommandBuffer.createComputePass` and `ComputePass`, with storage, uniform and texture bindings, binding sets and `dispatch`. `gpuContext.supportsCompute` and the compute limits are exposed; on OpenGL ES compute is unsupported and the compute calls throw. - Impeller: workgroup sizes are checked against device limits when a pipeline is created, bindings persist across dispatches on Vulkan, dispatches and passes synchronize automatically, and reloading a compute shader no longer crashes. - End-to-end tests on Metal and Vulkan, including a compute pass writing vertices that a render pass draws. ## 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 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. - [ ] 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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [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/ [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
suryaKommana2662
pushed a commit
to suryaKommana2662/flutter
that referenced
this pull request
Oct 29, 2026
…r#194167) Fixes flutter#193867. Part of flutter#188474. A command buffer now records one pass at a time, so it can hold any number of passes on every backend. Before, every pass stayed open until submit, which on Metal limited a command buffer to one render pass. - Creating the next pass, recording a copy, or submitting ends the open pass, and `RenderPass.end()` ends it explicitly. On Metal and Vulkan the pass is encoded at that point. - Using an ended pass, or recording into a submitted command buffer, throws a `StateError` that says why. ## 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 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. - [ ] 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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [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/ [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
suryaKommana2662
pushed a commit
to suryaKommana2662/flutter
that referenced
this pull request
Oct 29, 2026
Fixes flutter#188477, fixes flutter#188479, fixes flutter#188480, fixes flutter#193868, fixes flutter#193869, fixes flutter#193872. Part of flutter#188474 and flutter#188481. Adds compute to Flutter GPU on Metal and Vulkan. Stacked on flutter#194167. - Shader bundles (format version 3) carry each shader's storage buffers and compute workgroup size. - `gpuContext.createComputePipeline`, `CommandBuffer.createComputePass` and `ComputePass`, with storage, uniform and texture bindings, binding sets and `dispatch`. `gpuContext.supportsCompute` and the compute limits are exposed; on OpenGL ES compute is unsupported and the compute calls throw. - Impeller: workgroup sizes are checked against device limits when a pipeline is created, bindings persist across dispatches on Vulkan, dispatches and passes synchronize automatically, and reloading a compute shader no longer crashes. - End-to-end tests on Metal and Vulkan, including a compute pass writing vertices that a render pass draws. ## 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 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. - [ ] 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/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [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/ [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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #193867. Part of #188474.
A command buffer now records one pass at a time, so it can hold any number of passes on every backend. Before, every pass stayed open until submit, which on Metal limited a command buffer to one render pass.
RenderPass.end()ends it explicitly. On Metal and Vulkan the pass is encoded at that point.StateErrorthat says why.Pre-launch Checklist
///).