GPU/descriptor: handle null CBVs without leaving stale views or VA-0 shadows #304
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!304
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-304"
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?
@AscilCH on GitHub · 2026-11-24 23:25 UTC · original
AscilCH:fix/gpu-null-cbv-handling→main· +40 −5 · 3 files · 1 commits · openProblem
Three bugs when a title creates a null constant buffer view (
CreateConstantBufferView(NULL, handle)orSizeInBytes == 0/BufferLocation == 0):crates/victory-gpu/src/descriptor.rs):create_cbvskippedrecord()whendescwas null, leaving whatever previous CBV/SRV/UAV occupied the handle active.0x0+ invalid D3D12 CBV (crates/victory-gpu/src/descriptor/host.rs):make()calledshadow::find(address, size)even whenaddress == 0 || size == 0, creating a 4 MiB loose shadow buffer for VA0x0and passing{ BufferLocation: non_zero_gpu_va, SizeInBytes: 0 }toCreateConstantBufferViewinstead of returningNonefornull_for(which writes the canonical null CBVD3D12_CONSTANT_BUFFER_VIEW_DESC::default()).crates/victory-gpu/src/draw.rs):State::tablescalledlist.scratch(0)+defer_fill(to, NULL, 0)and emitted{ BufferLocation: non_zero_gpu_va, SizeInBytes: 0 }; on scratch failure it wrotehost.make_null(index)(a null 2D Texture SRV) into a CBV slot.Fix
View::Constant(0, 0)indescriptor::create_cbvwhendescis null.Noneearly indescriptor::host::makewhenaddress == 0 || size == 0sonull_forwrites a canonical null CBV without callingshadow::find.host.constant_at(index, 0, 0)indraw::State::tableswhenaddress == 0 || size == 0or whenlist.scratchreturnsNone.descriptor::tests::null_cbv_overwrites_previous_descriptoranddescriptor::host::tests::null_cbv_does_not_allocate_shadow_at_zero.Verification
rustfmt --edition 2024 --check(changed hunks): cleancargo test -p victory-gpu --locked descriptor -- --test-threads=1: 17 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-gpu --all-targets --locked -- -D warnings: cleancargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
Fix three null-CBV bugs across `descriptor.rs`, `descriptor/host.rs`, and `draw.rs`: 1. `descriptor::create_cbv` returned without calling `record()` when `desc == NULL`, leaving whatever previous view occupied the slot alive. Record `View::Constant(0, 0)` on null `desc`. 2. `descriptor::host::make` called `shadow::find(address, size)` even when `address == 0 || size == 0`, allocating a bogus 4 MiB loose shadow at VA `0x0` and emitting an invalid CBV `{ BufferLocation: non_zero, SizeInBytes: 0 }`. Return `None` so callers emit the canonical null CBV via `null_for`. 3. `draw::State::tables` called `list.scratch(0)` + `defer_fill(to, NULL, 0)` for null CBVs and fell back to `host.make_null(index)` (a null 2D texture SRV) on scratch exhaustion. Emit `host.constant_at(index, 0, 0)` directly for null CBVs and on scratch fallback. Add unit tests in `descriptor::tests` and `descriptor::host::tests`.@gmankab on GitHub · 2026-11-26 10:46 UTC · original
I independently tested this fix in the Wine-free Victory runtime on Fedora Linux 45. Both null-CBV regressions failed before the port. On the corresponding native PR branch, all seven descriptor tests passed on RX 6800 RADV and Lavapipe with Vulkan validation.
In a 460-second Lavapipe Series S loading comparison, the control logged 22 zero-byte CBV calls and nine Vulkan zero-range validation messages. With the fix, both counts were zero. The title still timed out on the illustrated loading screen.
The native port preserves AscilCH’s authorship. https://github.com/spidercraft/VIctory/pull/27
Tested-on: RX 6800, Fedora Linux 45, RADV and Lavapipe
Assisted-by: gpt-6.2 sol xhigh
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.