GPU, Shaders: view structured buffers raw on host for NVIDIA heap reads (FIND-11) #2883
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2885"
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 jujumoneylol on 2026-11-25T23:03:13Z.
Summary
Fixes FIND-11 (tracked in #1633 / #1744): NVIDIA GPUs misread heap-indexed structured buffers when a DXIL raw handle (
ByteAddressBuffer, resource kind11) indexes into a host D3D12 structured buffer descriptor (DXGI_FORMAT_UNKNOWN,StructureByteStride > 0).Root Cause
In DXIL,
annotateHandle(createHandleFromHeap(idx), ResourceProperties)requires a compile-time constant resource kind andStructStrideInBytes. Because heap-indexed buffers have runtime-variable strides (loaded fromVIEW_STRIDES),victory-shaderlowers heap-indexed buffer accesses through raw handles ((11 | u, 0)) and computesbyte = index * view_stride[idx] + offset.Previously,
victory-gpucreated host D3D12 structured views (StructureByteStride = S) for structured buffers. On NVIDIA hardware (verified on Turing GTX 1650, matching the RTX 5070 report in #1744),rawBufferLoad(raw_handle, byte_offset, undef)against a structured descriptor dividesbyte_offset / 4and uses that as the element index at inner offset 0 — reading[101, 104, 107, 110, ...]instead of[200, 201, 202, ...]for a 12-byte stride buffer withoffset:4.Changes
crates/victory-gpu/src/descriptor/host.rs:StructureByteStride > 0, 4-byte-multiple byte length fitting inu32dwords) as host raw views (DXGI_FORMAT_R32_TYPELESS,FirstElement = offset / 4,NumElements = total_bytes / 4,StructureByteStride = 0,D3D12_BUFFER_{SRV,UAV}_FLAG_RAW), respecting D3D12's 16-byte raw-view alignment (D3D12_RAW_UAV_SRV_BYTE_ALIGNMENTviashadow::for_view(..., 16)in bothbuffer_srv/buffer_uavandview_copy).VIEW_STRIDESviaview_stride().structured_buffer_views_stay_raw_on_host_and_keep_stride_tableverifying host view creation,VIEW_STRIDESpreservation, and zero D3D12 debug-layer errors.crates/victory-gpu/src/draw.rs:structured_views_off_their_buffers_elements_get_their_own_copyfor 16-byte raw-view alignment (2 * 456 = 912uses the buffer's copy;456(8 mod 16) and100(4 mod 16) get exact copies).crates/victory-shader/src/emit/lower.rs:(11 | u, 0)) with explicitbyte = index * stride + offsetso descriptor kinds match the raw host views across both table-bound and heap-indexed paths.getDimensions(Fields::BufferandFields::Smem) through raw handles ((11 | u, 0)) and divide the returned byte count bystride(UDiv) to recover the element record count.crates/victory-shader/src/emit/host.rs&diff_tests.rs:Stride::Structuredto create host raw SRVs matchingvictory-gpu, while addingStride::PcStructuredfor DXC-compiled PC reference shaders indiff_tests.crates/victory-shader/src/emit/stride_tests.rs:heap_indexed_structured_buffers_with_distinct_strides(multiple distinct strides in one heap on hardware + WARP).table_bound_structured_buffer_reads_by_element_and_dimensions(table-boundidxen+offset:4+num_recordsviagetDimensionson hardware + WARP).Verification (NVIDIA GeForce GTX 1650 + WARP, Windows 11)
mainf3578e3):emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_strideFAILED onhardware: got[101, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 0, ...]instead of[200..231].main842b0cb):emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride: PASS on bothhardware(GTX 1650) andwarp.emit::stride_tests::heap_indexed_structured_buffers_with_distinct_strides: PASS on bothhardwareandwarp.emit::stride_tests::table_bound_structured_buffer_reads_by_element_and_dimensions: PASS on bothhardwareandwarp.cargo test -p victory-shader --lib: 303 passed (only failure is the pre-existingFIND-9NVIDIA 1M view-heap cap testa_heap_buffer_read_where_no_buffer_view_is_reads_zeros).cargo test -p victory-gpu --lib: 227 passed including 20/20draw::testsandstructured_buffer_views_stay_raw_on_host_and_keep_stride_tablewithVICTORY_D3D12_DEBUG=1(only failures are the 2 pre-existingFIND-91M view-heap cap tests).cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: 0 warnings/errors.cargo check --workspace --all-targets: clean.cargo xtask policy: pass (asset policy: 191 files ok).Notes
FIND-11in #1633.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T23:37:09Z.
Review: COMMENTED
Correct raw-view rules: R32_TYPELESS + FLAG_RAW is the only legal representation, gated on byte-length divisibility and u32 element count, with the 16-byte FirstElement alignment pushed down into view_align so for_view reserves a conforming copy. Complements #2873's format legalization. LGTM.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:10:33Z.
Verified
41773eb8on Windows 11 (NVIDIA RTX 5090 Blackwell + WARP +dxil.dll) againstmain(842b0cb):Before / After on RTX 5090 (FIND-11 confirmed fixed!)
main(842b0cb):emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stridefails deterministically on RTX 5090 (returns[101, 104, 107, ...]instead of[200, 201, ...]).#2885(41773eb8):a_heap_buffer_read_by_element_takes_the_views_stride,heap_indexed_structured_buffers_with_distinct_strides, andtable_bound_structured_buffer_reads_by_element_and_dimensionsall pass on both RTX 5090 and WARP!stride_tests: 9/10 passed on RTX 5090 (only the pre-existing baseline failurea_heap_buffer_read_where_no_buffer_view_is_reads_zeros, which also fails withE_INVALIDARGon842b0cbon RTX 5090).Suite & Audit Notes
victory-shader:emit::lower::tests33/33,diff_tests5/5 passed;victory-gpu: RTX 5090descriptor::host::tests15/15 (includingstructured_buffer_views_stay_raw_on_host_and_keep_stride_table) &draw::tests20/20, WARPdraw::tests20/20 passed;cargo clippy(default &diagnostics) 0 warnings;cargo xtask policy(191 files ok;emit/lower.rs=521,447bytes,2,841bytes under 512 KiB).total_bytes % 4 != 0), the shader side still emits a raw handle (rare in practice since structured strides/totals are almost always 4-byte multiples); (2) touchesbuffer_srv/buffer_uavindescriptor/host.rsalongside#2873, so landing order will need a small merge resolution.Great fix for NVIDIA — looks ready to merge.
Imported from Marvisak/VIctory. Originally posted by alonso49noob on 2026-11-26T00:52:50Z.
RTX 5060 8 GB (Blackwell), driver 621.01, Windows 11, Rust 1.98.1. I compared
main63bcca4withmain+ this PR (41773eb), which merges cleanly. Each tree was built in its own target dir. The full shader runs skip the #2571 crash test.main63bcca4stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride(x3)[101, 104, 107, …]synthetic_tests::gathers_at_a_level_match_the_hardware(x3)[0, 1, 0, 0]stride_testscargo test -p victory-shader --libcargo test -p victory-gpu --libThe gather test is the other fixture named when #2357 was closed, and the reports above don't cover it. It passes here, and this PR doesn't change
synthetic_tests.rs. The failures left are theHEAP_VIEWScap ones, the same as onmain:a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views. I saw no new failures.Unrelated note:
descriptor::host::tests::views_bound_while_another_slot_gets_its_texture_do_not_waitfailed in 1 of 3 fullvictory-gpuruns onmain. It passed 6 of 6 alone and in every other full run on both trees, so it looks intermittent and not tied to this PR.Written with AI help (Claude Code); the numbers are from runs on my machine.
Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-26T02:21:28Z.
Review: APPROVED
Ampere data point: RTX 3080 (617.42), Windows 10 19045,
main63bcca4+ #486 (Agility runtime for the shader tests) + #2596 (#2571),--test-threads=1.victory-shader --libvictory-gpu --liba_heap_buffer_read_by_element_takes_the_views_strideandgathers_at_a_level_match_the_hardwarepass, along with the new stride tests andstructured_buffer_views_stay_raw_on_host_and_keep_stride_table. Nothing new fails.mainand with each other, and #2461 clears the heap-cap failures.pops_wait_loop_exits_immediately_for_inactive_lanes, which needs an SM 6.6 WARP that Windows 10 doesn't have.So on this card the two together leave no NVIDIA-specific failure.
One scope note: unlike the raw views in #2878, which only apply on NVIDIA, this views structured buffers raw on every host, and
getDimensionsdivides by the stride everywhere. The runs so far are NVIDIA and WARP, so a run on AMD hardware would close that.@alonso49noob: the intermittent
views_bound_while_another_slot_gets_its_texture_do_not_waitonmainis a race between tests over the sharedWHILE_PREPARINGhook from42ea09f. It's unrelated to this PR, and #2585 fixes it.Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T03:51:33Z.
@jujumoneylol I found a WARP regression when a shader writes through one structured view and another shader reads the same records through a view with a different starting offset. The NVIDIA fix for reading the untouched fields also showed up in this comparison.
842b0cb41773ebOn this PR, both adapters returned all 1,600 untouched fields and all 160 newly written values read through the writer's own origin. All 544 stale words were reads of a GPU-written field through a different origin. For example, a writer at byte 12 and a reader at byte 24 share 31 records. Reader lane 0 should see the
1stored by writer lane 1. It saw the initial0xa1700008. All 31 overlapping records were stale. The last, non-overlapping record kept its correct initial value.The fixture places 32-element views at byte offsets 0, 12, 24, 36 and 48 in a 432-byte write-watched title GPU buffer. Every access is inside its declared view. Each writer and reader runs in a separate fence-waited submission and schedules the same heap refresh that
draw::State::binduses. There are no intervening CPU writes. Your existing descriptor/stride test still passed on both adapters. The same normal-submit comparison measured 544/2,400 wrong on each adapter on the current #2178 head319749e. Related alignment and alias results on #2178For the alignment fallback, the acceptance case I would keep is that the later SRV sees all 31 overlapping writes across differently aligned origins. The test-only commit directly on this PR can be run in a separate checkout with:
Synthetic D3D12 readbacks on Windows. The game and AMD hardware remain untested here. AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-26T04:25:20Z.
Review: CHANGES_REQUESTED
Changing my earlier approval. @steven-seagull27's fixture (
8c474d5) reproduces exactly on the RTX 3080 (617.42) / Windows 10. Hardware adapter, with an Agility opt-in for the GPU test binary (Windows 10's WARP has no SM 6.6, so no WARP row here):main63bcca4+ fixture41773eb+ fixtureAll 18 failing reads on this PR are the GPU-written field read through a different origin, as they describe. The pattern also shows the cause. The five origins are bytes 0, 12, 24, 36 and 48. The two that are 16-byte aligned, 0 and 48, see each other's writes: writer 0 → reader 4 and writer 4 → reader 0 are both clean. Every pair involving an origin that isn't 16-byte aligned is stale (29-31 of 32).
That matches the fallback in this PR: a raw view whose start isn't 16-byte aligned gets "a copy of its own bytes", which
draw.rs's updated test now asserts for456= 8 mod 16. A write through one such copy never reaches another view of the same records. On hosts where structured views read correctly today (WARP: 0 wrong onmain, presumably AMD too), that's a regression.Two shapes that would keep one copy:
The fixture is a good acceptance test to carry into the PR. All 31 overlapping writes should be visible across differently aligned origins.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T04:27:10Z.
Automated triage for the maintainers.
Thanks for
e7250c5; both points are addressed. Indescriptor/host.rs,buffer_srv/buffer_uavnow view structured buffers raw from the preceding 16-byte boundary of the shared copy, with alignmentRAW_WORD_ALIGN. The 0-12-byte remainder goes intoVIEW_STRIDESbits 28-29, and the shader adds it back (view_raw_biasinemit/lower.rs), so overlapping views share one copy. The overlap fixture shows 0 of 2,400 words wrong on both adapters. Structured views that cannot be made raw are now refused instead of falling back to a structured descriptor.VIEW_STRIDE_BITSshrinks to 28 bits, which still leaves room for any real stride.Notes for the maintainer: every buffer handle now reads the stride table (a small per-access cost), and
lower.rsis about 1.5 KiB under the policy size cap. This replaces the approach in #2178 (open, global toggle, private copies), so only one should land.CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by jujumoneylol on 2026-11-26T06:42:48Z.
Thanks @steven-seagull27, @fyernald, and the triage review — pushed
e7250c5addressing both findings:1. Overlapping structured views now share one host copy (no private copies for 4-byte-aligned starts)
victory-gpu(descriptor/host.rs): Structured buffer SRVs/UAVs now use 4-byte alignment (RAW_WORD_ALIGN = 4) inshadow::for_viewandview_aligninstead of forcing 16-byte private copies. Whenshadow.offset(start)is 4-byte aligned (not 16-byte aligned),buffer_srv/buffer_uavroundFirstElementdown to the preceding 16-byte boundary (aligned = offset - bias,NumElements = (total_bytes + bias) / 4), adjustMARKtoshadow.mark_entry(start - bias), and store the0..12-byte start remainder inVIEW_STRIDESbits28..29(VIEW_RAW_OFFSET_SHIFT = 28, 2 bits for0..=3dwords;VIEW_STRIDE_BITS = (1 << 28) - 1).victory-shader(emit/shader.rs,emit/lower.rs): Record all buffer handles (kinds10..=12, SRV and UAV) inview_index, addview_raw_bias(h)((word >> 26) & 0xC) toraw_viewoffsets for heap-direct and table-bound structured buffers, and subtract it beforeUDivingetDimensionsso element counts remain exact.crates/victory-gpu/src/descriptor/overlap_test.rs) directly into the default test suite (skipping cleanly on hosts without SM 6.6).2. No native structured descriptor fallback behind raw shader handles
buffer_srvandbuffer_uavnow refuse structured views whose byte length is0, not a multiple of 4, not 4-byte aligned on the host copy, or whose raw dword count overflowsu32, rather than falling back to creating a native D3D12 structured descriptor. Covered instructured_buffer_views_stay_raw_on_host_and_keep_stride_table.Verification (
e7250c5, Windows 11,VICTORY_D3D12_DEBUG=1)overlap_test::gpu_writes_visible_through_overlapping_viewsstride_tests::table_bound_structured_buffer_reads_by_element_and_dimensions(bias=0&bias=12)stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride+heap_indexed_structured_buffers_with_distinct_stridesvictory-gpudescriptor::host::*+draw::tests(--test-threads=1)FIND-9dynamic_slots_are_held_until_released)FIND-9)victory-shader(stride_tests,diff_tests,lower::tests,waterfall_tests,synthetic_tests)FIND-9a_heap_buffer_read_where_no_buffer_view_is_reads_zeros)cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings(default &--all-features)cargo xtask policy192 files ok,lower.rs= 522,717 bytes)Imported from Marvisak/VIctory. Originally posted by jujumoneylol on 2026-11-26T09:11:59Z.
Pushed one small cleanup/fix (
767f228):Lower::view_raw_biasnow reuses theVIEW_STRIDESdword already loaded byLower::buffer_guard(guarded_stride) instead of reloadingVIEW_STRIDES[index]viaself.s.view_index.VIEW_STRIDES[null_buffer_view()]read whenbuffer_guardredirects a non-buffer slot to the null buffer view on a smallVIEW_STRIDEStable (caught when testing#2885stacked with#2461on GTX 1650 ina_heap_buffer_read_where_no_buffer_view_is_reads_zeros, which now passes cleanly).cargo xtask policy(lower.rs523,185 bytes < 512 KiB),cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings, andoverlap_test+ structured-buffer descriptor tests on GTX 1650 (VICTORY_D3D12_DEBUG=1).Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T09:48:26Z.
Review: APPROVED
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-shader --lib emit::stride_tests:: -- --test-threads=1: 9/10 passed on RTX 5090 — notablya_heap_buffer_read_by_element_takes_the_views_stridenow passes on RTX 5090 (fails on cleanorigin/main), along with both new tests (heap_indexed_structured_buffers_with_distinct_stridesandtable_bound_structured_buffer_reads_by_element_and_dimensions). The single remaining failure (a_heap_buffer_read_where_no_buffer_view_is_reads_zeros) reproduces identically on cleanorigin/main.cargo test -p victory-gpu --lib descriptor::host:: -- --test-threads=1 --skip dynamic_slots_are_held_until_released: 16/16 passed (includingoverlap_test::gpu_writes_visible_through_overlapping_viewsandstructured_buffer_views_stay_raw_on_host_and_keep_stride_table).cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Great NVIDIA fix (FIND-11): viewing structured buffers raw on the host makes heap-indexed structured buffer reads work cleanly on RTX 5090.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T09:51:08Z.
Review: CHANGES_REQUESTED
The raw-view +
VIEW_STRIDES0..12-byte bias approach works cleanly on NVIDIA hardware — verified locally on Windows 11 with an RTX 5090 and WARP (git merge-treeagainst63bcca43clean,cargo clippy --workspace --all-targets [--all-features] -- -D warningsclean,cargo xtask policy192 files ok):descriptor::host::overlap_test::gpu_writes_visible_through_overlapping_views: passed (0/2400 mismatches) on RTX 5090, RTX 5090 +VICTORY_D3D12_DEBUG=1, and WARP +VICTORY_D3D12_DEBUG=1structured_buffer_views_stay_raw_on_host_and_keep_stride_tableandstructured_views_off_their_buffers_elements_get_their_own_copy: passed on RTX 5090, RTX 5090 Debug, and WARP Debugvictory-shaderstride_tests::+diff_tests::+waterfall_tests::: 19/20 passed on RTX 5090 + WARP (including both new structured-buffer tests; the lonea_heap_buffer_read_where_no_buffer_view_is_reads_zerosfailure reproduces identically onorigin/main63bcca43due to NVIDIA's 1M heap cap inemit::host).Two correctness bugs should be fixed before merge:
1. Out-of-bounds
VIEW_STRIDESroot-SRV read and silently droppedraw_biasfor dynamic-slot tables (crates/victory-gpu/src/descriptor/host.rs:129-143, 511-519)Before this PR, table-bound structured buffers used native structured handles
(12 | u, stride)and did not readVIEW_STRIDES. Now every table-bound structured buffer (u.stride >= 4) loadsVIEW_STRIDES[index]viaview_raw_bias(h)->view_word(index)(lower.rs:1808-1815, 4646-4652) using the unclamped heap slotindexfromentry_heap_index/heap_index.However,
HostHeap::newallocatesself.stridesfor onlycount.max(HEAP_VIEWS)dwords (host.rs:130), andwrite_stridedrops any write withindex >= self.count.max(HEAP_VIEWS)(host.rs:513). On uncapped heaps wherecount + extra > count.max(HEAP_VIEWS)(e.g. a title heap withcount = 1_245_184+DYNAMIC = 262_144, orcount = 900_000+262_144 > HEAP_VIEWS), any fresh descriptor table placed in dynamic slots atindex >= count.max(HEAP_VIEWS)has itsraw_biaswrite silently dropped and causes the shader to read past the end of theVIEW_STRIDESroot SRV (no hardware bounds check — garbage bias or GPU page fault / device removal).Allocating
strides(andmarkssymmetrically at lines 135 & 531) after(heap, count, extra)is resolved with(count + extra).max(views)entries, and checkingindex >= (self.count + self.dynamic).max(HEAP_VIEWS)inwrite_stride/set_mark, fixes this cleanly.2.
ClearUnorderedAccessViewUint/Floaton a biased (bias = 4/8/12) structured UAV clobbers4..12preceding bytes in the shared host copy (descriptor/host.rs:1393-1415,draw.rs:1056-1085)buffer_uavroundsFirstElementdown bybias = offset & 15(aligned = offset - bias) and setsNumElements = (total_bytes + bias) / 4, relying on translated shaders to skip the leadingbiasbytes viaVIEW_STRIDES.draw.rs::clear_unorderedinvokesClearUnorderedAccessViewUint/Floatdirectly on that biased raw host UAV without shader execution (and with unshiftedrects). Whenbias > 0, D3D12 clears[aligned, aligned + raw_count * 4), overwriting the4..12bytes immediately precedingstartinside the sharedShadowbuffer — bytes outsidebuffer_range(&view)thatreadabledid not even snapshot.For
bias > 0structured UAVs,clear_unorderedneeds to restrict the clear to[bias / 4 .. raw_count)(via shifted/clampedD3D12_RECTs on the raw buffer UAV, or an exact 16-byte-aligned clear path) so preceding neighbor bytes in the shared copy are never overwritten.3. Minor:
getDimensions(num_records) withidxen == falseon a table-bound structured buffer (crates/victory-shader/src/emit/lower.rs:4442-4455)When a table-bound buffer with
used.stride >= 4is accessed viabuffer_loadwithidxen == false(div_stride == None,!is_heap_direct), line 4445 skips subtractingview_raw_bias(h), returningtotal_bytes + biasinstead oftotal_bytes. Including|| used.is_some_and(|u| u.stride >= 4)in that condition handles it consistently.Imported from Marvisak/VIctory. Originally posted by frenziedcoder on 2026-11-26T09:13:31Z.
RTX 5080 (Blackwell), driver 621.40, title runs: with this PR in place of #2464 in the NVIDIA stack, the interior shots draw a character that #2464's tree draws as broken spikes, with no other change in what translates and no device removal in 600 s. For the choice between this PR and #2464 the triage mentions, measured in the title rather than synthetically.
Trees:
main842b0cb+ #1906, #2098, #2626, #2628, #2176 (fb99078), #2118 + the localwave32_approxchange and BVH-builder hold-back from #2176's thread, and then either #2464 (b9dc4b0) or this PR (e7250c5; #2464 reverted cleanly, this PR merged cleanly). Diag build,VICTORY_D3D12_DRED=1, scriptedEnter, 600 s, one run each.translate --cache)The translation counts are identical, so the difference is in how the views are made. My guess is the unaligned structured origins this PR copies to aligned ones and #2464 leaves structured (steven-seagull27's 12/24/36-byte case), but I haven't traced which buffer the character reads.
Synthetic, same tree:
emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stridepasses (it fails onmainon this card);a_heap_buffer_read_where_no_buffer_view_is_reads_zerosstill fails withdispatch failed: The parameter is incorrect, as onmain(the view-heap cap of #1835).victory-gpuoverlaptests: 2 passed.Not tested:
767f228(pushed after these runs; theview_raw_biasstride-reuse cleanup); more than one run per tree; this PR without the rest of the stack; AMD.AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title on my machine (sandboxed at Low integrity, game folder read-only), read the logs and frame captures, and wrote this report.
Imported from Marvisak/VIctory. Originally posted by qtLkz on 2026-11-26T10:03:46Z.
Tested on NVIDIA Ada (the description has Turing): RTX 4070 Ti, driver 621.01, Windows 11 Pro 26300, Rust 1.98.1, this PR (
767f228) on main63bcca4, together with #2596 / #2683 / #2633 (clean merges), fixtures untouched.cargo test -p victory-shader --lib --locked -- --test-threads=1: 313 passed, 0 failed, including the two that fail on NVIDIA on main because of raw reads through structured views:stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride ... ok(on main:left: [101, 104, 107, ...],right: [200, 201, ...], the stride applied twice)synthetic_tests::gathers_at_a_level_match_the_hardware ... okvictory-gpu: 233 passed, 0 failed. Full workspace green. Details in #2317.
AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by qtLkz on 2026-11-26T10:07:04Z.
Tested on NVIDIA Ada (the description has Turing): RTX 4070 Ti, driver 621.01, Windows 11 Pro 26300, Rust 1.98.1, this PR (
767f228) on main63bcca4, together with #2596 / #2683 / #2633 (clean merges), fixtures untouched.cargo test -p victory-shader --lib --locked -- --test-threads=1: 313 passed, 0 failed, including the two that fail on NVIDIA on main because of raw reads through structured views:stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride ... ok(on main:left: [101, 104, 107, ...],right: [200, 201, ...], the stride applied twice)synthetic_tests::gathers_at_a_level_match_the_hardware ... okvictory-gpu: 233 passed, 0 failed. Full workspace green. Details in #2317.
AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T10:49:09Z.
@jujumoneylol @fuzeofficlal I reproduced the structured UAV clear in review item 2 on native Windows. Both the RTX 5080 and inbox WARP gave the following results in two fresh runs per adapter and revision.
767f22822f19d9Each case starts with 32 distinct guard words in one allocated buffer. A six-record view with a 12-byte stride starts at a 0, 4, 8, or 12-byte bias. The test clears either the whole view or the relative word rectangle
[2,6), with both Uint and Float. On the PR head the whole clear changed exactly one, two, or three preceding words at the respective nonzero biases. The title copy hid those changes because it only copied the logical view back. At bias 12, the rectangle was shifted three words toward the start of the buffer, giving six wrong GPU words.The fix uses an exact
R32_UINTview with zero structure stride and no RAW flag for the biased native clear, and copies that CPU descriptor into the shader-visible slot. The clear itself produced no D3D12 InfoQueue warnings or errors on either adapter, measured after heap setup through execution. Four existing overlap, structured-view and clear-slot tests also passed on each. This covers the clear item. The stride-table andgetDimensionsreview items remain separate.The commit applies directly to
767f228. Fork commit · Downloadable patchAI-assisted patch and tests, run locally.
Imported from Marvisak/VIctory. Originally posted by ThomasHFWright on 2026-11-26T13:00:50Z.
Proton data point for
767f228. I ported the shared raw-view approach to LinVxtory’s PR995-based renderer and tested it on CachyOS with an RTX 5090 (NVIDIA 620.73.04) and GE-Proton 11-14.ClearUnorderedAccessViewcall, so this run adds no coverage for the upstream clear issue.Source-only faces-hair branch · Reproduction notes and results
AI-assisted port and validation. The measurements are from my machine.
Imported from Marvisak/VIctory. Originally posted by potatoe0100 on 2026-11-26T14:40:49Z.
Review: COMMENTED
RTX 4060 8 GB (Ada), driver 621.14, Windows 11 Pro 26300.
--test-threads=1, skipping onlyheap_direct_texture_reads_mark_their_heap_index(#2571).With #2461:
main63bcca4+ this PR (767f228) + #2461 (6544a52). The only conflict is thepub use shader::{...}list inemit/mod.rs: keep both sides and dropNULL_BUFFER_VIEW. Results:victory-gpu --lib234 passed, 0 failed, andvictory-shader --lib303 passed, 0 failed.mainfails 5 on this card, so the two PRs together clear every NVIDIA unit-test failure here.Clear item (review 2): I ran @steven-seagull27's fixture from
22f19d9against this head. 12 of 16 cases are wrong, with 36 wrong words in the shared GPU buffer and 22 in the title copy. That matches the RTX 5080 numbers exactly. With22f19d9cherry-picked on top, all 16 cases are correct with 0 and 0 wrong words, and the full suites still pass (235 / 303, 0 failed). Folding22f19d9in would close that item.Item 1 of the same review (out-of-bounds
VIEW_STRIDESread): this doesn't look reachable to me.Shader::heap_handleclamps the index toHEAP_VIEWS - 1before it stores it inview_index, andview_raw_bias/view_wordread through that clamped index. The stride table hascount.max(HEAP_VIEWS)entries, so the read stays inside it. Dynamic slots at or pastHEAP_VIEWSonly exist whencount > HEAP_VIEWS - DYNAMIC(1,835,008), and the retail heap is 1,245,184. Shaders onmaincan't address those slots either, because of the same clamp. So I don't think it should block this PR.AI-assisted (Claude). Unit tests only, no game data.
Imported from Marvisak/VIctory. Originally posted by qtLkz on 2026-11-26T15:21:37Z.
@steven-seagull27 @jujumoneylol I reproduced the structured UAV clear result for
22f19d9on NVIDIA Ada. Setup: RTX 4070 Ti, driver 621.01, Windows 11 Pro 26300, Rust 1.98.1. Both trees were built from the PR alone, without the rest of the NVIDIA stack.structured_clears_preserve_neighbor_words_in_the_shared_buffer(--features diagnostics,VICTORY_D3D12_DEBUG=1, one run per adapter and tree):767f228+ test file only767f228+ test file only767f228+22f19d9767f228+22f19d9The per-case counts on the PR head match yours exactly. Whole-view clears overwrite 1, 2 and 3 GPU words at biases 4, 8 and 12, and the title copy does not show them. The
[2,6)rectangle gives 2, 4 and 6 wrong GPU words. Bias 0 is clean on every case.Full suites (
cargo test -p <crate> --lib --locked -- --test-threads=1):767f228767f228+22f19d9The same three tests fail on both trees, and all three come from the NVIDIA 1M view-heap cap (FIND-9, addressed by #2683), not from this PR:
emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros:dispatch failed: The parameter is incorrectdescriptor::host::tests::dynamic_slots_are_held_until_released:NumDescriptors >= HEAP_VIEWSmemory::tests::lists_share_a_table_and_copies_keep_their_views:past the dynamic slotsemit::memory_tests::heap_direct_texture_reads_mark_their_heap_indexwas skipped on both trees, because it crashes the NVIDIA driver and stops the shader run (#2571, fixed by #2596/#2587).22f19d9introduces no new failures on Ada.AI-assisted (Claude).
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-26T17:18:09Z.
NVIDIA Ampere check of
767f228: RTX 3070 8 GB, driver 616.56, Windows 11, rustc 1.100.0, hardware adapter.main63bcca4as control, each tree in its own target dir,--locked -- --test-threads=1. Synthetic tests only.63bcca4767f228emit::stride_tests::gathers_at_a_level_match_the_hardware, 3 runs[0,1,0,0], want[0,0,0,0])descriptor::host::, 3 runsoverlap_test::gpu_writes_visible_through_overlapping_viewspasses 3/3victory-shader --lib(skipping the #2571 test)victory-gpu --libmain,a_heap_buffer_read_by_element_takes_the_views_stridereads[101,104,…,131,0,…]where[200..231]is wanted. It passes with the PR.a_heap_buffer_read_where_no_buffer_view_is_reads_zeros. On the PR it fails with "dispatch failed: The parameter is incorrect" (stride_tests.rs:533). Searched: the test name in VIctory issues and PRs. It is the null-buffer read on a capped heap from #1835; #3235, #1943 and #2177 propose fixes.dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views(theHEAP_VIEWScap; tracked in #1744 and #3178).22f19d9, not in this PR).AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from Marvisak/VIctory. Originally posted by Jineggegg on 2026-11-26T19:42:54Z.
jujumoneylol, item 3 of the review above (the size of a table-bound structured buffer read without
idxen) reproduces on767f228, on an RTX 5090 and on WARP.3214c40on top of767f228fixes it and extends the existing test. It changes one condition inemit/lower.rsand the test inemit/stride_tests.rs, and applies with or without22f19d9.What happens. For a table-bound buffer the program declares with a structured stride,
raw_viewadds the raw start bias when the handle is heap-direct orused.stride >= 4. The size read subtracted it only when the count is divided by the stride (div_stride, anidxenaccess) or the handle is heap-direct. A program that reads the same view by byte (offen) gets the view's size plus the bias: 396 instead of 384 bytes for 32 records of 12 bytes that start 12 bytes past a 16-byte boundary. The commit uses the loads' condition.div_strideis onlySomewhenused.stride >= 4, so theidxencase is unchanged.Test.
table_bound_structured_buffer_reads_by_element_and_dimensionsalso runs the same program withbuffer_load_dword v2, v1, s[8:11], 0 offen offset:4in place of theidxenload, at bias 0 and 12, and expects the 32 dwords after the view's start, with32 * 12in lane 31.cargo test -p victory-shader --lib --locked emit::stride_tests::table_bound_structured_buffer_reads_by_element_and_dimensions:VICTORY_WARP=1767f228+ the test change onlybias-12, by byte: lane 31 is 396, expected 384VICTORY_WARP=1the first pass also runs on WARP but is labelledhardware)767f228+ the commitcargo test --workspace --locked --no-fail-fast, once on the RTX 5090 (skippingheap_direct_texture_reads_mark_their_heap_index, which ends the shader test process on NVIDIA, #2571) and once withVICTORY_WARP=1 VICTORY_D3D12_WARP=1. In that second runvictory-shaderruns on WARP.victory-gpustill runs on the RTX 5090, because its WARP switch only exists indiagnosticsbuilds.VICTORY_WARP=1767f228On the RTX 5090 the three failures are the view-heap cap tests (
a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views).767f228fails the same three, as do the Ada runs above. WithVICTORY_WARP=1both trees fail the same six: the twovictory-gpucap tests, plus four shader tests (gathers_at_a_level_match_the_hardware(#3267), the twopermutes_*tests,a_mask_joined_with_data_at_a_uniform_loop_is_its_number). Clippy, default and--all-features(as inci.yml): clean.cargo xtask policy: 192 files ok.Item 1 (stride table size). I agree with potatoe0100 that it can't be reached.
Shader::heap_handleclamps every index belowHEAP_VIEWS, and table-bound buffer handles go through it too (guarded_heap_handle). The stride and mark tables havecount.max(HEAP_VIEWS)entries. Writes are only dropped for dynamic slots at or pastcount.max(HEAP_VIEWS), which no shader can address, so they don't change what shaders read. The same holds with #2121's paged heap, which caps title slots so that title and dynamic slots stay below the null buffer views. I didn't find a fixture that observes a difference, so the commit doesn't change it.RTX 5090, driver 621.14, Windows 11 build 26300, in-box WARP 10.0.26100.9818,
dxil.dll1.9.2609.5, Rust 1.98.1.Synthetic tests only, no game data. AI-assisted (Claude Code); the runs are from my machine.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by jujumoneylol on 2026-11-27T00:59:17Z.
Folded both reviewer fixes onto
fix/find-11-raw-structured-buffers(preserving authorship):4ea6a86(from @steven-seagull27's22f19d9): addresses review item 2 from @fuzeofficlal — nativeClearUnorderedAccessViewUint/Floaton biased (4/8/12-byte) structured UAVs now uses an exactR32_UINTnon-RAW view so preceding neighbor words in the shared buffer are untouched and clear rects stay aligned (structured_clears_preserve_neighbor_words_in_the_shared_buffer).76a13e1(from @Jineggegg's3214c40): addresses review item 3 from @fuzeofficlal —getDimensions(num_records) on a table-bound structured buffer read by byte (offen) now subtractsview_raw_biasunder the sameis_heap_direct || used.stride >= 4condition as loads, with the byte-read test cases added totable_bound_structured_buffer_reads_by_element_and_dimensions.VIEW_STRIDESbounds on dynamic slots): as @potatoe0100 and @Jineggegg verified,Shader::heap_handleclamps every index belowHEAP_VIEWSwhilestridesis sized tocount.max(HEAP_VIEWS), so the OOB read is not reachable.Re-verified on Windows 11 / GTX 1650 + WARP (
VICTORY_D3D12_DEBUG=1):cargo xtask policy: 193 files okcargo clippy -p victory-shader -p victory-gpu --all-targets(default &--all-features,-D warnings): cleanvictory-shaderstride_tests(heap-indexed, element & byte table-bound dimensions at bias 0 and 12): 3/3 passed (GTX 1650 + WARP)victory-gpu --features diagnosticsoverlap_test+structured_clears_preserve_neighbor_words_in_the_shared_buffer: 2/2 passed on GTX 1650 (WARP=0) and 2/2 passed on WARP (WARP=1).Thanks @fuzeofficlal, @steven-seagull27, @Jineggegg, and @potatoe0100 for the catches and fixes!
Imported from Marvisak/VIctory. Originally posted by potatoe0100 on 2026-11-27T03:08:21Z.
Retest of
76a13e1on NVIDIA RTX 4060, driver 621.14, Windows 11.cargo test -p victory-gpu -p victory-shader --lib --locked -- --test-threads=1, skipping onlyheap_direct_texture_reads_mark_their_heap_index(#2571).victory-gpu232 passed, 2 failed;victory-shader302 passed, 1 failed. All three are the known view-heap cap failures (#1835):dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsanda_heap_buffer_read_where_no_buffer_view_is_reads_zeros.main63bcca4+ this head + #2461 (6544a52), with the sameemit/mod.rsimport conflict as before: 235 passed, 0 failed and 303 passed, 0 failed.767f228is fixed:structured_clears_preserve_neighbor_words_in_the_shared_bufferpasses. The new byte-read cases intable_bound_structured_buffer_reads_by_element_and_dimensionsandgpu_writes_visible_through_overlapping_viewsalso pass.Unit tests only, no game data.
AI-assisted (Claude)
Imported from Marvisak/VIctory. Originally posted by neonbyte1 on 2026-11-28T05:25:17Z.
In-game confirmation on Linux to go with @DieQuelle's Windows result above: RTX 5090 (driver 620.73.04), GE-Proton11-14 Wine with its vkd3d-proton, merged onto our integration tree (
mainplus ~320 open PRs). vkd3d-proton doesn't misread the structured-view divisors, so there's nothing to speed up here; the point was cost and correctness: one clean A/B pair, 420 s, yard: 188.8 vs 195.9 ms/frame (no cost), pictures equal (0.4-0.5 % of pixels differ by more than 32/255).One thing for the PR itself: this PR's own device test
structured_clearfails on its head76a13e1under vkd3d-proton: withbias=0 float=truethe clear leaves the buffer untouched.ClearUnorderedAccessViewFloatof a rawR32_TYPELESSUAV is a no-op there. On our tree a clear's private view is typed instead (R32_FLOATfor a float clear,R32_UINTotherwise, no bias; views in slots stay raw), and the test passes:515f232. It doesn't cherry-pick onto your head as is (our base movedbuffer_uav), but it's ~30 lines indescriptor/host.rs; happy to rebase it onto your branch if you want it.AI-assisted (Claude); measured on my machine, no game data shared.
Imported from Marvisak/VIctory. Originally posted by artor410 on 2026-11-28T08:19:14Z.
NVIDIA Ampere check of
76a13e1, merged cleanly ontomain63bcca4(tree03528ae). RTX 3070 Ti 8 GB (Ampere, 32-lane waves, heap capped at 1,000,000), driver 610.88, Windows 11, rustc 1.98.1, hardware adapter. Synthetic tests only.stride_tests+gathers_at_a_levela_heap_buffer_read_where_no_buffer_view_is_reads_zeros(it fails on main and on #2178 and #2464 too)overlap_test::gpu_writes_visible_through_overlapping_viewsI ran the same overlap test on #2178 (544 mismatches) and #2464 (1425 mismatches). This is the only one of the three that passes it. Side by side in #1744.
(Claude Code, Claude Opus 5.5.)
Imported from Marvisak/VIctory. Originally posted by hxpeerr on 2026-11-28T21:01:41Z.
In-game head-to-head with #2464 on a Blackwell card (RTX 5060 Ti, driver 621.40), each alone on
main: https://github.com/Marvisak/VIctory/pull/2464#issuecomment-7245718270View 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.