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

Manually merged
github merged 1 commit from gh-pr/2449/head into gh-pr/2449/base 2026-11-26 05:06:14 +00:00
Owner

@⁠makmatvey on GitHub · 2026-11-25 13:44 UTC · original
makmatvey:cursor/gpu-create-cbv-null-debc → main · +29 −4 · 1 files · 1 commits · merged 2026-11-25 21:57 UTC

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.

**@⁠makmatvey** on GitHub · 2026-11-25 13:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2449) `makmatvey:cursor/gpu-create-cbv-null-debc` → `main` · +29 −4 · 1 files · 1 commits · merged 2026-11-25 21:57 UTC ## 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.
D3D12 accepts a null description and initializes BufferLocation=0,
SizeInBytes=0. create_cbv returned early instead, so a later null call
left the previous View (and mirrored host slot) active. Record
Constant(0, 0) so the slot is cleared; host mirroring already nulls
Constant views via null_buffer_view.

Fixes VIC-BT-016 in #1242.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:06:13 +00:00
github manually merged commit 30b9adcb3b into gh-pr/2449/base 2026-11-26 05:06:14 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 14:02 UTC · original

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).

**@⁠kotekompotek** on GitHub · 2026-11-25 14:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/2449#issuecomment-7164661989) 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:58 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 15:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2449#issuecomment-7167476882) <!-- 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)_
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!2449
No description provided.