Skip to content

O4: positron-wgpu — GPU renderer (outlier B, closes the outlier pair)#8

Merged
joelteply merged 1 commit into
mainfrom
feat/o4-wgpu-gpu-renderer
Jul 3, 2026
Merged

O4: positron-wgpu — GPU renderer (outlier B, closes the outlier pair)#8
joelteply merged 1 commit into
mainfrom
feat/o4-wgpu-gpu-renderer

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

positron-wgpu — the GPU reference Renderer for positron, outlier B in the contract's outlier-validation.

A Renderer here has type Output = Frame: GPU-bound geometry (colored quads for a vertex buffer), not a CPU text tree. counter-cli's String and positron-ratatui's Paragraph are both CPU text (a weak outlier pair). GPU quads are maximally different. With Renderer<S> fitting a String, terminal cells, and GPU geometry without forcing, the contract provably carries no hidden DOM/text assumption — so the middle (mobile, DOM) is guaranteed. That is "web ≠ DOM" made real: one Rust wgpu renderer runs native (Metal/Vulkan/DX12) + web (WebGPU/WASM) from one source.

Shape (same seam as outlier A)

  • frame.rs — pure data (Frame/Primitive/Rect/Rgba/RgbaFrame), no wgpu. The render(state) -> Frame projection is unit-tested headlessly. RgbaFrame is deliberately continuum's avatar-frame shape (width/height/tight RGBA8) for the O5 reconcile.
  • gpu.rs — the only file touching wgpu. Gpu::rasterize renders a Frame offscreen (wgpu 22, Rgba8Unorm, padded copy_texture_to_buffer readback). Missing GPU → loud GpuError::NoAdapter, never a software fallback (force_fallback_adapter: false).
  • lib.rsrender_to_rgba: project a ViewState through a Renderer and rasterize in one call (GPU twin of positron_ratatui::render_to_buffer).

Why the GPU path is an example, not a #[test]

CI runners have no GPU adapter. The pure projection is the always-on unit-tested contract proof; the hardware path is proven by examples/counter_gpu.rs, which rasterizes the same Counter the tests project and writes PNGs. This honors fail-loud — no silent software fallback.

Verification

  • cargo fmt --check clean, cargo clippy --workspace --all-targets -- -D warnings clean.
  • Workspace tests: 31 pass (6 new in positron-wgpu; O1–O3 unchanged).
  • Live on Metal: cargo run -p positron-wgpu --example counter_gpu3 renders three green quads, -4 four red (magnitude→count, sign→color, correct readback).

Roadmap: closes O4 → O5 is next (ContinuumHost: first real ViewState, session↔Commands/Events, reconcile RgbaFrame with continuum's RenderBackend).

🤖 Generated with Claude Code

positron-wgpu is a `Renderer` whose `type Output` is a GPU `Frame` — colored
quads destined for a vertex buffer, not any CPU text tree. That is the point:
`counter-cli`'s `String` and `positron-ratatui`'s `Paragraph` are both CPU text
(a weak outlier pair); GPU geometry is maximally different. With `Renderer<S>`
fitting a `String`, terminal cells, AND GPU quads without forcing, the contract
provably carries no hidden DOM/text assumption — the middle (mobile, DOM) is
guaranteed. This is the "web ≠ DOM" claim made real: one Rust wgpu renderer for
native (Metal/Vulkan/DX12) + web (WebGPU/WASM).

Splits along the same seam as outlier A:
- frame.rs — pure data (Frame/Primitive/Rect/Rgba/RgbaFrame), no wgpu. The
  render(state) -> Frame projection is unit-tested headlessly. RgbaFrame is
  deliberately continuum's avatar-frame shape for the O5 reconcile.
- gpu.rs — the only file touching wgpu. Gpu::rasterize renders a Frame offscreen
  (wgpu 22, Rgba8Unorm target, padded copy_texture_to_buffer readback). Missing
  GPU is a loud GpuError::NoAdapter, never a software fallback.
- lib.rs — render_to_rgba: project a ViewState through a Renderer and rasterize
  in one call (GPU twin of positron_ratatui::render_to_buffer).

The hardware path can't be a #[test] (CI runners have no adapter); it's proven
by examples/counter_gpu.rs, which rasterizes the same Counter the tests project
and writes PNGs. Verified on Metal: 3→three green quads, -4→four red.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply joelteply merged commit 77d45d2 into main Jul 3, 2026
2 checks passed
@joelteply joelteply deleted the feat/o4-wgpu-gpu-renderer branch July 3, 2026 03:19
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