GPU descriptor: write null CBV when create_cbv description is null #1573

Closed
geiyiliyabumo wants to merge 1 commit from upstream-pr/1574 into main
geiyiliyabumo commented 2026-11-24 19:22:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T19:22:39Z.


Summary

Fixes create_cbv silently ignoring a null D3D12_CONSTANT_BUFFER_VIEW_DESC pointer instead of overwriting the destination descriptor slot with a null CBV (tracking issue #1242, VIC-BT-016).

Per the D3D12 specification, ID3D12Device::CreateConstantBufferView(NULL, DestDescriptor) creates a null CBV descriptor, replacing any prior view at DestDescriptor. Previously create_cbv skipped record(...) when desc was null, leaving stale CBV/SRV/UAV entries active in CPU view tracking and host descriptor heaps.

Changes

  • crates/victory-gpu/src/descriptor.rs: Add View::NullConstant (non-buffer) and record it in create_cbv when desc is null, overwriting any prior view at handle. Add synthetic unit test null_cbv_overwrites_an_existing_view.
  • crates/victory-gpu/src/descriptor/host.rs: Handle View::NullConstant in make and null_for via null_cbv (CreateConstantBufferView(None, at)), clearing any previously retained host resource in that slot. Add live D3D12/WARP regression test null_cbv_is_mirrored_without_a_buffer.

Verification

  • cargo test -p victory-gpu --lib descriptor: 9/9 passed on AMD Radeon RX 9060 XT (RDNA4) and WARP (--features diagnostics).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features): clean.
  • cargo xtask policy: 154 files OK.

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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6589610363 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1574). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T19:22:39Z. --- ## Summary Fixes `create_cbv` silently ignoring a null `D3D12_CONSTANT_BUFFER_VIEW_DESC` pointer instead of overwriting the destination descriptor slot with a null CBV (tracking issue #1242, `VIC-BT-016`). Per the D3D12 specification, `ID3D12Device::CreateConstantBufferView(NULL, DestDescriptor)` creates a null CBV descriptor, replacing any prior view at `DestDescriptor`. Previously `create_cbv` skipped `record(...)` when `desc` was null, leaving stale CBV/SRV/UAV entries active in CPU view tracking and host descriptor heaps. ### Changes - `crates/victory-gpu/src/descriptor.rs`: Add `View::NullConstant` (non-buffer) and record it in `create_cbv` when `desc` is null, overwriting any prior view at `handle`. Add synthetic unit test `null_cbv_overwrites_an_existing_view`. - `crates/victory-gpu/src/descriptor/host.rs`: Handle `View::NullConstant` in `make` and `null_for` via `null_cbv` (`CreateConstantBufferView(None, at)`), clearing any previously retained host resource in that slot. Add live D3D12/WARP regression test `null_cbv_is_mirrored_without_a_buffer`. ### Verification - `cargo test -p victory-gpu --lib descriptor`: **9/9 passed** on **AMD Radeon RX 9060 XT (RDNA4)** and **WARP** (`--features diagnostics`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings` (default & `--all-features`): clean. - `cargo xtask policy`: 154 files OK. *AI-assisted; synthetic tests only, no game files.*
DenRakEiw commented 2026-11-24 20:02:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T19:30:31Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 52 passed, 0 failed (1 ignored) on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (including null_cbv_overwrites_an_existing_view and null_cbv_is_mirrored_without_a_buffer)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean null CBV descriptor handling when create_cbv receives a null description, including proper mirroring. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045957169 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1574#pullrequestreview-6045957169). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T19:30:31Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — 52 passed, 0 failed (1 ignored) on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (including `null_cbv_overwrites_an_existing_view` and `null_cbv_is_mirrored_without_a_buffer`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean null CBV descriptor handling when `create_cbv` receives a null description, including proper mirroring. Looks good. AI-assisted (Gemini 4 Neon).
upstream-sync closed this pull request 2026-11-25 01:06:53 +00:00
Marvisak commented 2026-11-25 01:08:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:42:46Z.


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1298. Same null-CBV-description fix as the smaller #1298, built on a host null CBV (CreateConstantBufferView) that no longer matches main, where constant buffers are raw views.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148797151 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1574#issuecomment-7148797151). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:42:46Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1298. Same null-CBV-description fix as the smaller #1298, built on a host null CBV (CreateConstantBufferView) that no longer matches main, where constant buffers are raw views. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

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!1573
No description provided.