fix(gpu): bind bounded single-descriptor tables for root SRVs and UAVs #3337
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!3337
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3337"
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?
@legayclightning22 on GitHub · 2026-11-26 18:58 UTC · original
legayclightning22:fix/bounded-root-srv-uav-tables→main· +339 −59 · 2 files · 1 commits · openSummary
Binds bounded single-descriptor tables for root SRVs and UAVs in
victory-gpu(crates/victory-gpu/src/draw.rsandcrates/victory-gpu/src/pipeline/host.rs), with aVICTORY_ROOT_SRV_DIRECTopt-out for direct root binding.Changes
crates/victory-gpu/src/draw.rsandcrates/victory-gpu/src/pipeline/host.rsto use bounded single-descriptor tables[cite: 18].VICTORY_ROOT_SRV_DIRECTopt-out support and unit tests covering bounded root views and environment override behavior[cite: 18].Verification
cargo test -p victory-gpu --lib[cite: 18]cargo clippy --locked -p victory-gpu --all-targets -- -D warnings[cite: 18]cargo xtask policy[cite: 18]@Dukestar69 on GitHub · 2026-11-26 19:09 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).cargo test -p victory-gpu --lib pipeline::host:: -- --test-threads=1: 7 passed, 0 failed (root_srv_direct_only_for_one,root_srv_direct_opt_out_keeps_raw_addresses,root_srvs_and_uavs_are_bounded_one_descriptor_tables).cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@oni-swr on GitHub · 2026-11-26 19:16 UTC · original
WARP/CPU verification of head
8dd2ca97(claim: #1633)Environment: Windows 11, WARP only (
VICTORY_WARP=1,VICTORY_D3D12_WARP=1),dxil.dllfrom Windows SDK 10.0.26100.0 (VICTORY_DXIL), no physical GPU, no game files.-j 4,--locked, separate target dir. Control:origin/main@63bcca43. Merge:git merge-treeagainst currentorigin/mainis clean (head is 1 commit ahead, 0 behind).63bcca438dd2ca97cargo test -p victory-gpucargo clippy -p victory-gpu --all-targets -- -D warningsxtask policyNew tests all pass on WARP:
root_srvs_and_uavs_are_bounded_one_descriptor_tables,root_srv_direct_opt_out_keeps_raw_addresses,root_srv_direct_only_for_one. They are absent on control (added by this PR); I did not separately demonstrate them failing without the fix. Synthetic/unit tests only; no real-title rendering was checked.AI disclosure: run by Claude Code (Claude Sonnet 5.5), coordinated by Antigravity.
@fuzeofficlal on GitHub · 2026-11-26 20:58 UTC · original · requested changes
Converting raw root SRVs/UAVs to bounded single-descriptor tables is a solid goal, and
pipeline/host.rscleanly switchesroot_srvs/root_uavstoD3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLEwith theVICTORY_ROOT_SRV_DIRECT=1opt-out. However, there is a silent data-corruption bug inState::root_tablewhenever a title binds a root SRV or root UAV at a non-zero offset inside a buffer.Blocking issue:
State::root_tablediscards the byte offset (crates/victory-gpu/src/draw.rs:1064, 1080-1092)In
crates/victory-gpu/src/draw.rs:root_view_slotcreates the raw view atfirst = 0(shadow.start) and caches it per(key, copy, uav):root_tablethen callsroot_view_slotand discards the returnedoffset(address - shadow.start):Reusing a
first = 0view only works for theis_root_viewuser-data path (victory-shader/src/emit/lower.rs:1695-1733,!self.root_memory), where the shader receivesoffsetin aROOT_VIEW_OFFSETuser-data dword and adds it to every byte address. For shaders that populatestage.root_srvs/stage.root_uavs(victory-shader/src/emit/lower.rs:5447-5459,root_memory == true),root_view_offset()returnsNone(lower.rs:1724): the shader indexes directly from byte0of the bound resource, relying on the binding itself to start ataddress(asSet*RootShaderResourceView/Set*RootUnorderedAccessView(param, shadow.gpu(address))did onmain).As a result, any root SRV/UAV bound at
address > shadow.start:shadow.start + 0instead ofaddress— which is either unrefreshed zeros (becauseroot_view_slotat line 1046 only refreshes[address..shadow.end]) or stale/unrelated data at offset0.shadow.start + 0instead ofaddress, silently corrupting the start of the buffer (outside the declaredgpu_writes(list, address, ...)range) while leavingaddressuntouched.1 << 27dwords) raw-view cap inHostHeap::raw_view_atifaddressis more than 512 MiB into a large buffer.Live GPU reproduction (RTX 5090 & WARP,
VICTORY_D3D12_DEBUG=1)Dispatching a compute shader (
ByteAddressBuffer : register(t0, space1)->RWByteAddressBuffer : register(u1, space1), copying dword 0) withsrc[0x0] = 0xDEADBEEF,src[0x100] = 0xCAFEBABE, binding root SRV atsrc + 0x100and root UAV atdst + 0x200:main/VICTORY_ROOT_SRV_DIRECT=1):dst[0x0] = 0x00000000,dst[0x200] = 0xcafebabe(RTX 5090 & WARP).root_table(coldsrc[0]):dst[0x0] = 0x00000000,dst[0x200] = 0x00000000(reads unrefreshed zeros atsrc[0]; RTX 5090 & WARP).root_table(warmsrc[0]):dst[0x0] = 0xdeadbeef,dst[0x200] = 0x00000000(reads wrong data fromsrc[0]and writes it todst[0]instead ofdst[0x200]; RTX 5090 & WARP).Note that the new test assertion in
draw.rs:2784only checksstate.root_table(...) == heap_host.gpu(index)without actually dispatching a shader through the table at a non-zero offset.Suggested fix
root_tablecreate (and cache separately, keyed by(key, copy, offset, uav)or(key, address, uav)) a bounded raw view starting atfirst = offsetwithbytes = shadow.left(address) & !3(requiringoffsetto be 4-byte aligned, and passingshadow.mark_entry(address)tohost.set_markfor UAVs), rather than reusingroot_view_slot'sfirst = 0descriptor.root_tableon both a root SRV and a root UAV at non-zero offsets within their buffers, plus an out-of-bounds read pastshadow.left(address)returning0.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.