From f6c7a5a8b8bf5578ce87d40a478dd9a381c78407 Mon Sep 17 00:00:00 2001
From: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com>
Date: Thu, 22 Oct 2026 02:14:26 +0800
Subject: [PATCH 1/5] perf(gpui): add streaming image patch that reuses one
texture per stream, with backend tests and a CI job
---
.github/workflows/ci.yml | 63 +
.../patches/zed-streaming-image.patch | 3049 +++++++++++++++++
scripts/prepare-gpui-dependency.sh | 1 +
scripts/prepare-gpui-dependency.test.mjs | 7 +
4 files changed, 3120 insertions(+)
create mode 100644 apps/desktop-gpui/patches/zed-streaming-image.patch
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 57810c00587..f8ff8eb5548 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,6 +24,7 @@ jobs:
rust: ${{ steps.filter.outputs.rust }}
gpui: ${{ steps.filter.outputs.rust == 'true' || steps.filter.outputs.gpui == 'true' || steps.desktop-resources.outputs.desktop-resources == 'true' }}
tauri-plugins: ${{ steps.filter.outputs.tauri-plugins }}
+ gpui-patches: ${{ steps.filter.outputs.gpui-patches }}
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -65,6 +66,9 @@ jobs:
- 'scripts/sync-desktop-versions.mjs'
- 'scripts/verify-gpui-release-inputs.mjs'
- 'scripts/verify-windows-stack.mjs'
+ gpui-patches:
+ - 'apps/desktop-gpui/patches/**'
+ - 'scripts/prepare-gpui-dependency.sh'
tauri-plugins:
- 'Cargo.lock'
- 'bun.lock'
@@ -370,6 +374,65 @@ jobs:
fi
cargo +1.95.0 test --manifest-path apps/desktop-gpui/Cargo.toml --locked --target ${{ matrix.settings.target }} -p cap-gpui-kernels
+ # Cap only builds gpui's crates as dependencies, so their own tests never run
+ # in the app jobs above. Run the ones covering Cap's patches against real
+ # devices: Metal on macOS, WARP on Windows, and Mesa's lavapipe (Vulkan) and
+ # llvmpipe (GL) on Linux. Zed's lockfile predates the patches' dependency
+ # changes, so these builds cannot use --locked.
+ gpui-patch-tests:
+ name: GPUI patch tests (${{ matrix.settings.name }})
+ needs: changes
+ if: needs.changes.outputs.gpui-patches == 'true'
+ timeout-minutes: 90
+ strategy:
+ fail-fast: false
+ matrix:
+ settings:
+ - name: macOS
+ runner: blacksmith-6vcpu-macos-15
+ - name: Windows
+ runner: blacksmith-8vcpu-windows-2025
+ - name: Linux
+ runner: blacksmith-8vcpu-ubuntu-2404
+ runs-on: ${{ matrix.settings.runner }}
+ env:
+ CARGO_PROFILE_DEV_DEBUG: "0"
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Install Linux desktop dependencies
+ if: ${{ runner.os == 'Linux' }}
+ uses: ./.github/actions/install-desktop-deps
+
+ - name: Install software GPU drivers
+ if: ${{ runner.os == 'Linux' }}
+ run: sudo apt-get install -y --no-install-recommends mesa-vulkan-drivers libvulkan1 libegl1 libegl-mesa0 libgl1-mesa-dri
+
+ - name: Rust setup
+ uses: dtolnay/rust-toolchain@1.95.0
+
+ - name: Prepare GPUI dependency
+ shell: bash
+ run: ./scripts/prepare-gpui-dependency.sh
+
+ - name: Test GPUI patches
+ shell: bash
+ working-directory: ../zed-cap
+ run: |
+ cargo +1.95.0 test -p gpui --lib stream
+ if [[ "$RUNNER_OS" == "Linux" ]]; then
+ WGPU_BACKEND=vulkan cargo +1.95.0 test -p gpui_wgpu --lib wgpu_atlas -- --nocapture
+ WGPU_BACKEND=gl cargo +1.95.0 test -p gpui_wgpu --lib wgpu_atlas -- --nocapture
+ else
+ cargo +1.95.0 test -p gpui_wgpu --lib wgpu_atlas -- --nocapture
+ fi
+ if [[ "$RUNNER_OS" == "macOS" ]]; then
+ cargo +1.95.0 test -p gpui_macos --lib -- metal_atlas metal_renderer
+ elif [[ "$RUNNER_OS" == "Windows" ]]; then
+ cargo +1.95.0 test -p gpui_windows --lib directx_atlas
+ fi
+
tauri-plugins:
name: Verify Tauri plugin versions
runs-on: blacksmith-8vcpu-ubuntu-2404
diff --git a/apps/desktop-gpui/patches/zed-streaming-image.patch b/apps/desktop-gpui/patches/zed-streaming-image.patch
new file mode 100644
index 00000000000..6d67d833357
--- /dev/null
+++ b/apps/desktop-gpui/patches/zed-streaming-image.patch
@@ -0,0 +1,3049 @@
+diff --git a/crates/gpui/src/gpui.rs b/crates/gpui/src/gpui.rs
+index 4b1679c..a143fab 100644
+--- a/crates/gpui/src/gpui.rs
++++ b/crates/gpui/src/gpui.rs
+@@ -47,6 +47,7 @@ pub mod profiler;
+ pub mod queue;
+ mod scene;
+ mod shared_uri;
++mod streaming_image;
+ mod style;
+ mod styled;
+ mod subscription;
+@@ -145,6 +146,7 @@ pub use refineable::*;
+ pub use scene::*;
+ pub use shared_uri::*;
+ use std::{any::Any, future::Future};
++pub use streaming_image::*;
+ pub use style::*;
+ pub use styled::*;
+ pub use subscription::*;
+diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs
+index 09adcdd..7dd2d38 100644
+--- a/crates/gpui/src/platform.rs
++++ b/crates/gpui/src/platform.rs
+@@ -40,7 +40,8 @@ use crate::{
+ FontRun, ForegroundExecutor, GlyphId, GpuSpecs, Hsla, ImageSource, Keymap, LineLayout, Pixels,
+ PlatformGestures, PlatformInput, Point, Priority, RenderGlyphParams, RenderImage,
+ RenderImageParams, RenderSvgParams, Scene, ShapedGlyph, ShapedRun, SharedString, Size,
+- SvgRenderer, SystemWindowTab, Task, Window, WindowControlArea, hash, point, px, size,
++ StreamFrame, StreamingImageId, SvgRenderer, SystemWindowTab, Task, Window, WindowControlArea,
++ hash, point, px, size,
+ };
+ #[cfg(any(target_os = "linux", target_os = "freebsd"))]
+ use anyhow::bail;
+@@ -1316,6 +1317,17 @@ pub trait PlatformAtlas {
+ build: &mut dyn FnMut() -> Result