GPU: replace stale descriptors on null CBV writes #1298

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

@⁠EatCodeSleep2 on GitHub · 2026-11-24 17:14 UTC · original
EatCodeSleep2:fix/null-constant-buffer-descriptors-1242 → main · +17 −5 · 3 files · 1 commits · open

Summary

Write a null constant-buffer record when the title passes a null CBV description. This overwrites the previous record and uses the existing typed-null CBV path on the host, including for transient descriptor tables. A zero-address view never needs a scratch upload.

Refs #1242, finding VIC-BT-016. D3D12 CreateConstantBufferView

Verification

  • The new synthetic regression retains the old view on main and sees a null constant-buffer record with this patch.
  • GPU library tests passed in both configurations (51 default, 54 with diagnostics, one ignored in each).
  • GPU all-targets Clippy with diagnostics and warnings denied passed.

The regression checks the guest descriptor update. It does not read back a null CBV in a shader. AI-assisted. No game files used.

**@⁠EatCodeSleep2** on GitHub · 2026-11-24 17:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1298) `EatCodeSleep2:fix/null-constant-buffer-descriptors-1242` → `main` · +17 −5 · 3 files · 1 commits · open ## Summary Write a null constant-buffer record when the title passes a null CBV description. This overwrites the previous record and uses the existing typed-null CBV path on the host, including for transient descriptor tables. A zero-address view never needs a scratch upload. Refs #1242, finding VIC-BT-016. [D3D12 CreateConstantBufferView](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-createconstantbufferview) ## Verification - The new synthetic regression retains the old view on main and sees a null constant-buffer record with this patch. - GPU library tests passed in both configurations (51 default, 54 with diagnostics, one ignored in each). - GPU all-targets Clippy with diagnostics and warnings denied passed. The regression checks the guest descriptor update. It does not read back a null CBV in a shader. AI-assisted. No game files used.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:45 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:24 UTC · original

Independent verification of \df8f906\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:

  • Merge check vs \main\ (\ fe310e): clean
  • \cargo test -p victory-gpu --lib: 51 passed, 0 failed, 1 ignored (including \_null_cbv_overwrites_the_previous_descriptor)
  • \cargo clippy -p victory-gpu --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 154 files ok

Code audit looks clean and minimal: recording \View::Constant(0, 0)\ on null \CreateConstantBufferView\ clears stale entries while both \descriptor/host.rs\ (\View::Constant(0, _) => None) and \draw.rs\ (\if address != 0) route address-0 CBVs cleanly to typed null descriptors.

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1298#issuecomment-7139153609) Independent verification of \df8f906\ on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200\) / Rust 1.98.1 MSVC**: - Merge check vs \main\ (\ fe310e\): clean - \cargo test -p victory-gpu --lib\: **51 passed, 0 failed, 1 ignored** (including \_null_cbv_overwrites_the_previous_descriptor\) - \cargo clippy -p victory-gpu --all-targets -- -D warnings\ (default and \--all-features\): clean - \cargo xtask policy\: 154 files ok Code audit looks clean and minimal: recording \View::Constant(0, 0)\ on null \CreateConstantBufferView\ clears stale entries while both \descriptor/host.rs\ (\View::Constant(0, _) => None\) and \draw.rs\ (\if address != 0\) route address-0 CBVs cleanly to typed null descriptors. *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 18:44 UTC · original

Reviewed at head df8f906 (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked:

1. The bug and the fix are both right. create_cbv with a null desc (the title unbinding a CBV) used to skip record, so the heap slot kept the previous View::Constant — a stale descriptor. Now a null desc records View::Constant(0, 0) (words(desc).unwrap_or_default()), which every consumer treats as null: make returns None for View::Constant(0, _) (host.rs:631), so make_at/null_for write a typed null CBV (zero location, the Constant arm of null_for); the root-table fill in draw.rs:744 guards address != 0 so a null CBV goes through make_at → null instead of scratch-allocating a copy of address 0; the remaining View::Constant consumer (draw.rs:1180) is debug formatting and is unaffected (size 0 < 16). I checked all four View::Constant sites — no stale path left.

2. Red/green proven here. Reverting just the create_cbv hunk in the worktree makes the new a_null_cbv_overwrites_the_previous_descriptor fail (slot still reads Constant(0x1000, 256) after the null write); on df8f906 it passes with Constant(0, 0). So the branch changes exactly the null-overwrite case.

3. Checks on df8f906: cargo test -p victory-gpu 51 passed / 0 failed / 1 ignored (new test included); cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings clean; cargo build --release -p victory builds; rustfmt --edition 2024 --check on all three changed files shows exactly the same hunks main has (host.rs shifted by the +2 lines) — no new fmt diffs.

4. Note, not a defect: a non-null desc with BufferLocation == 0 and nonzero size now also lands in the Constant(0, _) null arm of make (previously it would try shadow::find(0, size) and fail to null anyway). Address 0 is not a valid title CBV, so treating it as null is the safer reading; the recorded view keeps the real size for diagnostics.

Nothing found that would block this.

**@⁠adamdotpy** on GitHub · 2026-11-24 18:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/1298#issuecomment-7141095676) Reviewed at head `df8f906` (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked: **1. The bug and the fix are both right.** `create_cbv` with a null `desc` (the title unbinding a CBV) used to skip `record`, so the heap slot kept the previous `View::Constant` — a stale descriptor. Now a null desc records `View::Constant(0, 0)` (`words(desc).unwrap_or_default()`), which every consumer treats as null: `make` returns `None` for `View::Constant(0, _)` (`host.rs:631`), so `make_at`/`null_for` write a typed null CBV (zero location, the `Constant` arm of `null_for`); the root-table fill in `draw.rs:744` guards `address != 0` so a null CBV goes through `make_at` → null instead of scratch-allocating a copy of address 0; the remaining `View::Constant` consumer (`draw.rs:1180`) is debug formatting and is unaffected (size 0 < 16). I checked all four `View::Constant` sites — no stale path left. **2. Red/green proven here.** Reverting just the `create_cbv` hunk in the worktree makes the new `a_null_cbv_overwrites_the_previous_descriptor` fail (slot still reads `Constant(0x1000, 256)` after the null write); on `df8f906` it passes with `Constant(0, 0)`. So the branch changes exactly the null-overwrite case. **3. Checks on `df8f906`:** `cargo test -p victory-gpu` 51 passed / 0 failed / 1 ignored (new test included); `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` clean; `cargo build --release -p victory` builds; `rustfmt --edition 2024 --check` on all three changed files shows exactly the same hunks `main` has (host.rs shifted by the +2 lines) — no new fmt diffs. **4. Note, not a defect:** a *non-null* desc with `BufferLocation == 0` and nonzero size now also lands in the `Constant(0, _)` null arm of `make` (previously it would try `shadow::find(0, size)` and fail to null anyway). Address 0 is not a valid title CBV, so treating it as null is the safer reading; the recorded view keeps the real size for diagnostics. Nothing found that would block this.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:21 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/draw.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1298#issuecomment-7149467864) <!-- victory-triage v1 head=df8f906b1e595f1c9b60b0080927e1c5e634f5c9 verdict=needs-rebase at=2026-11-25T01:21:42Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/draw.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor.rs
  • crates/victory-gpu/src/draw.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1298'
git switch 'github-bot/gh-1298'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1298'
git switch 'github-bot/gh-1298'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1298'
git switch 'main'
git merge --squash 'github-bot/gh-1298'
git switch 'main'
git merge --ff-only 'github-bot/gh-1298'
git switch 'main'
git merge 'github-bot/gh-1298'
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/Marvisak--VIctory!1298
No description provided.