fix(gpu): add CBV guards and typed buffer view validation #3339
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3339"
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 Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-26T19:03:50Z.
Summary
Adds CBV guards and typed buffer view validation in
victory-gpu(414d469), along with unit tests covering buffer view validation.Changes
Verification
cargo test -p victory-gpu --lib descriptorcargo clippy --locked -p victory-gpu --all-targets -- -D warningscargo xtask policyImported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T19:08:06Z.
Review: APPROVED
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).cargo test -p victory-gpu --lib descriptor:: -- --skip dynamic_slots_are_held_until_released --test-threads=1: 24 passed, 0 failed (includingcbv_sizes_are_capped_and_zero_sizes_use_the_zero_view,null_cbv_clears_a_stale_view,buffer_view_ranges_are_validated_before_creation, andtyped_buffer_views_use_bit_exact_host_formats).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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:24:25Z.
Review: APPROVED
Looks good. The CBV size clamping and zero-CBV handling (
crates/victory-gpu/src/descriptor.rs:575-595,crates/victory-gpu/src/descriptor/host.rs:1516-1538,1792-1821), overflow-checkedbuffer_view_range(descriptor/host.rs:1293-1305), cached CPU-heap null buffer descriptor copies (descriptor/host.rs:1823-1886), andmake_viewnull fallback (descriptor/host.rs:1502-1508) are all clean and well-structured.Verified merged onto
origin/main(63bcca43):cargo xtask policy(191 files ok) andcargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics) pass cleanly.--features diagnosticswithVICTORY_D3D12_DEBUG=1:descriptor::passes 25/25 on WARP and 24/24 on RTX 5090 (skipping the 1M-heap-capdynamic_slots_are_held_until_released);bindless::(3/3) anddraw::(20/20) also pass on both RTX 5090 and WARP.buffer_view_format's 32-bit integer-to-float remapping live across three adapters — RTX 5090, AMD Radeongfx1036iGPU, and WARP — with D3D12 Debug Layer + GPU-Based Validation (VICTORY_D3D12_GBV=1):Buffer<float4>->RWBuffer<float4>preserves subnormal integer bit patterns (0x0000_0001,0x0000_002A,0x007F_FFFF),-0.0(0x8000_0000), signaling NaN (0x7F80_0001), and0xFFFF_FFFFbit-for-bit across all three adapters with 0 Debug Layer / GBV messages.ClearUnorderedAccessViewUint,RWBuffer<uint>InterlockedAdd, andRWByteAddressBufferInterlockedAddon remappedR32_FLOAT/R32G32B32A32_FLOATUAVs all produce exact results with 0 Debug Layer / GBV messages.zero_constant,cached_null_buffer, andu64::MAXrange overflow paths execute cleanly with 0 Debug Layer / GBV messages.A few minor non-blocking follow-up notes:
buffer_view_format(descriptor/host.rs:1065) maps7 | 8(R32G32B32_UINT/SINT) to6(R32G32B32_FLOAT) for both SRVs and UAVs. While valid for SRVs, 96-bit formats cannot be used with typed UAVs (D3D12 reports an error and removes the device for bothR32G32B32_UINTonmainandR32G32B32_FLOAThere). Checkingtyped_storefor typed buffer UAVs inbuffer_uav— asfitsalready does for textures — would be a nice follow-up.buffer_view_range(descriptor/host.rs:1300),offset.is_multiple_of(element) && bytes.is_multiple_of(element)is always true afterchecked_muland can be simplified.Some(Some((buffer.clone(), None)))fromzero_constant(descriptor/host.rs:1820) causesdescribe_slot(diagnostics builds) to format zero CBVs as"Constant(0, 0)"rather than"null".Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:48:36Z.
Windows 11,
63bcca4+ this PR, Radeon RX 7900 XTX:cargo test -p victory-gpu --lib: 234 passed / 0 failed / 1 ignored (unpatched63bcca4here: 231; three new tests).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.The three new tests are
cbv_sizes_are_capped_and_zero_sizes_use_the_zero_view,typed_buffer_views_use_bit_exact_host_formatsandbuffer_view_ranges_are_validated_before_creation, and all three pass on this card. Synthetic only. AI-assisted.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.