GPU/descriptor: handle null CBVs without leaving stale views or VA-0 shadows #304
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-24T23:25:41Z.
Problem
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.)
Imported from fxceless/victory-fork. Originally posted by gmankab on 2026-11-26T10:46:17Z.
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
Imported from fxceless/victory-fork. Originally posted by CwWwWwW on 2026-11-27T09:14:32Z.
Independent check of current main (
9a9091d, 2026-11-27): all three problems described here are still present, so this PR is still needed.crates/victory-gpu/src/descriptor.rs:1220-create_cbvstill only callsrecord()whenwords(desc)isSome, so a null description leaves the slot's previous view recorded.crates/victory-gpu/src/descriptor/host.rs:3631-make()still callscrate::shadow::find(address, u64::from(size))forView::Constantwithout anaddress == 0 || size == 0early return.crates/victory-gpu/src/draw.rs:4153and:4202- the CBV-table path still falls back tohost.make_null(index), i.e. a null 2D texture SRV in a CBV slot.Note that the PR is currently
mergeable=False(it conflicts with main -descriptor.rs/draw.rs/host.rshave moved since its base). A rebase preserving the three fixes and the two tests should still apply; the discussion here remains relevant.(Offline code check only; no game data. This fork also has the same class fixed upstream as VIctory #2449, but this PR additionally covers the VA-0 shadow and dynamic-CBV parts.)
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.