Renderer port 5: table constant buffers in host copies read through their raw twin (VICTORY_PORT_CBV_COPIES=1) #363

Closed
github-bot wants to merge 1 commit from github-bot/gh-363 into main AGit
Owner

@⁠Sr-0w on GitHub · 2026-11-26 19:04 UTC · original
port/cbv-copies → main · +164 −26 · 4 files · 1 commits · closed without merging

Summary

Extends renderer port #5 (VICTORY_PORT_CBV=1) behind a new opt-in switch VICTORY_PORT_CBV_COPIES=1 (off by default, A/B-able via VICTORY_AB):

  • Previously, draw.rs only viewed table constant buffers (View::Constant) directly through their raw twin when their Shadow was in_place(). Constant buffers in ordinary host copies (~760–810/frame, ~2 MB/frame) fell back to Step::Fill through per-list scratch upload memory.
  • When a Step::Fill reads GPU-written memory, card_steps either emits a bounce copy (~100–137 fills/frame, ~1.4 ms/frame planning) or — whenever a Step::Placed copy touches that range (BEHIND_PLACED) — drains the GPU queue with a full flight wait (WHY_READ).
  • With VICTORY_PORT_CBV_COPIES=1 (requiring VICTORY_PORT_CBV=1), 16-byte-aligned table constant buffers in non-in-place host copies are viewed directly through HostHeap::constant_raw_at and brought up to date via shadow.refresh(list, address, size), matching title slots and root views. Unaligned or unshadowed constant buffers keep the existing Step::Fill fallback.
  • Adds per-frame diagnostics counters (in host copies, KB) in port_cbv::log, CPU unit tests for switch parsing and table_use selection, and README.md documentation.

Assumption

Constants are written by the title into rings it waits on with fences before reusing, and a host copy is refreshed like any other title buffer: CPU writes before submission go up through Shadow::refresh (with VICTORY_SEND_OWN=1 uploading dirty runs in queue order for card-side copies), while prior shader writes and placed buffer copies are read directly from the host copy on the card in command-list order.

Measurements

Hardware & configuration: RX 7800 XT 16 GB, Series X profile, ray tracing on (VICTORY_BVH_BUILDER=1), renderer ports 1, 2, 5, 6 and 7 on, warm cache, water scene in a retail game.

Standalone A/B (VICTORY_AB=15,VICTORY_PORT_CBV_COPIES, last six steady phases)

Metric (per frame) VICTORY_PORT_CBV_COPIES=0 VICTORY_PORT_CBV_COPIES=1 Delta
Frame time (mean) ~100.2 ms (10.0 fps) ~96.8 ms (10.3 fps) -3.4 ms
Frame time (median / p90) 98.2 / 110.8 ms 95.6 / 106.3 ms -2.6 / -4.5 ms
card_steps fills (plan) 102.7 fills (1.47 ms) 0.0 steady / 3.7 avg (0.19 ms) -1.28 ms
Flight waits (last six phases) 5.44 ms 0.41 ms -5.03 ms
Flight waits (arena-only vs A/B run) 55.6 ms 3.4 ms -52.2 ms
Table CBVs viewed in host copies 0 761 (2,005 KB; 296 unaligned fallback) —

Combined with companion BVH arena write tracking (last 90 s)

Run Frame rate / ms card_steps fills (plan) Flight waits
Reference (5 ports) 9.8 fps / 102.8 ms 117.8 fills (1.39 ms) 15.2 ms
BVH arena write tracking alone 9.2 fps / 109.5 ms 88.5 fills (1.44 ms) 34.0–55.6 ms
Combined (VICTORY_PORT_CBV_COPIES=1 + BVH arena tracking) 11.1 fps / 90.0 ms 0.0 fills (0.19 ms) 0.1–0.5 ms

Picture on the water scene unchanged (checked visually on the recorded runs).

