Skip to content

gpui: Support in-place image updates - #4

Merged
remorses merged 3 commits into
remorses:gpuixfrom
monotykamary:gpui-dynamic-image-updates
Sep 8, 2026
Merged

remorses merged 3 commits into
remorses:gpuixfrom
monotykamary:gpui-dynamic-image-updates

Conversation

@monotykamary

Copy link
Copy Markdown

Objective

  • Provide GPUIX with the GPUI primitives needed to update a stable polychrome image without rebuilding retained views or reallocating a same-sized atlas tile.
  • This is the prerequisite for remorses/gpuix#40 and the fixed-cell terminal proposed in remorses/gpuix#42.

Solution

  • Add RenderImage::from_bgra for tightly packed, single-frame pixel buffers.
  • Add PlatformAtlas::update, with in-place uploads for Metal, WGPU, and DirectX and the existing remove/reinsert behavior as the default fallback.
  • Add an explicit per-sprite nearest-neighbor flag while preserving the existing polychrome sprite layout. Ordinary images and color glyphs remain linearly sampled; monochrome and subpixel glyph paths are unchanged.
  • Add Window::update_image, which reports whether every atlas tile retained its identity, and Window::present_cached_frame for safely presenting that updated stable scene.

The separate monochrome glyph sampling discussion in zed-industries/zed#57777 and zed-industries/zed#57781 is intentionally out of scope.

Testing

  • cargo test -p gpui -p gpui_apple --lib --features gpui_apple/runtime_shaders — 269 GPUI tests and 4 Metal atlas tests passed.
  • cargo test -p gpui_wgpu --lib — 31 tests passed, including same-size reuse, resize fallback, BGRA swizzling, WGSL validation, WebGL transport, and sprite stride coverage.
  • ./script/clippy -p gpui_apple, ./script/clippy -p gpui_wgpu, and ./script/clippy -p gpui_windows passed.
  • cargo clippy -p gpui --release --lib --all-features -- --deny warnings passed. The repository wrapper's all-target GPUI run is currently blocked by a pre-existing redundant_clone lint in crates/gpui/src/interactive.rs:881.
  • Instantiated MetalHeadlessRenderer with runtime shaders to compile the complete changed Metal shader successfully.
  • Ran the downstream GPUix native suite against this worktree with runtime Metal shaders: 227 tests passed.
  • Rust formatting and git diff --check passed.

Tested on macOS Apple Silicon. Metal and WGPU executed locally. The DirectX implementation was linted but requires Windows CI or hardware for runtime validation.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • N/A

Add stable atlas uploads across Metal, WGPU, and DirectX, explicit nearest-neighbor polychrome sampling, and cached-scene presentation for externally updated images.
@remorses
remorses merged commit 81c99f8 into remorses:gpuix Sep 8, 2026
remorses added a commit to remorses/gpuix that referenced this pull request Sep 10, 2026
Fast-forward the submodule from 5f672a20b1 to 81c99f816b on origin/gpuix.
That is remorses/zed#4: atlas uploads keep a same-sized tile on Metal,
WGPU, and DirectX, plus nearest-neighbor polychrome sampling and
Window::present_cached_frame.

GPUIX needed no code change. rust-toolchain stays 1.97.1. cargo check,
cargo test --lib, bun run build, and img.test.tsx all passed.

Session: ses_f7ec2f4c6ffekfPE4MgCvjex0R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants