feat(scene): PERF frame-budget HUD for wire re-tessellation cost

Phase 5.3 (CPU tessellation slice). Add a `PERF` command that toggles an
overlay on the active viewport showing the cost of the most recent wire
re-tessellation: ms, wire count, geometry epoch. Anchored top-left via
position_canvas_overlay.

Timing is captured at the wire-cache miss paths (model_tile_wires_arc,
paper_sheet_wires_arc) and stored in Cells on Scene, read directly by the
UI view (Scene is single-threaded / Rc-based, so build_primitive and view
share a thread). Reads ~0 ms on a warm cache, so it isolates the exact
work a miss costs — the slice 2.2 / 3.1 / 3.3 each move, making them
PR-to-PR comparable.

GPU upload/draw/GPU-wait spans (need wgpu timestamp queries) remain open.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-05 01:07:17 +03:00
commit 9b112ce12c
5 changed files with 83 additions and 3 deletions

View file

@ -261,10 +261,17 @@ Opened "x.dwg" — 84321 entities — parse 1.2s, purge 80ms, caches 340ms, xref
Regressions are visible immediately.
### 5.3 Frame-budget HUD
### 5.3 Frame-budget HUD ✅ DONE (CPU tess slice)
Add a CLI `PERF` toggle (or F12) that shows per-frame breakdown: tess ms,
upload ms, draw ms, GPU wait ms. Makes PR-to-PR comparison trivial.
A CLI `PERF` toggle overlays the cost of the most recent wire
re-tessellation (ms + wire count + geometry epoch) on the active viewport,
anchored top-left. Reads ~0 ms while the wire cache is warm (idle
pan/zoom), so it isolates exactly the work a cache miss costs — the slice
every render-path change (2.2 / 3.1 / 3.3) moves. Timed at the miss paths
in `model_tile_wires_arc` / `paper_sheet_wires_arc` and stored on `Scene`.
Still open: GPU-side `upload` / `draw` / `GPU-wait` spans need wgpu
timestamp queries; the CPU tessellation slice covers the current hot path.
---