Repository navigation
victory-gpu: clamp constant buffer views to their registered buffer - #1855
mgunes1311-lab wants to merge 5 commits into
Conversation
|
Independent WARP check at base 70564ae and head dca80ab. 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). |
catminou4
left a comment
There was a problem hiding this comment.
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.
|
Automated triage for the maintainers. Needs rebase. Previous verdict for this head: merge candidate. Generated by Claude Code |
|
Automated triage for the maintainers, second look (a review against 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 Push the change and it will be reviewed again. Thank you for the contribution. |
Summary
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