Leveraging Rust and the GPU to render user interfaces at 120 FPS
Zed's GPUI framework hits 120 FPS by rendering the editor UI like a video game: rather than a general-purpose 2D vector renderer (Pathfinder proved too slow), it uses dedicated GPU shaders for a small set of primitives such as rectangles, shadows, text, icons and images, all described as data on the CPU and drawn with instanced rendering. Rounded rectangles come from a signed distance function evaluated in a Metal fragment shader. Drop shadows follow Evan Wallace's approximation, which pairs a closed-form erf-based Gaussian convolution on one axis with a few samples along the other. Text uses OS shaping via CoreText, with a per-frame cache of text-font pairs so only changed text gets reshaped.
Related posts
- Zed Weekly: #29
Zed mediumAdeptZed's port to GPUI 2 is nearing daily usability, and the team is focused on frame-rendering performance measured by holding tab-switch at 60Hz key repeat. Because every element is a boxed trait object, they replaced malloc with a custom thread-local bump arena that enforces safety dynamically instead of via lifetimes, and changed `Element::paint` to take `&mut self` to avoid heap-to-stack copies. The target is full-window redraws under 4ms on an M1, with view caching planned next. Other updates cover a better VS Code theme importer, focus handlers moved to run after each frame draw to fix a split-pane focus bug, and a port of the feedback UI.
- Optimizing the Metal pipeline to maintain 120 FPS in GPUI
Zed mediumAdeptZed's GPUI renderer dropped frames on Macs running in direct (non-composited) mode because `MetalRenderer::draw` blocked the main thread with `wait_until_completed`. In direct mode that call waits for pixels to reach the frame buffer, not just the compositor's intermediate surface. Switching to `wait_until_scheduled` exposed a CPU/GPU race on the shared instance buffer, fixed with a pool of instance buffers that are returned to the pool from a command-buffer completion handler. Dropped frames under ProMotion were fixed by presenting repeated frames for one second after the last input so the display stays at 120 Hz. When macOS later capped some users at 60 FPS, the team moved to `CVDisplayLink`, presents drawables via the command buffer without `presentsWithTransaction`, and keeps the synchronous path only for app startup and window resizes.
- Zed Weekly: #22
Zed easyNoviceZed team members report weekly progress: GPUI is being rewritten with a ported Metal renderer that uses plane-split for primitive draw ordering, multi-threaded entity access, and a MainThread<T: Context> wrapper so native UI APIs are only called from the main thread. Channels are being reworked to separate chat-style communication from DAG-structured project notes, with unread indicators, notifications, public channels and deep links on the way. Julia split markdown parsing from rendering for completion documentation, avoiding flicker when grammars load late and speeding up rendering. Other work covers Vue LSP and tree-sitter support, CPU and memory telemetry, and a fix for a follow-loop bug in collaboration.
- The Future of React Native Graphics: WebGPU, Skia, and Beyond
Shopify Engineering easyNoviceReact Native WebGPU, built on Google's Dawn, lets React Native apps run Three.js, React Three Fiber, TSL shaders, ComputeToys compute shaders and TensorFlow.js on Metal (iOS) and Vulkan (Android) with no changes, which collapses the separate OpenGL and Metal backends into one. Lessons from that work fed back into React Native Skia. Moving from a mutable C++ scene graph (SkiaDOM) to an immutable, Fabric-reconciler display list made animation up to 50% faster on iOS and nearly 200% faster on Android, while fixing 98% of reported Android crashes. Skia also gained macOS, tvOS and headless Node.js targets, and the experimental Skia Graphite backend previews automatic threading and two-way 2D/3D texture composition.
- Linux when?
Zed mediumAdeptZed's Linux port works by implementing GPUI's platform-agnostic `Platform` and `PlatformWindow` traits for Linux. Three months after open-sourcing, Zed compiles and runs usably on Linux. The hard parts were the fragmentation of the Linux desktop (distributions, packaging, X11 vs Wayland, desktop environments, audio servers) and replacing the Metal renderer. Community contributor kvark solved rendering with Blade, a Vulkan-based GPU abstraction, and other contributors added Wayland support, file dialogs and input fixes behind a shared `LinuxClient` trait.