Watch
1
Fork
You've already forked gpui-afogados
0
0

Latest commit

maotovisk
Subpixel text: write alpha when drawing into a rounded group's transparent layer
Some checks failed
CI / Test (ubuntu-latest) (push) Failing after 3s
CI / Lint and upstream check (push) Failing after 3s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
ce5a8ff 2026-11-19 20:58:58 -03:00 436 commits
2026-09-22 09:57:02 +08:00
2026-11-16 10:05:35 +08:00
2026-09-22 09:57:02 +08:00
2026-11-16 10:05:35 +08:00

gpui-afogados

gpui-fast (Zed's GPUI with retained views, scroll layers and window composition) with the patches the afogados desktop app is built on. Everything here is Apache-2.0 (LICENSE-APACHE); the upstream code is © Zed Industries and the gpui-fast authors. gpui-fast's own README follows our section.

Layout

Branch What
upstream Meant to mirror gpui-fast's main (https://github.com/longbridge/gpui-fast); until it is moved it still holds the Zed import (same as zed-upstream). UPSTREAM names the Zed commit gpui-fast imported.
main gpui-fast plus our patches, one commit per feature. This is what the app depends on. It moved from the Zed-based fork in merge 3ac461d (2026-11-13), whose first parent is the old history.
zed-main, zed-upstream The fork as it was until 2026-11-13: Zed's GPUI at 4a6121bb plus the same patches.

Patches on main

"On gpui-fast" says what changed when the patch moved from Zed's GPUI to gpui-fast (2026-11-13).

Commit What On gpui-fast
External video frames VideoFrame (NV12/P010; DMA-BUF, D3D11 shared handle or CPU planes), surface() for external frames, and the wgpu renderer importing and sampling them, so a hardware-decoded frame is drawn with no copy. gpui-fast draws every frame through gpui_wgpu/src/fast/frame.rs; the surfaces are prepared in record_with and drawn in draw_scene. gpui-fast's rounded clip stack does not clip them (a video carries its own radii).
Windows video surfaces The D3D11 renderer draws VideoFrames (it drew nothing before): CPU frames into R8/R8G8 textures with UpdateSubresource, and D3D11 shared NV12/P010 textures opened once with OpenSharedResource1 and sampled through two plane views without a lock (the producer guarantees the picture is whole on the GPU and the texture stays unreferenced while reused; gpui_windows/src/video_import.rs, surface_vertex/surface_fragment in shaders.hlsl). Publishes the adapter LUID and whether shared import works. A failed import turns it off for the process, and decoders then send CPU frames. The YCbCr matrix moved to gpui::video_yuv_to_rgb, shared with wgpu. Drawn in gpui_windows/src/fast/frame.rs's draw_scene_masked. The rounded clip stack wraps surface_fragment like the other fragments. Checked with video_surface pixel tests (CPU + shared) and D3DCompile; run in afogados_desktop (H.264 1080p60).
Element transform Styled::transform_scale / transform_translate: a CSS-like scale/translate for an element and its subtree, applied on the CPU to each primitive as it enters the scene, so every renderer draws it with no shader change. Painting only: layout and hit-testing are untouched. A view prepainted inside a subtree with a non-identity transform is built again rather than drawn from last frame (Window::afg_with_transform_prepaint).
Smooth wheel scrolling Window::set_smooth_wheel_scroll: wheel notches become per-frame pixel deltas along Chromium's curve (200 ms falling to 100 ms by distance, retargeting mid-run). Trackpad and touch are untouched. Unchanged.
Animated list scroll ListState::scroll_to_reveal_item_animated / scroll_to_center_item_animated: Chromium's programmatic curve (cubic-bezier(0.4, 0, 0, 1), sqrt(px) frames, at most 1500 ms), stepped by the list's prepaint, ending on its exact anchor. scroll_to_bottom_animated: a short ease-out (cubic, 150–280 ms by sqrt(px)) to the tail that resumes tail-following when it lands (a chat's "jump to latest"). scroll_to_reveal_item keeps gpui-fast's deferred reveal; starting and stepping an animation bumps the list's version.
Chat list alignment ListAlignment::TopUnlessOverflowing: top while the content fits, pinned to the end and following once it overflows; re-anchors after the viewport shrinks. Unchanged.
Letter spacing Styled::letter_spacing: CSS tracking in pixels through TextRun/FontRun into cosmic-text. macOS/Windows carry the field but their shapers do not apply it yet. gpui-fast's number shaping leaves a run with letter spacing to the platform; its recent-shapes cache keys on the runs.
img aspect ratio img ignores the picture's intrinsic ratio when width and height are both set. Unchanged.
uri-list Linux clipboard and drop read text/uri-list file lists in one place. Unchanged.
Display-size images RenderImage::with_display_size: a downscaled copy laid out at the original's size. Unchanged.
Windows run-time shaders Release builds without fxc.exe (cross builds) embed the HLSL and compile it with D3DCompile on first use. Embeds gpui-fast's staged rounded_clip_shaders.hlsl instead of src/shaders.hlsl. Compiled for x86_64-pc-windows-msvc, not yet run on Windows.
Rounded clip compilation Reuses the root primitive buffers when compiling rounded overflow groups and keeps a single retained root paint stream. The renderer layer graph and retained paint ranges keep their existing representation.
End of a list A list whose last rows exactly fill the viewport stays at its end (it used to jump to the top on the next wheel step); ListState::unmeasured_item_count. Carried from the Zed-based "Rounded content masks" commit.
Runtime shader test on CRLF Compare the expanded shader and embedded include after newline normalization. Test-only: the staged shader is already normalized line by line; Windows CRLF checkouts otherwise fail the include assertion despite compiling every entry point.
Windows overlay popup WS_POPUP framing, no DWM border/corners on transparent popups; empty input region enables click-through; capture-exclusion API delegates to WDA_EXCLUDEFROMCAPTURE. Additive window APIs; normal windows unchanged. Built in the app; border, cross-process click-through and capture exclusion not checked live.
Mirrored video surfaces Surface::mirrored / Window::paint_video_mirrored, default off; flips texture X in both video shaders without flipping bounds or clipping. Flag travels with retained PaintSurface; owning view must notify when changed. Windows offscreen D3D11 mirroring, CPU-upload and shared-texture tests pass; Linux runtime not checked.
Page zoom Window::set_zoom scales rendering at device resolution and converts viewport, pointer events and IME coordinates; default 1. Refreshes the window on change so retained layout and paint are rebuilt. The reentrant callback replacement converts both immediate and queued platform input into zoomed coordinates once at delivery. Pointer regression tests cover 50–200% zoom; native Windows live verification remains pending.

Not carried: "Rounded content masks" (overflow-hidden clipping children to rounded corners) and its HLSL follow-up. gpui-fast clips rounded overflow itself (fast/rounded_clip.rs, zed#37480).

Using it

Side by side with the app (what afogados_desktop does):

gpui = { path = "../gpui-afogados/crates/gpui" }
gpui_platform = { path = "../gpui-afogados/crates/gpui_platform", default-features = false, features = ["wayland", "x11", "font-kit"] }
reqwest_client = { path = "../gpui-afogados/crates/reqwest_client" }

Moving to a newer gpui-fast

git remote add gpui-fast https://github.com/longbridge/gpui-fast.git   # once
git fetch gpui-fast
git checkout upstream && git merge --ff-only gpui-fast/main
git checkout main && git rebase upstream    # replays our patches; fix conflicts per commit
cargo test -p gpui --lib

Adding a patch

One commit per feature on main, with what it adds and why in the message, and a row in the table above. Keep platform-neutral API in crates/gpui and each renderer's side in its own crate (gpui_wgpu for Linux, gpui_windows for Direct3D 11), so a feature that only one renderer has yet is visible in the diff.


GPUI Fast

A performance-focused fork of Zed's GPUI with incremental rendering and native window composition. v0.1.0 is available on crates.io. The project remains experimental.

  • Retained Mode reuses unchanged views, layout nodes and text measurements.
  • Scroll layers reuse cached GPU tiles and list rows while scrolling, on macOS, Linux and Windows.
  • Window composition embeds native content while keeping GPUI menus, popovers and dialogs above it.

Performance vs GPUI

The gpui_perf showcase is a component gallery written the way GPUI Kit's is: a sidebar of 243 pages, a 5,000-row data table, a list of 5,000 messages, and a trading workspace that a stream of quotes updates. Built once on GPUI Fast and once on upstream GPUI (the gpui-pre 0.3.7 snapshot), scrolling at 32 px a frame, at up to 144 frames per second on Linux, release builds. Main-thread CPU per frame (median) and the CPU of the whole process (100% = one core):

Scenario GPUI GPUI Fast
A spinner animating 5.91 ms, 85% CPU 0.73 ms, 11% CPU (−88%)
Scrolling the sidebar 5.95 ms, 86% CPU 0.79 ms, 12% CPU (−87%)
Scrolling a page of components 5.96 ms, 82% CPU 0.79 ms, 12% CPU (−87%)
Scrolling the data table 3.07 ms, 44% CPU 0.54 ms, 8% CPU (−82%)
Refreshing the table every 33 ms 11% CPU 2% CPU
Scrolling the list 2.66 ms, 39% CPU 0.39 ms, 6% CPU (−85%)
Streaming quotes into the workspace 5.06 ms, 43% CPU 1.35 ms, 15% CPU (−73%)
Scrolling the workspace's watchlist 5.23 ms, 77% CPU 1.33 ms, 24% CPU (−75%)
Hovering the workspace's watchlist 5.16 ms, 42% CPU 1.32 ms, 14% CPU (−74%)

Each figure is the mean of two runs alternating between the two builds. While the watchlist scrolls, GPUI draws 124 frames a second and GPUI Fast 144, so that row's process CPU does not compare directly. Results depend on the workload. To reproduce:

cargo run -p gpui_perf --release -- --auto
cargo run -p gpui_perf --release --no-default-features --features upstream -- --auto

In GPUI Kit's own story gallery (gpui-pre 0.3.9 against GPUI Fast 0.1.7, 60 Hz), scrolling used less CPU on 75 of 76 stories, 37% less on average; see Story scroll CPU against gpui-pre.

Retained Mode

GPUI Fast tracks rendering dependencies and rebuilds only what changed: a window of 60 panel views that stays still costs 0.19 ms a frame instead of 3.31 ms with retention turned off. See Retained Mode and Scroll layers for measurements and implementation details.

Window composition

Opt-in composition supports macOS, Windows and Linux (Wayland and X11), based on zed#62379. GPUI menus, popovers and dialogs, including their shadows and translucent backdrops, render above the native content on all three:

Platform Native content GPUI overlays
macOS AppKit view (WKWebView) Overlay layer
Windows WebView2 composition Overlay layer
Linux (Wayland) Subsurface Overlay subsurfaces
Linux (X11) Child window (WebKitGTK) Overlay window blended by the compositing manager; cut out of the native content without one
# WKWebView on macOS, WebView2 on Windows, a GPU surface of its own on Linux
cargo run -p gpui_perf --example native_webview
# A WebKitGTK page on Linux X11 or XWayland
cargo run -p gpui_perf --example linux_webview

Using it

Alias the published crates to GPUI's library names:

[dependencies]
gpui = { package = "gpui-fast", version = "0.1.0" }
gpui_platform = { package = "gpui-fast-platform", version = "0.1.0", features = ["wayland", "x11"] }

The platform features above select Linux backends; omit them on macOS and Windows. GPUI Kit applications should follow the compatibility setup to use the same GPUI core.

Changes to render state outside tracked entities, globals and list/scroll state need cx.notify(). See Retained Mode for details.

Following upstream

v0.1.0 includes Zed's GPUI through a1b71072e5. UPSTREAM records the revision for the current checkout.

GPUI Fast keeps its implementation in fast/ modules with small hooks into upstream code, making future syncs easier. See Architecture and Contributing for design, building and testing.

License

Apache-2.0 — copyright Zed Industries, Inc. This is a modified fork; see LICENSE-APACHE.