Draw the desktop and apps on the GPU when there is one #3

Merged
nandi merged 4 commits from gpu-rendering into main 2026-12-01 00:51:00 +00:00
Owner

Summary

  • The host draws the desktop with OpenGL ES 3 when it finds a usable GPU. In a login session it draws straight into the display's own buffers. EGL and GLES are loaded at run time, so machines without a GPU keep drawing on the CPU.
  • Client buffers use one zwp_linux_dmabuf_v1 implementation (compositor/wayland/dmabuf.mbt). GPU buffers of any layout the driver can read are imported directly. Without a GPU, linear ARGB8888/XRGB8888 buffers are mapped and read on the CPU. This replaces the earlier linear-only version on main.
  • CHANDRA_GPU=0 keeps the desktop on the CPU and CHANDRA_GPU=1 forces the GPU. NVIDIA's proprietary driver stays on the CPU unless forced. If a session crashes within seconds of starting on the GPU, the next start uses the CPU once.
  • Fixes a startup trap from e2dc2bb: compositor/shell/backlight.mbt called getenv in a top-level value, which trapped compositor.wasm while it was being instantiated. The backlight root is now read on first use.
  • Adds a Show Desktop panel module and its generated interfaces, and a show-desktop toggle request.

Testing

  • scripts/test-native.py: 336 passed, 0 failed (build 7.8 s, tests 18.1 s). One ffmpeg recording test (compositor/host/screenshot_test.mbt) failed when run beside the others and passed when run alone.
  • New compositor/host/dmabuf_test.mbt covers import, capture, release, rejected buffers and client disconnect against a fake GPU.
  • just test-gpu (about 5 s): GPU and CPU drawing differ by at most 2 of 255 levels per channel; display buffers are exact at every rotation and scale.
  • moon check: 0 errors (723 warnings).
  • Headless benchmark at 1920x1080 on an Intel HD 4600:
    • Overview animation: 8 ms/frame on CPU, 1 ms on GPU.
    • Terminal scrolling: 5.1 ms/frame on CPU, 2.5 ms on GPU.
    • Host CPU use with vkcube (about 55 fps): 69% CPU vs 42% GPU.
    • Host CPU use with alacritty (about 54 fps): 75% CPU vs 54% GPU.
  • Not run: real page flips in a login session on hardware, the phone's GPU, AMD GPUs, and recovery after a GPU reset.
## Summary - The host draws the desktop with OpenGL ES 3 when it finds a usable GPU. In a login session it draws straight into the display's own buffers. EGL and GLES are loaded at run time, so machines without a GPU keep drawing on the CPU. - Client buffers use one `zwp_linux_dmabuf_v1` implementation (`compositor/wayland/dmabuf.mbt`). GPU buffers of any layout the driver can read are imported directly. Without a GPU, linear ARGB8888/XRGB8888 buffers are mapped and read on the CPU. This replaces the earlier linear-only version on `main`. - `CHANDRA_GPU=0` keeps the desktop on the CPU and `CHANDRA_GPU=1` forces the GPU. NVIDIA's proprietary driver stays on the CPU unless forced. If a session crashes within seconds of starting on the GPU, the next start uses the CPU once. - Fixes a startup trap from `e2dc2bb`: `compositor/shell/backlight.mbt` called `getenv` in a top-level value, which trapped `compositor.wasm` while it was being instantiated. The backlight root is now read on first use. - Adds a Show Desktop panel module and its generated interfaces, and a `show-desktop` toggle request. ## Testing - `scripts/test-native.py`: 336 passed, 0 failed (build 7.8 s, tests 18.1 s). One ffmpeg recording test (`compositor/host/screenshot_test.mbt`) failed when run beside the others and passed when run alone. - New `compositor/host/dmabuf_test.mbt` covers import, capture, release, rejected buffers and client disconnect against a fake GPU. - `just test-gpu` (about 5 s): GPU and CPU drawing differ by at most 2 of 255 levels per channel; display buffers are exact at every rotation and scale. - `moon check`: 0 errors (723 warnings). - Headless benchmark at 1920x1080 on an Intel HD 4600: - Overview animation: 8 ms/frame on CPU, 1 ms on GPU. - Terminal scrolling: 5.1 ms/frame on CPU, 2.5 ms on GPU. - Host CPU use with vkcube (about 55 fps): 69% CPU vs 42% GPU. - Host CPU use with alacritty (about 54 fps): 75% CPU vs 54% GPU. - Not run: real page flips in a login session on hardware, the phone's GPU, AMD GPUs, and recovery after a GPU reset.
nandi added 4 commits 2026-12-01 00:49:18 +00:00
The host's rasteriser has a GPU half (raster_gpu.c): the same primitives, drawn the same way, on
machines with a real GPU and OpenGL ES 3, straight into the display's buffers in a login session.
EGL and GLES are loaded at run time; without them everything is drawn on the CPU as before
(CHANDRA_GPU=0 does that too). zwp_linux_dmabuf_v1 lets apps draw on the GPU as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wasm compositor trapped at start since e2dc2bb: a top-level value called getenv.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add generated .mbti interfaces for show-desktop, its plasmoid, and the show-desktop-widget world
- Add a ToggleDesktop host request and publish_desktop_shown(Bool) for the panel to report desktop state
nandi merged commit d6709d2d31 into main 2026-12-01 00:51:00 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: experiments/chandra#3