You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Flutter GPU] Add Texture.fromImage to wrap a ui.Image's texture without a CPU round trip #188246
Rendering a widget subtree into a Flutter GPU texture currently requires a full CPU round trip. The only way to get widget content into a gpu.Texture today is
final image =await layer.toImage(...); // GPU renderfinal bytes =await image.toByteData(format: rawStraightRgba); // GPU to CPU readbackfinal texture = gpuContext.createTexture(StorageMode.hostVisible, w, h, ...);
texture.overwrite(bytes); // CPU to GPU upload
The readback and the upload are wasted work. On Impeller, the ui.Image returned by toImage already wraps a GPU resident impeller::Texture, and Flutter GPU shares the same impeller::Context as the UI renderer, so the texture is already usable without copying it anywhere.
Proposal
Add gpu.Texture.fromImage(ui.Image image) as the inverse of the existing Texture.asImage(). It would pull the impeller::Texture out of the image's DlImageImpeller and wrap it in a gpu.Texture, reading size and format back from the texture descriptor.
This is a small addition. The extraction already exists in the engine (DlImage::asImpellerImage() then GetImpellerTexture), and the wrapping mirrors Texture::AsImage.
Notes
Use the async toImage rather than toImageSync. The deferred image from toImageSync fills its texture on the raster thread after the call returns, so a synchronous wrap could capture an unrendered or null texture.
Textures from fromImage should be treated as sample only to start, since the caller does not own the descriptor.
Fail gracefully for non Impeller images, where asImpellerImage() returns null.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
[Flutter GPU] Add Texture.fromImage to wrap a ui.Image texture
[Flutter GPU] Add Texture.fromImage to wrap a ui.Image texture (flutt…
github-actions commentedon Jul 14, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.