GPU: clear descriptors for null constant buffers (re-lands #1522) #1916
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1916
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1916/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Calvix2k on GitHub · 2026-11-25 00:52 UTC · original
Calvix2k:codex/gpu-null-cbv-descriptor-016→main· +86 −2 · 3 files · 3 commits · closed without mergingRe-lands #1522 (closed as part of the audit batch; it cannot be reopened because the branch was force-pushed during the rebase).
What
descriptor::create_cbv only records a view when the description is non-null, so a descriptor slot reused after a null CreateConstantBufferView keeps the previous CBV instead of the unbound descriptor the D3D spec defines. main (
4118f33) still behaves that way.Addresses VIC-BT-016 from #1242.
Verification (Windows 10, Ryzen 7 5800X / RX 7800 XT)
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 02:27 UTC · original
I ran a CBV clear through the host shader path on your current head
3734f7b574. Translated table and heap constant views use raw buffer SRVs. Creating a native null CBV in that slot leaves it the wrong descriptor kind for the shader.1eff62e is one commit directly on your head. It reuses the existing raw null SRV and adds a dispatch that reads the same descriptor slot before and after clearing. On WARP with GPU-based validation, both builds read 0x11223344 before the clear. The original head left the output sentinel 0xdeadbeef after it. The fixed build wrote 0.
The full WARP GPU suite passed with 148 tests and 2 ignored. Strict GPU Clippy and asset policy passed.
@Marvisak on GitHub · 2026-11-25 08:18 UTC · original · edited 2026-11-25 12:28 UTC
Automated triage for the maintainers.
Merge candidate. At
725a352, andrewpozdnakov7-jpg's shader-read fixture is cherry-picked as its own commit with their authorship. It iscleared_constant_view_reads_zero_as_a_raw_buffer, a test-only addition incrates/victory-gpu/src/draw.rs. It reads0x11223344through the slot before the clear and 0 after. On the earlier head (3734f7b) it shows the sentinel, so it tests the descriptor kind and not only that the device survives.The host-side fix is unchanged from the last review and right. In
descriptor/host.rs,maketurnsView::NullConstantintonull_buffer_view(at), so the slot stays a raw buffer SRV, the kind translated shaders read constant views through.descriptor::create_cbvrecords the null description, andviews_survive_copiescovers the recording. CIcheckpasses at725a352.Generated by Claude Code
@Calvix2k on GitHub · 2026-11-25 08:34 UTC · original
The host-side half is fixed in
734d85a:View::NullConstantnow calls the existingnull_buffer_view(at)and returnsSome(None), so the slot keeps a raw SRV like every other buffer read through the heap.On the test half I tried to build the shader-read fixture and could not get it to produce a nonzero "before" value here: a
View::Constantover a title buffer created withcreate_committedmakesmakereturnNone(buffer_srvcannot find a host copy for that range), and a host buffer's VA is not title memory. Rather than commit a test that reads zeros twice and proves nothing, I left the device test as it is and am asking:shadow::register?) that I can use, orbefore/aftershader read from 1eff62e as part of this PR?The
recordside is covered byviews_survive_copies(it asserts the slot becomesView::NullConstant).@andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:47 UTC · original
Yes. I put the shader-read fixture in a2cc866, directly on your
734d85ab072884d274a8e69ac261fd4107026474. The change adds only the test.The nonzero control uses
resource::test_buffer(16)and takes the title address frombuffer_bytes. That committed buffer is registered by the normal resource creation path, and the test holds it through both dispatches. It callsreadablebefore dispatch to refresh the buffer's host copy.With WARP GPU-based validation, the same fixture reads
0x11223344before the clear on both heads. On3734f7b, the clear leaves0xdeadbeefin the output. On734d85a, your raw null SRV writes zero. The full WARP GPU suite passed with 148 tests, 2 ignored. Strict GPU Clippy and staged asset policy passed.Please preserve the test commit's Git author if you cherry-pick it. If you fold the test into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@Calvix2k on GitHub · 2026-11-25 12:19 UTC · original
@andrewpozdnakov7-jpg — cherry-picked as its own commit,
725a352, so your authorship stays (Author: andrewpozdnakov7-jpg, date and message unchanged); noCo-authored-byneeded since it is not folded into anything.Ran here after the pick:
cargo test -p victory-gpu --features diagnostics --libon Windows 10 19045 / RX 7800 XT — 147 passed, 2 ignored, and the only failure is the known placed-view test on a runtime withoutID3D12Device10(#1999, identical onmain). Yourcleared_constant_view_reads_zero_as_a_raw_bufferpasses on the AMD card as well as it did on WARP.Thanks for taking the fixture over — that was the one part of this PR I could not write honestly myself (the control needs a committed buffer and the dispatch ordering you describe).
@Marvisak on GitHub · 2026-11-25 22:04 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing in favour of #2449, which makes the same fix in 33 lines by recording
Constant(0, 0), the representationmainalready uses for a zeroed description, without a new enum variant. The change here is correct for D3D12 and its tests pass onmain.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed