gpu/shadow: opt-in ReBAR GPU_UPLOAD heap with VRAM guard & WC streaming (3/4 of #51) #58

Open
github-bot wants to merge 1 commit from github-bot/gh-58 into beta AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 00:43 UTC · original
Vladimir-Human:perf/split-rebar-upload → beta · +1116 −71 · 1 files · 1 commits · open

Split 3/4 of #51 cleanly on top of beta (independent of #56, #57, and Part 4 Lazy Copy-Back).

Summary of Changes (crates/victory-gpu/src/shadow.rs)

  • Opt-in mod rebar (VICTORY_REBAR=1|2, default OFF): allocates host shadow buffers/windows in D3D12_HEAP_TYPE_GPU_UPLOAD after querying live adapter support and checking VRAM budget (1 for windows only, 2 for windows + buffers, keeping VICTORY_CARD_BUFFERS VRAM copies preferred when carded).
  • Concurrent headroom guard & OOM-safe accounting: tracks placed + in-flight ReBAR reservations atomically and rolls back CARD_BYTES / WINDOW_CARD_BYTES if shared_buffer staging allocation fails.
  • AVX2 VMOVNTDQA WC streaming helpers + _mm_sfence() ordering: adds copy_from_wc, slices_equal_wc, merge_gpu_into_title_runs, wc_sfence(), and TLS SCRATCH_WC so reads from write-combined ReBAR mappings avoid slow uncached byte reads while keeping sequential WC writes ordered.
  • Worker serialization for WC reads: routes WC snapshot/diff scans through serialized jobs (copy_jobs_wc / find_pieces_wc) and single-threaded differing to avoid thrashing PCIe read queues.
  • Unit & live-GPU tests + opt-in benchmark: rebar_tests::{rebar_wc_write_read_compare_roundtrip, simd_wc_and_gpu_merge_helpers_match_scalar_oracles} and #[ignore] bench_rebar (plus rebar::tests::rebar_decisions_and_concurrent_headroom_hold).

Verification (VICTORY_D3D12_DEBUG=1)

  • cargo test -p victory-gpu -> passed
  • cargo test -p victory-gpu --all-features -> passed
  • cargo run -p xtask -- policy --staged -> asset policy: 1 files ok (shadow.rs = 224,768 B)

Related: #51, #56, #57

**@⁠Vladimir-Human** on GitHub · 2026-11-26 00:43 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/58) `Vladimir-Human:perf/split-rebar-upload` → `beta` · +1116 −71 · 1 files · 1 commits · open Split 3/4 of #51 cleanly on top of `beta` (independent of #56, #57, and Part 4 Lazy Copy-Back). ### Summary of Changes (`crates/victory-gpu/src/shadow.rs`) - **Opt-in `mod rebar` (`VICTORY_REBAR=1|2`, default OFF)**: allocates host shadow buffers/windows in `D3D12_HEAP_TYPE_GPU_UPLOAD` after querying live adapter support and checking VRAM budget (`1` for windows only, `2` for windows + buffers, keeping `VICTORY_CARD_BUFFERS` VRAM copies preferred when carded). - **Concurrent headroom guard & OOM-safe accounting**: tracks placed + in-flight ReBAR reservations atomically and rolls back `CARD_BYTES` / `WINDOW_CARD_BYTES` if `shared_buffer` staging allocation fails. - **AVX2 `VMOVNTDQA` WC streaming helpers + `_mm_sfence()` ordering**: adds `copy_from_wc`, `slices_equal_wc`, `merge_gpu_into_title_runs`, `wc_sfence()`, and TLS `SCRATCH_WC` so reads from write-combined ReBAR mappings avoid slow uncached byte reads while keeping sequential WC writes ordered. - **Worker serialization for WC reads**: routes WC snapshot/diff scans through serialized jobs (`copy_jobs_wc` / `find_pieces_wc`) and single-threaded `differing` to avoid thrashing PCIe read queues. - **Unit & live-GPU tests + opt-in benchmark**: `rebar_tests::{rebar_wc_write_read_compare_roundtrip, simd_wc_and_gpu_merge_helpers_match_scalar_oracles}` and `#[ignore] bench_rebar` (plus `rebar::tests::rebar_decisions_and_concurrent_headroom_hold`). ### Verification (`VICTORY_D3D12_DEBUG=1`) - `cargo test -p victory-gpu` -> passed - `cargo test -p victory-gpu --all-features` -> passed - `cargo run -p xtask -- policy --staged` -> `asset policy: 1 files ok` (`shadow.rs` = 224,768 B) Related: #51, #56, #57
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:53:58 +00:00
Author
Owner

@⁠HandshakeHackin on GitHub · 2026-11-26 02:58 UTC · original

On hosted native Windows I forced the diagnostics software adapter and VICTORY_REBAR=2 at d29505a. WARP reported GPU-upload heap support, allocated and mapped the 256 KiB buffer, and completed the write/read/compare round trip, including detecting the altered byte. The verification wrapper required an initialized device and an explicit support or fallback marker, since the original live test can return early. This verifies buffer contents on WARP. The physical RX 9070 XT run is still needed for PCIe behavior and timings. Windows test and result

**@⁠HandshakeHackin** on GitHub · 2026-11-26 02:58 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/58#issuecomment-7181290057) On hosted native Windows I forced the diagnostics software adapter and `VICTORY_REBAR=2` at `d29505a`. WARP reported GPU-upload heap support, allocated and mapped the 256 KiB buffer, and completed the write/read/compare round trip, including detecting the altered byte. The verification wrapper required an initialized device and an explicit support or fallback marker, since the original live test can return early. This verifies buffer contents on WARP. The physical RX 9070 XT run is still needed for PCIe behavior and timings. [Windows test and result](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45745588363/job/139660707514)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/58/head:github-bot/gh-58'
git switch 'github-bot/gh-58'

Merge

Merge the changes and update on Forgejo.
git switch 'beta'
git merge --no-ff 'github-bot/gh-58'
git switch 'github-bot/gh-58'
git rebase 'beta'
git switch 'beta'
git merge --ff-only 'github-bot/gh-58'
git switch 'github-bot/gh-58'
git rebase 'beta'
git switch 'beta'
git merge --no-ff 'github-bot/gh-58'
git switch 'beta'
git merge --squash 'github-bot/gh-58'
git switch 'beta'
git merge --ff-only 'github-bot/gh-58'
git switch 'beta'
git merge 'github-bot/gh-58'
git push origin 'beta'
This discussion has been locked. Commenting is limited to contributors.
No description provided.