victory-gpu: clamp constant buffer views to their registered buffer #1855
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!1855
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1855"
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?
@mgunes1311-lab on GitHub · 2026-11-24 23:29 UTC · original
mgunes1311-lab:gpu-constant-view-copies→main· +367 −31 · 4 files · 8 commits · openSummary
Since descriptor-table and heap
View::Constant(address, size)slots are backed in place by rawByteAddressBufferSRVs overShadowcopies, suballocated constant buffer descriptors that declare a 64 KiBSizeInBytesnear the end of a registered title buffer exposed four mismatches acrossvictory-gpu:descriptor::host::make):makecalledshadow::find(address, size)before clampingsizeto the registered buffer's remaining bytes. Wheneveraddress + sizeexceeded the buffer's end,shadow::findrejected the registered buffer and allocated a separate 4 MiBloosewindow for the host SRV whiledraw::readable(shadow::find(address, 1)) refreshed the registered buffer'sShadowcopy — leaving the SRV reading stale/zero bytes (missing both CPU writes and GPU UAV writes into the buffer's copy) and reading past the buffer's end instead of hardware bounds-checking to0.bindless::seen):bindless::seenlikewise looked upshadow::find(address, size)unclamped instead of resolving throughview_copy.view_addressesentries (descriptor::host::buffer_range):buffer_rangereturnedNoneforView::Constant, sowrite_address(HostHeap::view_addresses/note_address) wrote[0, 0]instead of the 48-bit title GPU address for constant buffer slots (anddescribe_slotomitted their address range).View::Constant(0, size)): Previously allocated a 4 MiBloosewindow at virtual address0x0instead of falling back tonull_buffer_view.Changes
crates/victory-gpu/src/shadow.rs: Addregistered_left(address)returning the remaining bytes in the innermost registered title buffer containingaddress(Nonefor loose memory).crates/victory-gpu/src/descriptor/host.rs: HandleView::Constantinbuffer_range(returningNoneat address0, clamping toregistered_left(address)when inside a registered buffer while leaving loose-memory constant views unclamped, and rounding down to whole dwords), resolveView::Constantinview_copyviashadow::for_view(..., 4), and build the raw SRV inmakefrombuffer_range(falling back tonull_buffer_viewwhen null or empty).crates/victory-gpu/src/bindless.rs&crates/victory-gpu/src/draw.rs: Route constant buffer view tracking and refreshes throughbuffer_rangeandview_copydirectly.descriptor::host::tests::constant_views_clamp_to_their_buffer_and_record_their_addressbindless::tests::overlong_constant_views_read_their_buffers_copy(multi-round D3D12 compute dispatch test coveringdefer_heap,view_copyrefresh, hardware out-of-bounds0reads past the clamped buffer end, and GPU UAV writes into the buffer's copy).Verification
cargo clippy --workspace --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings(default and--all-features)RUSTDOCFLAGS="-D warnings -A rustdoc::private-intra-doc-links" cargo doc --workspace --no-deps --target x86_64-pc-windows-msvc --lockedVICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --all-features --target x86_64-pc-windows-msvc --lockedcargo run -p xtask --target x86_64-pc-windows-msvc --locked -- policy --staged&cargo test -p xtask --target x86_64-pc-windows-msvc --locked@andrewpozdnakov7-jpg on GitHub · 2026-11-24 23:39 UTC · original
Independent WARP check at base
70564ae08cand headdca80ab6e0.I ran the GPU-write portion of the same fixture on both revisions, skipping the earlier host-side range assertions so the baseline reached the dispatch. With a 64 KiB CBV at offset 0xfc00, the base read the stale CPU value 0x00004000 at dword 0 after a UAV write of 0xdead0000. The head read back the expected 63 in-range words from that GPU write and zero out of range.
The unmodified PR head also passed both of its CBV regressions and the full victory-gpu suite on WARP (83 passed, 1 ignored).
@Marvisak on GitHub · 2026-11-25 07:25 UTC · original · edited 2026-11-25 22:22 UTC
Automated triage for the maintainers.
Needs rebase.
mainhas moved since the last triage, and this PR no longer merges cleanly into it (conflicts incrates/victory-gpu/src/descriptor/host.rsandcrates/victory-gpu/src/draw.rs). It will be reviewed again once it is rebased onto currentmain. The second-look comment above names the two test updates the rebase needs (theranges()tuple and the 16-byte view-address slots).Previous verdict for this head: merge candidate.
Generated by Claude Code
@Marvisak on GitHub · 2026-11-25 22:02 UTC · original
Automated triage for the maintainers, second look (a review against
main, with the PR built and tested).The mismatch is real (an overlong constant buffer view is made over one copy and read as another) and the fix is consistent. This can be merged once its tests are brought up to
main, where they no longer compile. Incrates/victory-gpu/src/bindless.rs,overlong_constant_views_read_their_buffers_copyshould destructure the items ofheap_host.viewed.ranges()as(s, a, len, uav, _). Incrates/victory-gpu/src/descriptor/host.rs,constant_views_clamp_to_their_buffer_and_record_their_addressshould read the view-address entry atdata + 16 * slot(mainwrites 16 bytes per slot now). With those two changes the tests pass. It also conflicts withmainindescriptor/host.rsanddraw.rsafter today's merges, so it needs a rebase.Push the change and it will be reviewed again. Thank you for the contribution.
@catminou4 on GitHub · 2026-11-24 23:47 UTC · original · reviewed
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Constant buffer views clamped to their registered buffer range: bounds fix in CBV creation — pairs with #1629's padding work; check overlap.
@mgunes1311-lab on GitHub · 2026-11-26 17:13 UTC · original
Merged
main(63bcca4) following the rebase notes above:draw.rs: preservedlen > 0andpage_range(address, len as usize)withdescriptor::view_copy(view)so zero-length clamped constant views skip page-range updates while valid clamped views reuse their registered buffer copy.descriptor/host.rs&bindless.rs: updatedconstant_views_clamp_to_their_buffer_and_record_their_addressfor 16-byte heap-keyed view-address entries and 5-tupleViewed::ranges().Verified
constant_views_clamp_to_their_buffer_and_record_their_address,overlong_constant_views_read_their_buffers_copy,view_addresses_cover_tables_made_afresh,clippy, andxtask policyon Windows 11 (x86_64-pc-windows-msvc).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.