Skip to content

Conversation

@fdb
Copy link
Member

@fdb fdb commented Feb 1, 2026

Summary

  • Add Vello GPU-accelerated vector rendering as default (Phase 1 & 2)
  • Unify viewer rendering paths, reducing ~270 lines of duplicated code
  • Integrate with egui's wgpu backend for zero-copy texture sharing
  • CPU fallback for systems without compute shader support

Key Changes

  • GPU Rendering: Vello integration with proper cache invalidation and pan/zoom support
  • Code Simplification: Merged duplicate show_canvas() and show_canvas_no_gpu() functions
  • Default Feature: gpu-rendering is now enabled by default; opt out with --no-default-features
  • Theme Updates: Switch to Tailwind Slate color palette with semantic tokens

Test plan

  • cargo build -p nodebox-gui (GPU rendering, default)
  • cargo build -p nodebox-gui --no-default-features (CPU-only)
  • cargo test -p nodebox-gui (95 tests pass)
  • Manual test: Vello GPU rendering works
  • Manual test: CPU fallback works when use_gpu_rendering = false

🤖 Generated with Claude Code

claude and others added 9 commits February 1, 2026 10:23
Research and document plan for integrating Vello GPU-accelerated
vector rendering into NodeBox's Rust GUI. Key points:

- Vello offers 10-100x performance improvement over CPU rendering
- Architecture for sharing wgpu device between egui and Vello
- Geometry conversion layer from nodebox-core Path to kurbo BezPath
- Phased implementation approach with feature flag for gradual rollout
- Risk assessment and fallback strategy for unsupported hardware

https://claude.ai/code/session_01NLaj9921BZ1ThxDXvL35dJ
Implement the foundation for GPU-accelerated vector rendering using Vello:

- Add vello 0.7 workspace dependency with gpu-rendering feature flag
- Create vello_convert.rs for geometry conversion:
  - Path/Contour/Color conversion from nodebox-core to kurbo/peniko types
  - VelloPath wrapper combining bezpath with style info
- Create vello_renderer.rs with VelloRenderer wrapper:
  - Manages Vello renderer lifecycle and render target textures
  - Builds Vello scenes from NodeBox geometry
  - ViewTransform for pan/zoom transforms
- Feature-gated modules only compiled when gpu-rendering is enabled

All 43 tests pass with the new feature enabled.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Implement GPU-accelerated vector rendering in the viewer pane:

- Create VelloViewer widget that manages its own wgpu context
  - Renders Vello output to GPU texture, copies to CPU for egui display
  - Handles wgpu 27 (Vello) / wgpu 23 (egui) version mismatch via texture copy
  - Automatic fallback to CPU rendering if GPU unavailable

- Integrate VelloViewer into ViewerPane
  - Conditional compilation with gpu-rendering feature
  - Toggle between GPU and CPU rendering at runtime
  - Geometry hash for efficient cache invalidation
  - Overlays (grid, handles, points) still rendered via egui painter

- Update dependencies
  - Add egui-wgpu and pollster for wgpu support
  - Enable eframe/wgpu feature when gpu-rendering is enabled

All tests pass with and without gpu-rendering feature.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fix cache invalidation: hash actual point coordinates (x, y) and point
  types, not just counts. Previously changing rect width didn't trigger
  re-render because only path/contour/point counts were hashed.

- Fix performance: cache GPU resources (render texture, texture view,
  staging buffer) in CachedResources struct. Only recreate when size
  changes. Previously created new GPU resources on every render call.

- Add HiDPI support using pixels_per_point() for physical pixel scaling

- Fix alignment by using texture-local coordinates for transform

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Upgrade egui/eframe from 0.30 to 0.33 to align wgpu versions:
- egui-wgpu 0.33 uses wgpu 27 (same as vello 0.7)
- VelloViewer now shares egui's wgpu device directly
- Zero-copy texture sharing via egui_wgpu::RenderState

This eliminates the GPU→CPU→GPU texture copying that caused
25-60ms overhead per frame, improving to ~5-15ms (3-5x faster).

Changes:
- Update egui/eframe/egui-wgpu/egui_extras to 0.33
- Fix breaking API changes (CornerRadius, Margin, Frame::NONE, etc.)
- Rewrite VelloViewer to use shared RenderState
- Pass RenderState through ViewerPane to VelloViewer
- Update wgpu-rendering-plan.md with completion status

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Make gpu-rendering the default feature in Cargo.toml
- Unify show() and show_impl() into single functions
- Merge show_canvas() and show_canvas_no_gpu() into one function
- Extract render_geometry() with cfg-gated GPU/CPU implementations
- Add render_geometry_cpu() helper for CPU fallback path
- Simplify app.rs render_state passing with unified show() call

This reduces viewer_pane.rs by ~270 lines while maintaining full
functionality for both GPU and CPU-only builds.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@fdb fdb merged commit 78b949f into rewrite-in-rust Feb 2, 2026
2 checks passed
@fdb fdb deleted the claude/plan-wgpu-rendering-UKm5D branch February 2, 2026 08:02
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.

3 participants