fix(victory-gpu): clear stale constant buffer views on null descriptions #305

Open
github-bot wants to merge 3 commits from github-bot/gh-305 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 01:55 UTC · original
mauroalvare:codex/victory-null-cbv → main · +43 −6 · 4 files · 3 commits · open

Change

Passing a null description to CreateConstantBufferView left the previous descriptor in its slot in the Neptune runtime. A shader could still read the old constants, and copying the descriptor copied the stale binding.

Record a null CBV in create_cbv so regular descriptor copies and heap mirroring see the replacement. Make zero-sized CBVs use the existing typed null descriptor in both the mirrored heap and the dynamic draw table, avoiding a shadow allocation and a constant upload. This is the victory-gpu path used by tools/lancer_victory.ps1.

Ported from Marvisak/VIctory 78ed12eb by Matsvey Makushenka, credited in THIRD_PARTY.md and in the commit. The DirectX resource binding specification defines the behavior of a null CBV description.

Verification

Base c4c93bdc413191a9dc909998d2d53080a3f0c880. Fix 3445b080a9260af590e045c0e63bb8d7cfac3097. Windows x64, Rust 1.98.1 MSVC, RTX 5070 Ti (driver 621.40) and WARP (Microsoft Basic Render Driver).

With the new descriptor regression test applied to base, a_null_cbv_overwrites_a_bound_slot_and_can_be_copied failed because the old Constant(0x1_0000_1000, 256) remained in the source slot. Both new tests pass with the fix on NVIDIA and with VICTORY_D3D12_WARP=1. The same tests pass on NVIDIA with VICTORY_VIEW_INLINE=0.

Command from third_party/victory Result
cargo test --locked --offline -p victory-gpu --lib --features diagnostics a_null_cbv -- --test-threads=1 2 passed in each configuration above
cargo test --locked --offline -p victory-gpu --lib --features diagnostics -- --test-threads=1 198 passed, 3 failed, 3 ignored (base 196 passed, same 3 failures and ignores)
cargo test --locked --offline -p victory-loader --test load_probe 2 passed
cargo build --locked --offline --release -p victory Built the release launcher runtime
cargo xtask policy 199 files OK

The three existing GPU suite failures are spans_say_the_next_start_and_the_lowest_level_viewed, warp_card_fetch_copies_flagged_pieces_to_their_slots, and warp_card_patch_writes_the_masked_bytes_and_no_others.

From the repository root, python -m pytest -rs returned 1,342 passed and 323 skipped. The local checkout lacks the built C++ runtime, GPU runner and TomBox/Rust artifacts used by those tests. python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools passed.

Oracle and test data

The failure case writes a known CBV, replaces it with a null description and copies the slot. A separate synthetic D3D12 probe ran a compute shader that read the mirrored descriptor and stored one word in a readback buffer. The native control overwrote the same D3D12 descriptor with CreateConstantBufferView(None, slot).

Readback on RTX 5070 Ti and WARP Base Fix
Bound constants 0x13579bdf 0x13579bdf
After a null description in Neptune 0x13579bdf 0x00000000
After the native D3D12 null description 0x00000000 0x00000000

Both readback cases executed on both adapters. All data and shaders were generated in the tests. No game, console or SDK files were used.

Prepared with AI assistance (OpenAI Codex).

Rebase verification

Rebased on c41c224 and merged the source credit into the current THIRD_PARTY.md table. cargo test --locked --offline -j 4 -p victory-gpu null_cbv -- --test-threads=1 passed both CBV tests.

