Repository navigation
Conversation
…nvalid views Authored and verified by Gemini 4 Neon (Extra High Mode) as an AI coding agent, strictly clean-room with zero game files or external dumps. Two constant-buffer binding issues in victory-gpu (also observed on world frames in Marvisak#1581): 1. Stale scratch tail in 256-byte CBV padding: HostList::scratch rounds allocations to 256 bytes and reuses its upload chunks across HostList::reset(), while table CBVs (State::tables) and unaligned root CBVs (root_view) only filled `size` / `len` bytes. On PC D3D12, CBV SizeInBytes is rounded up to a 256-byte multiple, so shader reads in `[size..padded)` observed stale bytes from previous draws or frames instead of zeros (RDNA2 hardware bounds-checks CBVs at exact byte size and returns 0 past the end). Extend Step::Fill with HostList::defer_fill_padded to zero `[len..padded)` immediately after the submission-time copy. 2. Invalid non-null SizeInBytes=0 CBVs and wrong null descriptor type: In State::tables, View::Constant(address, size) with `address == 0 || size == 0` (including the title's null CBV `View::Constant(0, 0)`) or an overflowing `size.checked_next_multiple_of(256)` previously allocated 256 bytes of scratch and called `constant_at` with a non-null scratch GPU VA and `SizeInBytes = 0` (invalid in D3D12), or fell back to `host.make_null` (a 2D texture SRV, which triggers wild-address reads on AMD and GBV mismatches). Add `HostHeap::make_null_constant` (calling `CreateConstantBufferView(None, ...)`) and guard `State::tables`, `HostHeap::constant_at`, and `descriptor::host::make` consistently. Verification (clean-room synthetic compute readback tests, zero game data): - NVIDIA GeForce RTX 3060 Ti (`cargo test -p victory-gpu --locked` and `--all-features --locked`: 53/53 & 56/56 passed) - NVIDIA GeForce RTX 3060 Ti with `VICTORY_D3D12_DEBUG=1` + `VICTORY_D3D12_GBV=1` (3/3 CBV tests passed) - Microsoft WARP (`VICTORY_D3D12_WARP=1`, 3/3 CBV tests passed) - `cargo clippy --workspace --all-targets --locked -- -D warnings` (default & `--all-features`) and `cargo xtask policy` passed. Refs Marvisak#1581.
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu/victory-hle/apps are Windows-only (D3D12/windows_sys), so nothing here compiles or runs on macOS — please rely on the Windows CI leg.
CBV creation is hardened: constant_at and the descriptor make path now use checked_next_multiple_of(256) (u32::MAX-sized CBVs no longer wrap to a small SizeInBytes), null/zero-sized buffers become real null CBVs (CreateConstantBufferView(None, ...)) that read zeros, and scratch padding is zeroed. The new test covers gpu+size=0, address=0 and the overflow case. This matches the D3D12 requirement that CBV SizeInBytes be a multiple of 256 and > 0 — the previous size.next_multiple_of(256) could panic in debug or wrap in release on overflow. Windows-only; looks correct statically.
|
Automated triage for the maintainers. Closing because this change is already in Built on HostHeap::constant_at and per-draw CBV scratch copies in tables, both gone from main (constant buffers are raw views of the title's slots; empty views are nulled by in_buffer). The FPS claim for zeroed padding is not credible. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
|
Automated triage for the maintainers. Needs rebase. This pull request conflicts with Generated by Claude Code |
…, D16S8/R16 UAV views, audit defects & Stage 2 device fixes - Placed texture Map()/Unmap() return va_ directly with xmem page disarm (LEONIDA_LINEAR_MAP_FIRST=1 opt-out) and pre-draw per-frame xs_refresh_placed_textures on first direct ExecuteCommandLists after PresentX (ubiquitarianism/leonida@545e8d51, five-star-recomp@38a8436, GPL-3.0). - Preserve xbox_d16s8 (118) view formats 118/119/120 in proxy SRV/DSV/placed-view paths; create depth16 UAV plane 0 as R16_TYPELESS and allow R16_UNORM (56) on R16_TYPELESS/118 depth UAVs. - Fix cc4553c review defects: lock-held arena_release_locked + had_retired retry in arena_allocate_reclaiming; slot 127 depth fallback unconditional clear/castable sanitization; view-flag-agnostic slot 62 copy lookup + richer skip diagnostics. - Force integer RT blendEnable=VK_FALSE (Marvisak/VIctory#2042, GPL-3.0); off-element placed structured buffer V# + PC RAW fallback (five-star-recomp@955a679, GPL-3.0); console typeless-on-typeless view fallback (Marvisak/VIctory#2190, GPL-3.0) + CBV ring tail zeroing (Marvisak/VIctory#1629, GPL-3.0); refuse MEM_MAPPED in create_host_buffer with LEONIDA_IMPORT_REMAPPABLE=1 opt-out (Neonbridge@838c433, GPL-3.0); AS SRV Location resolution (Marvisak/VIctory#2098, GPL-3.0); 3D R9G9B9E5 RT+UAV RGBA16F view format fix; true placed-texture upload totals telemetry + boot_bench parser.
…pty ones, at most 64 KiB - Table CBVs filled into the list's scratch or own memory (upload fill or GPU copy) zero the bytes from the title's size to the 256-byte end the host view takes, as the console reads zeros past a view's size; before, they read what earlier recordings left there. A CBV copy is reused only where its bytes past the asked length are zeros. - A constant view of no address or no bytes is a null CBV (dynamic slots: HostHeap::null_constant; title slots: `make` declines it, `null_for` makes a null CBV), not a 0-byte view, a null 2D SRV, or a fill from title address 0. create_cbv without a description records View::Constant(0, 0) instead of leaving the slot's old view. - Host CBVs take at most 64 KiB (constant_bytes, capped_constant): larger ones remove the device on NVIDIA (0x887A0001). Title sizes over 64 KiB are logged (counted, with the largest seen), and only 64 KiB is copied. Tests (WARP): draw::tests::table_cbvs_read_zeros_past_their_size, descriptor::tests::a_constant_view_without_a_description_is_a_null_one, descriptor::host::tests::constant_views_are_capped_at_64_kib_and_null_when_empty. Ported from Marvisak/VIctory#1629 (head 111b773) by ESAT586 Ported from Marvisak/VIctory#1640 (head b916a9c) by NuraadGit Ported from fxceless/victory-fork#911 (1087538) by douline
Summary
Fixes two constant-buffer upload/binding bugs in
victory-gpu(reported alongside world-frame testing in #1581, where zeroing CBV scratch padding produced a visible FPS increase on an RTX 4070):Zero
[size..padded)scratch padding for 256-byte-rounded CBVs (host.rs,draw.rs)HostList::scratch()rounds allocations up to 256 bytes and reuses upload chunks acrossHostList::reset().State::tables()(table CBVs) androot_view()(unaligned root CBVs) only filledsize/lenbytes withdefer_fill, leaving[size..padded)holding stale bytes from earlier draws or frames.D3D12_CONSTANT_BUFFER_VIEW_DESC::SizeInBytesup to a 256-byte multiple, shader loads pastsize(within the rounded 256-byte block) read stale scratch data instead of0as on console RDNA2 hardware.HostList::defer_fill_padded()(extendingStep::Fillwithpadded) so[len..padded)is zeroed immediately aftercopy_mappedat submission time, with zero overhead whenlenis already a 256-byte multiple.Bind a proper D3D12 null CBV for zero-address, zero-sized, overflowing, or OOM constant views (
draw.rs,descriptor/host.rs)View::Constant(0, 0)(andView::Constant(addr, 0)/View::Constant(0, size)) inState::tables()allocated 256 bytes of scratch and calledconstant_at(index, gpu, 0), producing an invalid D3D12 CBV with a non-nullBufferLocationandSizeInBytes = 0(and failingReadProcessMemoryonNULLfor(0, size)).list.scratch()failed,State::tables()also fell back tohost.make_null(index)(a 2D texture SRV null view) instead of a null CBV, risking AMD wild-address device removal (RX 9060 XT (RDNA4) | Host GPU device removed (DXGI_ERROR_DEVICE_HUNG) with page fault at 0x1a00b0000 in world #59) and GBV descriptor-type mismatches.HostHeap::make_null_constant(index)(CreateConstantBufferView(None, at)), guardedState::tables()andHostHeap::constant_at()withaddress != 0 && size != 0andsize.checked_next_multiple_of(256)(avoidingu32::next_multiple_ofoverflow panics), and applied the same zero-size / overflow guard indescriptor::host::make().descriptor.rsuntouched (no conflict with GPU: replace stale descriptors on null CBV writes #1298 / GPU descriptor: write null CBV when create_cbv description is null #1574) and leaves the empty-slotNone =>branch indraw.rsuntouched (no conflict with GPU: typed null descriptors for empty table slots, depth-UAV scratch stand-in, and packed 16-bit fallback #581).Changes
crates/victory-gpu/src/host.rs: extendStep::Fillwithpaddedand addHostList::defer_fill_paddedto zero trailing padding bytes at submission time.crates/victory-gpu/src/descriptor/host.rs: addHostHeap::make_null_constant, hardenHostHeap::constant_atandmake()against null-address / zero-sized / overflowing CBVs, and addzero_sized_and_overflowing_cbvs_become_null_views.crates/victory-gpu/src/draw.rs: usedefer_fill_padded+make_null_constantinState::tablesanddefer_fill_paddedin unalignedroot_view, and add end-to-end GPU compute readback teststable_cbv_zeroes_scratch_padding_and_binds_null_cbvs_on_gpuandunaligned_root_cbv_zeroes_scratch_padding_on_gpu.Verification
All tests are synthetic clean-room tests (no game data):
cargo test -p victory-gpu --locked): 53 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --all-features --locked): 56 passed, 0 failed, 1 ignoredVICTORY_D3D12_DEBUG=1 VICTORY_D3D12_GBV=1 cargo test -p victory-gpu --all-features --locked cbv): 3 passed, 0 failedVICTORY_D3D12_WARP=1 cargo test -p victory-gpu --all-features --locked cbv): 3 passed, 0 failedcargo clippy --workspace --all-targets --locked -- -D warnings, default &--all-features): 0 warningscargo xtask policy): 154 files okRefs #1581.