GPU: clear descriptors for null constant buffers #1521

Closed
Calvix2k wants to merge 1 commit from upstream-pr/1522 into main
Calvix2k commented 2026-11-24 18:44:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T18:44:52Z.


Summary

Fixes VIC-BT-016 from audit issue #1242.

When CreateConstantBufferView receives a null description, VIctory previously left its descriptor metadata untouched. Reusing a slot could therefore preserve the old CBV. The view model now records an explicit null CBV and mirrors it as an unbound descriptor in the host heap.

The regression coverage verifies that a previously valid CBV is replaced by the null view, and exercises the null CBV creation call on the host D3D12 device.

Verification

  • cargo test -p victory-gpu --lib --locked — 51 passed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings — clean
  • cargo xtask policy --staged — passed
  • git diff --check — passed

The DirectX specification states that passing a null view description for a descriptor heap CBV results in unbound behavior: https://microsoft.github.io/DirectX-Specs/d3d/ResourceBinding.html

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588945748 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1522). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T18:44:52Z. --- ## Summary Fixes `VIC-BT-016` from audit issue #1242. When `CreateConstantBufferView` receives a null description, VIctory previously left its descriptor metadata untouched. Reusing a slot could therefore preserve the old CBV. The view model now records an explicit null CBV and mirrors it as an unbound descriptor in the host heap. The regression coverage verifies that a previously valid CBV is replaced by the null view, and exercises the null CBV creation call on the host D3D12 device. ## Verification - `cargo test -p victory-gpu --lib --locked` — 51 passed, 1 ignored - `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` — clean - `cargo xtask policy --staged` — passed - `git diff --check` — passed The DirectX specification states that passing a null view description for a descriptor heap CBV results in unbound behavior: https://microsoft.github.io/DirectX-Specs/d3d/ResourceBinding.html
upstream-sync closed this pull request 2026-11-24 19:03:49 +00:00
Calvix2k commented 2026-11-25 01:08:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T00:52:17Z.


Still needed on main (4118f33): descriptor::create_cbv only records a view when the description is non-null, so reusing a descriptor slot after a null CreateConstantBufferView keeps the previous CBV instead of the unbound one the D3D spec asks for. This PR adds View::NullConstant and mirrors it as an unbound host descriptor.

Rebased on current main; the only conflict was an old impl View { is_buffer } that main has since moved into descriptor/host.rs (dropped here, the host logic is unchanged).

Verified on Windows 10, Ryzen 7 5800X / RX 7800 XT:

  • iews_survive_copies (CPU) passes;

ull_constant_buffer_view_is_accepted_by_the_device passes on the host device (the slot is cleared, device not removed);

  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings clean;
  • cargo xtask policy 182 files ok.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7148975271 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1522#issuecomment-7148975271). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T00:52:17Z. --- Still needed on main (4118f33): descriptor::create_cbv only records a view when the description is non-null, so reusing a descriptor slot after a null CreateConstantBufferView keeps the previous CBV instead of the unbound one the D3D spec asks for. This PR adds View::NullConstant and mirrors it as an unbound host descriptor. Rebased on current main; the only conflict was an old impl View { is_buffer } that main has since moved into descriptor/host.rs (dropped here, the host logic is unchanged). Verified on Windows 10, Ryzen 7 5800X / RX 7800 XT: - iews_survive_copies (CPU) passes; - ull_constant_buffer_view_is_accepted_by_the_device passes on the host device (the slot is cleared, device not removed); - cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings clean; - cargo xtask policy 182 files ok.
Calvix2k commented 2026-11-25 01:08:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T00:52:38Z.


Re-landed as #1916 (this PR cannot be reopened after the rebase force-pushed the branch). Same commit, rebased on 4118f33.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148981059 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1522#issuecomment-7148981059). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T00:52:38Z. --- Re-landed as #1916 (this PR cannot be reopened after the rebase force-pushed the branch). Same commit, rebased on 4118f33.

Pull request closed

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
Marvisak/VIctory!1521
No description provided.