Testing

  • cargo test --locked -p victory-gpu --lib port_cbv: 3 passed, 0 failed.
  • cargo test --locked -p victory-gpu --features diagnostics --lib port_cbv: 3 passed, 0 failed.
  • cargo clippy --locked -p victory-gpu --features diagnostics --lib: 0 warnings in touched files (only main's pre-existing warning in watch.rs:3626).
  • Measured in game via VICTORY_AB=15,VICTORY_PORT_CBV_COPIES and the combined run above.

🤖 Generated with Claude Code

**@⁠Sr-0w** on GitHub · 2026-11-26 19:04 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/363) `port/cbv-copies` → `main` · +164 −26 · 4 files · 1 commits · closed without merging ## Summary Extends renderer port #5 (`VICTORY_PORT_CBV=1`) behind a new opt-in switch `VICTORY_PORT_CBV_COPIES=1` (off by default, A/B-able via `VICTORY_AB`): - Previously, `draw.rs` only viewed table constant buffers (`View::Constant`) directly through their raw twin when their `Shadow` was `in_place()`. Constant buffers in ordinary host copies (~760–810/frame, ~2 MB/frame) fell back to `Step::Fill` through per-list scratch upload memory. - When a `Step::Fill` reads GPU-written memory, `card_steps` either emits a bounce copy (~100–137 fills/frame, ~1.4 ms/frame planning) or — whenever a `Step::Placed` copy touches that range (`BEHIND_PLACED`) — drains the GPU queue with a full flight wait (`WHY_READ`). - With `VICTORY_PORT_CBV_COPIES=1` (requiring `VICTORY_PORT_CBV=1`), 16-byte-aligned table constant buffers in non-in-place host copies are viewed directly through `HostHeap::constant_raw_at` and brought up to date via `shadow.refresh(list, address, size)`, matching title slots and root views. Unaligned or unshadowed constant buffers keep the existing `Step::Fill` fallback. - Adds per-frame diagnostics counters (`in host copies`, KB) in `port_cbv::log`, CPU unit tests for switch parsing and `table_use` selection, and `README.md` documentation. ## Assumption Constants are written by the title into rings it waits on with fences before reusing, and a host copy is refreshed like any other title buffer: CPU writes before submission go up through `Shadow::refresh` (with `VICTORY_SEND_OWN=1` uploading dirty runs in queue order for card-side copies), while prior shader writes and placed buffer copies are read directly from the host copy on the card in command-list order. ## Measurements Hardware & configuration: RX 7800 XT 16 GB, Series X profile, ray tracing on (`VICTORY_BVH_BUILDER=1`), renderer ports 1, 2, 5, 6 and 7 on, warm cache, water scene in a retail game. ### Standalone A/B (`VICTORY_AB=15,VICTORY_PORT_CBV_COPIES`, last six steady phases) | Metric (per frame) | `VICTORY_PORT_CBV_COPIES=0` | `VICTORY_PORT_CBV_COPIES=1` | Delta | |---|---:|---:|---:| | Frame time (mean) | ~100.2 ms (10.0 fps) | ~96.8 ms (10.3 fps) | **-3.4 ms** | | Frame time (median / p90) | 98.2 / 110.8 ms | 95.6 / 106.3 ms | **-2.6 / -4.5 ms** | | `card_steps` fills (plan) | 102.7 fills (1.47 ms) | 0.0 steady / 3.7 avg (0.19 ms) | **-1.28 ms** | | Flight waits (last six phases) | 5.44 ms | 0.41 ms | **-5.03 ms** | | Flight waits (arena-only vs A/B run) | 55.6 ms | 3.4 ms | **-52.2 ms** | | Table CBVs viewed in host copies | 0 | 761 (2,005 KB; 296 unaligned fallback) | — | ### Combined with companion BVH arena write tracking (last 90 s) | Run | Frame rate / ms | `card_steps` fills (plan) | Flight waits | |---|---:|---:|---:| | Reference (5 ports) | 9.8 fps / 102.8 ms | 117.8 fills (1.39 ms) | 15.2 ms | | BVH arena write tracking alone | 9.2 fps / 109.5 ms | 88.5 fills (1.44 ms) | 34.0–55.6 ms | | **Combined (`VICTORY_PORT_CBV_COPIES=1` + BVH arena tracking)** | **11.1 fps / 90.0 ms** | **0.0 fills (0.19 ms)** | **0.1–0.5 ms** | Picture on the water scene unchanged (checked visually on the recorded runs). ## Testing - `cargo test --locked -p victory-gpu --lib port_cbv`: 3 passed, 0 failed. - `cargo test --locked -p victory-gpu --features diagnostics --lib port_cbv`: 3 passed, 0 failed. - `cargo clippy --locked -p victory-gpu --features diagnostics --lib`: 0 warnings in touched files (only main's pre-existing warning in `watch.rs:3626`). - Measured in game via `VICTORY_AB=15,VICTORY_PORT_CBV_COPIES` and the combined run above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Extends VICTORY_PORT_CBV=1 behind opt-in VICTORY_PORT_CBV_COPIES=1 (off by default, A/B-able via VICTORY_AB) so table constant buffers in non-in-place host copies are viewed through their raw twin with a normal Shadow::refresh instead of copied into scratch upload memory (Step::Fill), eliminating card_steps bounce copies and BEHIND_PLACED waits for flights.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:09:55 +00:00
github-bot closed this pull request 2026-11-27 14:52:46 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.