GPU: write a null CBV when CreateConstantBufferView gets a null desc #2447

Merged
makmatvey merged 1 commit from upstream-pr/2449 into main 2026-11-25 21:57:05 +00:00
makmatvey commented 2026-11-25 13:44:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by makmatvey on 2026-11-25T13:44:57Z.


What's wrong

create_cbv ignored a null description and left the previous View (and mirrored host slot) in place. D3D12's CreateConstantBufferView with a null pDesc is valid and writes a null CBV (BufferLocation = 0, SizeInBytes = 0). VIC-BT-016 in #1242.

What the change does

When desc is null, record View::Constant(0, 0) so the title slot is overwritten. Host mirroring already treats Constant views that cannot be made as null buffer views (null_for → null_buffer_view).

Tests

  • Added descriptor::tests::null_cbv_clears_a_stale_view (clears a prior CBV and a prior SRV).
  • cargo xtask policy — ok.
  • Linux agent cannot typecheck victory-gpu (pre-existing view_format / host_resource cfg); Windows CI is the gate.

Asset policy

No game data used.

Fixes VIC-BT-016 in #1242.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6605897321 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2449). Originally posted by [makmatvey](https://github.com/makmatvey) on 2026-11-25T13:44:57Z. --- ## What's wrong `create_cbv` ignored a null description and left the previous `View` (and mirrored host slot) in place. D3D12's `CreateConstantBufferView` with a null `pDesc` is valid and writes a null CBV (`BufferLocation = 0`, `SizeInBytes = 0`). VIC-BT-016 in #1242. ## What the change does When `desc` is null, record `View::Constant(0, 0)` so the title slot is overwritten. Host mirroring already treats `Constant` views that cannot be made as null buffer views (`null_for` → `null_buffer_view`). ## Tests - Added `descriptor::tests::null_cbv_clears_a_stale_view` (clears a prior CBV and a prior SRV). - `cargo xtask policy` — ok. - Linux agent cannot typecheck `victory-gpu` (pre-existing `view_format` / `host_resource` cfg); Windows CI is the gate. ## Asset policy No game data used. Fixes VIC-BT-016 in #1242.
DenRakEiw commented 2026-11-25 14:07:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:55:27Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Writing a null CBV when CreateConstantBufferView receives a null desc cleanly clears stale descriptor slots.
  • cargo test -p victory-gpu descriptor::tests: 6/6 passed on RTX 5090, 6/6 passed on WARP (including null_cbv_clears_a_stale_view).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6058902518 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2449#pullrequestreview-6058902518). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T13:55:27Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Writing a null CBV when `CreateConstantBufferView` receives a null desc cleanly clears stale descriptor slots. - `cargo test -p victory-gpu descriptor::tests`: 6/6 passed on RTX 5090, 6/6 passed on WARP (including `null_cbv_clears_a_stale_view`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
kotekompotek commented 2026-11-25 14:07:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T14:02:19Z.


Correct: D3D12 CreateConstantBufferView with a null description writes a null view, it does not leave the slot alone — an untouched slot would keep the previous CBV live. View::Constant(0, 0) is the existing null form and the test verifies the overwrite (and that a following null SRV behaves the same).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7164661989 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2449#issuecomment-7164661989). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T14:02:19Z. --- Correct: D3D12 `CreateConstantBufferView` with a null description writes a null view, it does not leave the slot alone — an untouched slot would keep the previous CBV live. `View::Constant(0, 0)` is the existing null form and the test verifies the overwrite (and that a following null SRV behaves the same).
catminou4 commented 2026-11-25 15:03:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:23Z.

Review: COMMENTED


Write a null CBV when CreateConstantBufferView gets null. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059178939 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2449#pullrequestreview-6059178939). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:11:23Z. **Review:** COMMENTED --- Write a null CBV when CreateConstantBufferView gets null. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
Marvisak commented 2026-11-25 16:09:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:58:21Z.


Automated triage for the maintainers.

Merge candidate. create_cbv in crates/victory-gpu/src/descriptor.rs now records View::Constant(0, 0) for a null description instead of leaving the slot's previous view in place, which matches the optional description in D3D12's CreateConstantBufferView and how create_srv/create_uav in the same file already record null descriptions. I checked the consumers: host mirroring (descriptor/host.rs make/null_for) and bindless.rs find no shadow at address 0 with size 0 and fall back to a null buffer view. CI: passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167476882 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2449#issuecomment-7167476882). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:58:21Z. --- <!-- victory-triage v1 head=30b9adcb3b87a02e48be67a36d2633213b345180 verdict=merge-candidate at=2026-11-25T15:58:11Z --> Automated triage for the maintainers. Merge candidate. `create_cbv` in `crates/victory-gpu/src/descriptor.rs` now records `View::Constant(0, 0)` for a null description instead of leaving the slot's previous view in place, which matches the optional description in D3D12's `CreateConstantBufferView` and how `create_srv`/`create_uav` in the same file already record null descriptions. I checked the consumers: host mirroring (`descriptor/host.rs` `make`/`null_for`) and `bindless.rs` find no shadow at address 0 with size 0 and fall back to a null buffer view. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:03:42 +00:00
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!2447
No description provided.