fix(gpu,shader): support VICTORY_PORT_CBV=1 on capped 1M-descriptor GPUs (raw_views == 0) and fix subword raw CBV load #3396

Open
github-bot wants to merge 1 commit from github-bot/gh-3396 into main AGit
Owner

@⁠qlfu on GitHub · 2026-11-29 22:46 UTC · original
qlfu:pr/fix-port-cbv-nvidia-direct-raw-srv → main · +237 −23 · 3 files · 1 commits · open

Summary

Enables Renderer Port #5 (VICTORY_PORT_CBV=1) on capped 1,000,000-descriptor view heaps where raw_views() == 0 (raw_twins=false — all NVIDIA RTX 20/30/40/50 GPUs), and fixes a latent subword raw-CBV lowering bug:

  1. victory-shader/src/emit/lower.rs:
    • Removes the raw_views() == 0 early-out in constants_raw() and dynamic stride == 0 loads so table/heap constant buffers lower to raw SRV loads directly from slot index (raw_twin already returns (index, false) when first == 0).
    • Fixes load_subword in buffer_load on ResourceType::Cbv (lower.rs) to read via raw_dwords instead of cbuffer_dword when raw.is_some().
  2. victory-gpu/src/descriptor/host.rs:
    • Updates constant_raw_at, constant_at, make_twinned (constant_raw_direct), and null_for to create raw SRVs directly at self.at(index) when port_cbv::on() && raw_views() == 0, and uses keep_ref in constant_raw_at to avoid redundant COM AddRef/Release.
  3. Unit test (victory-shader/src/emit/mod.rs):
    • Adds WARP execution test table_constant_buffers_read_as_raw_bytes_directly_without_raw_twins (raw_views = 0, constants_raw = true).

Measured Results (90s Series X 1440p DLSS Balanced, RTX 4070 Ti, 0 W / 0 E)

  • Before (003719.log): 0 table CBVs in place, 14,999 rejected (raw_twins=false).
  • After (010414.log): 13,902–17,848 table CBVs/frame (6.5–8.56 MB) read in place, 0 rejected for alignment, 181–260 title heap CBVs, copies_fills 3.10 -> 1.40 ms (-1.70 ms CPU).
  • Note: remains strictly opt-in (VICTORY_PORT_CBV=1), as on RTX Ada reading CBVs via rawBufferLoad over PCIe bypasses the L1 Constant Cache (cardmeter 32.6 -> 40.0 ms), making it primarily useful on CPU-bound/lower-resolution configurations or future VRAM-placed constant heaps.

Verification

  • git merge-tree --write-tree origin/main pr/fix-port-cbv-nvidia-direct-raw-srv: exit 0
  • cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-shader --lib --locked -- table_constant_buffers_read_as_raw_bytes: 2/2 pass (WARP D3D12)
  • cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- constant_buffer_raw_twins --test-threads=1: pass
  • cargo +1.98.1-x86_64-pc-windows-msvc xtask policy --staged: pass
**@⁠qlfu** on GitHub · 2026-11-29 22:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3396) `qlfu:pr/fix-port-cbv-nvidia-direct-raw-srv` → `main` · +237 −23 · 3 files · 1 commits · open ## Summary Enables Renderer Port #5 (`VICTORY_PORT_CBV=1`) on capped 1,000,000-descriptor view heaps where `raw_views() == 0` (`raw_twins=false` — all NVIDIA RTX 20/30/40/50 GPUs), and fixes a latent subword raw-CBV lowering bug: 1. **`victory-shader/src/emit/lower.rs`**: - Removes the `raw_views() == 0` early-out in `constants_raw()` and dynamic `stride == 0` loads so table/heap constant buffers lower to raw SRV loads directly from slot `index` (`raw_twin` already returns `(index, false)` when `first == 0`). - Fixes `load_subword` in `buffer_load` on `ResourceType::Cbv` (`lower.rs`) to read via `raw_dwords` instead of `cbuffer_dword` when `raw.is_some()`. 2. **`victory-gpu/src/descriptor/host.rs`**: - Updates `constant_raw_at`, `constant_at`, `make_twinned` (`constant_raw_direct`), and `null_for` to create raw SRVs directly at `self.at(index)` when `port_cbv::on() && raw_views() == 0`, and uses `keep_ref` in `constant_raw_at` to avoid redundant COM `AddRef`/`Release`. 3. **Unit test (`victory-shader/src/emit/mod.rs`)**: - Adds WARP execution test `table_constant_buffers_read_as_raw_bytes_directly_without_raw_twins` (`raw_views = 0`, `constants_raw = true`). ## Measured Results (90s Series X 1440p DLSS Balanced, RTX 4070 Ti, `0 W / 0 E`) - Before (`003719.log`): `0` table CBVs in place, `14,999` rejected (`raw_twins=false`). - After (`010414.log`): **`13,902–17,848` table CBVs/frame (`6.5–8.56 MB`) read in place**, `0` rejected for alignment, `181–260` title heap CBVs, **`copies_fills` `3.10 -> 1.40 ms` (`-1.70 ms` CPU)**. - Note: remains strictly opt-in (`VICTORY_PORT_CBV=1`), as on RTX Ada reading CBVs via `rawBufferLoad` over PCIe bypasses the L1 Constant Cache (`cardmeter` `32.6 -> 40.0 ms`), making it primarily useful on CPU-bound/lower-resolution configurations or future VRAM-placed constant heaps. ## Verification - `git merge-tree --write-tree origin/main pr/fix-port-cbv-nvidia-direct-raw-srv`: exit `0` - `cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-shader --lib --locked -- table_constant_buffers_read_as_raw_bytes`: 2/2 pass (WARP D3D12) - `cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- constant_buffer_raw_twins --test-threads=1`: pass - `cargo +1.98.1-x86_64-pc-windows-msvc xtask policy --staged`: pass
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 22:52:06 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 03:12 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-30 03:12 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3396#issuecomment-7267678844) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/3396/head:github-bot/gh-3396'
git switch 'github-bot/gh-3396'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3396'
git switch 'github-bot/gh-3396'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3396'
git switch 'github-bot/gh-3396'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3396'
git switch 'main'
git merge --squash 'github-bot/gh-3396'
git switch 'main'
git merge --ff-only 'github-bot/gh-3396'
git switch 'main'
git merge 'github-bot/gh-3396'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3396
No description provided.