**@⁠mauroalvare** on GitHub · 2026-11-26 01:55 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/305) `mauroalvare:codex/victory-null-cbv` → `main` · +43 −6 · 4 files · 3 commits · open ## Change Passing a null description to `CreateConstantBufferView` left the previous descriptor in its slot in the Neptune runtime. A shader could still read the old constants, and copying the descriptor copied the stale binding. Record a null CBV in `create_cbv` so regular descriptor copies and heap mirroring see the replacement. Make zero-sized CBVs use the existing typed null descriptor in both the mirrored heap and the dynamic draw table, avoiding a shadow allocation and a constant upload. This is the `victory-gpu` path used by `tools/lancer_victory.ps1`. Ported from [Marvisak/VIctory `78ed12eb`](https://github.com/Marvisak/VIctory/commit/78ed12eb79774bf141efaaf6ebd626a10bfb5bbf) by Matsvey Makushenka, credited in `THIRD_PARTY.md` and in the commit. The [DirectX resource binding specification](https://microsoft.github.io/DirectX-Specs/d3d/ResourceBinding.html#null-descriptors) defines the behavior of a null CBV description. ## Verification Base `c4c93bdc413191a9dc909998d2d53080a3f0c880`. Fix `3445b080a9260af590e045c0e63bb8d7cfac3097`. Windows x64, Rust 1.98.1 MSVC, RTX 5070 Ti (driver 621.40) and WARP (Microsoft Basic Render Driver). With the new descriptor regression test applied to base, `a_null_cbv_overwrites_a_bound_slot_and_can_be_copied` failed because the old `Constant(0x1_0000_1000, 256)` remained in the source slot. Both new tests pass with the fix on NVIDIA and with `VICTORY_D3D12_WARP=1`. The same tests pass on NVIDIA with `VICTORY_VIEW_INLINE=0`. | Command from `third_party/victory` | Result | | --- | --- | | `cargo test --locked --offline -p victory-gpu --lib --features diagnostics a_null_cbv -- --test-threads=1` | 2 passed in each configuration above | | `cargo test --locked --offline -p victory-gpu --lib --features diagnostics -- --test-threads=1` | 198 passed, 3 failed, 3 ignored (base 196 passed, same 3 failures and ignores) | | `cargo test --locked --offline -p victory-loader --test load_probe` | 2 passed | | `cargo build --locked --offline --release -p victory` | Built the release launcher runtime | | `cargo xtask policy` | 199 files OK | The three existing GPU suite failures are `spans_say_the_next_start_and_the_lowest_level_viewed`, `warp_card_fetch_copies_flagged_pieces_to_their_slots`, and `warp_card_patch_writes_the_masked_bytes_and_no_others`. From the repository root, `python -m pytest -rs` returned 1,342 passed and 323 skipped. The local checkout lacks the built C++ runtime, GPU runner and TomBox/Rust artifacts used by those tests. `python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools` passed. ## Oracle and test data The failure case writes a known CBV, replaces it with a null description and copies the slot. A separate synthetic D3D12 probe ran a compute shader that read the mirrored descriptor and stored one word in a readback buffer. The native control overwrote the same D3D12 descriptor with `CreateConstantBufferView(None, slot)`. | Readback on RTX 5070 Ti and WARP | Base | Fix | | --- | --- | --- | | Bound constants | `0x13579bdf` | `0x13579bdf` | | After a null description in Neptune | `0x13579bdf` | `0x00000000` | | After the native D3D12 null description | `0x00000000` | `0x00000000` | Both readback cases executed on both adapters. All data and shaders were generated in the tests. No game, console or SDK files were used. Prepared with AI assistance (OpenAI Codex). ## Rebase verification Rebased on `c41c224` and merged the source credit into the current `THIRD_PARTY.md` table. `cargo test --locked --offline -j 4 -p victory-gpu null_cbv -- --test-threads=1` passed both CBV tests.
Record a typed null descriptor when the title passes a null description.
Reuse the host null CBV for mirrored slots and dynamic tables without
allocating a shadow buffer or copying constants.

Source: Marvisak/VIctory 78ed12eb79774bf141efaaf6ebd626a10bfb5bbf
Co-authored-by: Matsvey Makushenka <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:42:32 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 14:01 UTC · original

This PR now conflicts with main in THIRD_PARTY.md (the sources table moved after the recent merges, including #351). Please rebase on main (git fetch origin && git rebase origin/main), keep both sides of the table rows, and force-push your branch; CI must then pass again before review.

🤖 Generated with Claude Code

**@⁠LooperSalty** on GitHub · 2026-11-26 14:01 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/305#issuecomment-7194168923) This PR now conflicts with main in `THIRD_PARTY.md` (the sources table moved after the recent merges, including #351). Please rebase on main (`git fetch origin && git rebase origin/main`), keep both sides of the table rows, and force-push your branch; CI must then pass again before review. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot force-pushed github-bot/gh-305 from 3445b080a9 to d195e9e2ea 2026-11-26 18:10:44 +00:00 Compare
Author
Owner

@⁠mauroalvare on GitHub · 2026-11-26 18:25 UTC · original

Rebased and pushed. I added the null-CBV attribution to the current THIRD_PARTY.md table alongside the credits on main.

Both focused tests passed. A null CBV clears an already-bound slot and can be copied, and the host descriptor can be created without a backing buffer.

The latest CI run passed.

**@⁠mauroalvare** on GitHub · 2026-11-26 18:25 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/305#issuecomment-7200441042) Rebased and pushed. I added the null-CBV attribution to the current `THIRD_PARTY.md` table alongside the credits on main. Both focused tests passed. A null CBV clears an already-bound slot and can be copied, and the host descriptor can be created without a backing buffer. [The latest CI run passed](https://github.com/LooperSalty/AnyXboxX/actions/runs/45872833446).
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/305/head:github-bot/gh-305'
git switch 'github-bot/gh-305'

Merge

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