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

Open
qlfu wants to merge 1 commit from upstream-pr/3396 into main
qlfu commented 2026-11-29 22:46:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-29T22:46:14Z.


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
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5555969132 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3396). Originally posted by [qlfu](https://github.com/qlfu) on 2026-11-29T22:46:14Z. --- ## 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
dyshay commented 2026-11-30 03:12:12 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T03:12:12Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7267678844 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3396#issuecomment-7267678844). Originally posted by [dyshay](https://github.com/dyshay) on 2026-11-30T03:12:12Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3396:upstream-pr/3396'
git switch 'upstream-pr/3396'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3396'
git switch 'upstream-pr/3396'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3396'
git switch 'upstream-pr/3396'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3396'
git switch 'main'
git merge --squash 'upstream-pr/3396'
git switch 'main'
git merge --ff-only 'upstream-pr/3396'
git switch 'main'
git merge 'upstream-pr/3396'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

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