Repository navigation
Read a Linux window’s frame back with render-to-image - #9
Open
francois-unity wants to merge 2 commits into
Open
francois-unity wants to merge 2 commits into
francois-unity wants to merge 2 commits into
Conversation
chris-addison
force-pushed
the
unity/a11y-automation
branch
from
October 6, 2026 18:24
2805d34 to
33d34a1
Compare
`render-to-image` (HUB-7425) compiles `Window::render_to_image` outside `test-support`, but no Linux window implemented it, so the trait’s default answered “not implemented for this platform”. Linux windows draw through the WGPU renderer, which already has an offscreen readback for visual tests: it renders the scene into a texture, copies that to a buffer and maps it. That readback was compiled only under `gpui_wgpu`’s `test-support`. Give `gpui_wgpu` a `render-to-image` feature that compiles the readback alone (`WgpuHeadlessRenderer` stays test-only), forward it from `gpui_linux` and `gpui_platform`, and let the X11 and Wayland windows call it. The readback now refuses while a window recovers a lost device, as the DirectX one does, rather than panicking on the torn-down GPU resources.
The offscreen readback copies 8-bit rows and only swizzles `Bgra8Unorm`, which held while it served the headless renderer alone. A window’s surface can pick another format when it offers neither 8-bit UNORM one, so refuse those with an error rather than returning swapped channels or a blank image. Test the device-lost half of the guard too: the first test only covered missing GPU resources, so dropping the `device_lost()` check kept it green. The refusal now names both states, and the macOS `wgpu` stub’s comment no longer claims the readback needs `test-support`.
francois-unity
force-pushed
the
unity/HUB-8070-linux-render-to-image
branch
from
October 7, 2026 14:48
7e90349 to
86a6758
Compare
francois-unity
marked this pull request as ready for review
October 7, 2026 20:49
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.
Lets a Linux window read its frame back through
Window::render_to_imagein arender-to-imagebuild, as macOS and Windows windows already can.Why:
render-to-image(HUB-7425) compilesWindow::render_to_imageoutsidetest-support, but no Linux window implemented it, so the trait’s default answered “not implemented for this platform”. Linux windows draw through the WGPU renderer, which already has an offscreen readback for visual tests, compiled only undergpui_wgpu’stest-support. The native Unity Hub needs it for its e2e screenshots on Linux CI, under Xvfb (HUB-8070).gpui_wgpugets arender-to-imagefeature that compilesWgpuRenderer::render_to_imagewithout the rest oftest-support(WgpuHeadlessRendererstays test-only).gpui_linuxgets arender-to-imagefeature, forwarded togpui_wgpu, andX11WindowandWaylandWindowhandrender_to_imageto their renderer.gpui_platform’srender-to-imageturns ongpui_linux/render-to-image. The readback refuses while a window recovers a lost device, as the DirectX one does, rather than panicking on the torn-down GPU resources.Bgra8Unorm, which held while it served the headless renderer alone. A window surface can pick another format, so it now refuses those with an error rather than returning swapped channels or a blank image. A second test covers the device-lost half of the guard, and the macOSwgpustub’s comment no longer claims the readback needstest-support.Rebased onto
unity/a11y-automationat33d34a1e35(upstreame8d5955b); the patches are unchanged.How to test
--features e2erelease build compiled this (as a git dependency, so errors only, not lints), and its devtoolsscreenshotwrote a full 1280×800 frame at scale 1 on 3 fresh launches, identical outside a live banner (Unity Hub run 37494475706, private).cargo +1.98.1 test -p gpui_ce_wgpu --features test-support --lib: 32 tests pass, includingrender_to_image_refuses_without_gpu_resourcesandrender_to_image_refuses_once_the_device_is_lost, each failing without its half of the guard.cargo +1.98.1 clippy --no-deps -p gpui_ce_wgpu --lib --features render-to-image -- -D warnings, and the same with--all-targets --features test-support,render-to-image, are clean.render-to-image, so on a Linux machine also runcargo clippy -p gpui_ce_linux --features render-to-image -- -D warningsandcargo clippy -p gpui_ce_platform --features render-to-image -- -D warnings.unity/HUB-8070-hub-pin-2,8beebe0250, overunity/HUB-8048-hub-pin-3).macOS’s opt-in
wgpurenderer still answers with its stub; it could switch to this readback in a follow-up.