Skip to content

perf(gpui): fuse playback frame conversion passes - #2478

Closed
viralcodex wants to merge 2 commits into
CapSoftware:mainfrom
viralcodex:fuse-playback-frame-conversion
Closed

viralcodex wants to merge 2 commits into
CapSoftware:mainfrom
viralcodex:fuse-playback-frame-conversion

Conversation

@viralcodex

@viralcodex viralcodex commented Oct 13, 2026 •

Copy link
Copy Markdown

Problem

GPUI's CPU playback-frame path converted RenderedFrame output in two full-frame passes:

  • Copy each row into a tightly packed buffer, removing wgpu's row padding.
  • Traverse that buffer again to convert RGBA pixels to GPUI's BGRA channel order.

This doubled the memory traversal for every frame shown through the CPU fallback used on Windows, Linux, and when macOS surface presentation is unavailable.

flowchart LR
  subgraph Before
    A["Padded RGBA frame"] --> B["Copy and unpad rows"]
    B --> C["Second pass: RGBA to BGRA"]
    C --> D["GPUI RenderImage"]
  end
  subgraph After
    E["Padded RGBA frame"] --> F["Unpad and convert in one pass"]
    F --> G["GPUI RenderImage"]
  end
Loading

Solution

  • frame.rs:
    • Allocate the tightly packed output once.
    • Unpad rows and swap the red/blue channels while writing each pixel.
    • Validate dimensions with checked arithmetic and reject incomplete input buffers.
    • Add an ignored release benchmark comparing the previous two-pass implementation with the new path.
    • Assert byte-for-byte equality for every measured frame.

Benchmark

Release-mode kernel benchmark on an Apple M4 Pro. Each result is the median of three runs; every run uses 12 alternating baseline/candidate pairs, discards the first two warmups, and verifies byte-identical output:

Frame size Previous This PR Change
GPUI preview (1248×702, padded rows) 282.6 µs 183.0 µs −35.2%
Full HD (1920×1080) 656.9 µs 418.8 µs −36.2%
4K (3840×2160) 2,790.2 µs 1,675.2 µs −40.0%

All frame-kernel tests pass and each benchmark reports pixels_equal=true.

please lmk if I missed something

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the previous empty-frame issue is fixed.

Summary

The PR combines row copying and RGBA-to-BGRA conversion into one pass.

  • Frame conversion unpads rows and swaps channels in one pass.

No new actionable issues were found. Tests were inspected, not run.

Reviews (2) · Last reviewed commit: "review comments addressed" · Reviewed by Greptile

Comment thread apps/desktop-gpui/kernels/src/frame.rs Resolved
@viralcodex

viralcodex commented Oct 13, 2026 •

Copy link
Copy Markdown
Author

@greptileai review

@viralcodex viralcodex changed the title fuse playback frame conversion passes perf(gpui): fuse playback frame conversion passes Oct 13, 2026
@viralcodex viralcodex closed this Oct 13, 2026
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.

1 participant