mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-21 08:01:33 +01:00
e20d19d32f
## Summary When the first window is created, adapter selection tests each adapter by configuring the surface at 64x64 with the first format and alpha mode the surface reports. The renderer then configures the same surface again at the window's size with its preferred format. On the NVIDIA proprietary driver on X11, each swapchain creation waits on the X server for several refreshes, so the second configure adds a few hundred ms before the first frame. This makes the adapter test use the configuration the renderer will use (same format, alpha mode, present mode and size), and skips the renderer's own configure when the context was just created against that surface. Every candidate adapter is still tested by configuring the surface, so hybrid-GPU selection works as before. Windows that reuse an existing context, device recovery with an existing context, and the web path still configure in the renderer. Time from exec to first presented frame, `gpui` `hello_world` example (1000x1000 window), release-fast, 22 alternating runs each: | | min | median | max | |---|---|---|---| | main | 720 ms | 946 ms | 1053 ms | | this PR | 403 ms | 528 ms | 701 ms | The removed configure took 218-534 ms (median 316 ms) in those runs. Machine: Pop!_OS 24.04, GNOME on Xorg, RTX 4070 with driver 580.159.03, 4K and 1440p monitors. Other work was running on the machine at the time, so absolute numbers are noisy, but every patched run was faster than every unpatched one. On the same machine's integrated AMD GPU (Mesa RADV, `ZED_DEVICE_ID=0x164e`) each configure takes about 2-5 ms, so there is no measurable change. ## Testing - Ran `hello_world` on X11 with the NVIDIA GPU and the integrated AMD GPU: the first frame renders correctly, and window captures after resizing are pixel-identical to main's on both GPUs. Resizing and maximizing reach `update_drawable_size` with the new sizes, as on main. - Logged the configure calls made while creating the window: main makes two (64x64 `Bgra8UnormSrgb` in adapter selection, then 1000x1000 `Bgra8Unorm` in the renderer), this PR one (1000x1000 `Bgra8Unorm`). The startup resize and transparency updates don't reconfigure on either branch, because the size and alpha mode are unchanged. - `cargo test -p gpui_wgpu`, `./script/clippy -p gpui_wgpu`, `cargo fmt`. - Not tested: Wayland, multiple windows, device recovery. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). (No UI changes.) - [x] Tests cover the new or changed behavior. Release Notes: - Improved window startup time on Linux with NVIDIA GPUs. - [GPUI] Improved window startup time on Linux with NVIDIA GPUs.