GPU, Shaders: view structured buffers raw on host for NVIDIA heap reads (FIND-11) #2885
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!2885
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@jujumoneylol on GitHub · 2026-11-25 23:03 UTC · original
jujumoneylol:fix/find-11-raw-structured-buffers→main· +965 −100 · 11 files · 3 commits · openSummary
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.@fuzeofficlal on GitHub · 2026-11-25 23:10 UTC · original
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.
@alonso49noob on GitHub · 2026-11-26 00:52 UTC · original
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.
@steven-seagull27 on GitHub · 2026-11-26 03:51 UTC · original
@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.
@Marvisak on GitHub · 2026-11-26 04:27 UTC · original · edited 2026-11-26 07:23 UTC
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
@jujumoneylol on GitHub · 2026-11-26 06:42 UTC · original
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)@kotekompotek on GitHub · 2026-11-25 23:37 UTC · original · reviewed
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.
@fyernald on GitHub · 2026-11-26 02:21 UTC · original · approved these changes
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.@fyernald on GitHub · 2026-11-26 04:25 UTC · original · requested changes
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.
@jujumoneylol on GitHub · 2026-11-26 09:11 UTC · original
Pushed one small cleanup/fix ($sha):
@frenziedcoder on GitHub · 2026-11-26 09:13 UTC · original
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.
@Dukestar69 on GitHub · 2026-11-26 09:48 UTC · original · approved these changes
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).
@fuzeofficlal on GitHub · 2026-11-26 09:51 UTC · original · requested changes
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.@qtLkz on GitHub · 2026-11-26 10:07 UTC · original
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).
@steven-seagull27 on GitHub · 2026-11-26 10:49 UTC · original
@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.
@ThomasHFWright on GitHub · 2026-11-26 13:00 UTC · original
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.
@potatoe0100 on GitHub · 2026-11-26 14:40 UTC · original · reviewed
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.
@qtLkz on GitHub · 2026-11-26 15:21 UTC · original
@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).
@upipibi on GitHub · 2026-11-26 17:18 UTC · original · edited 2026-11-26 17:52 UTC
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).
@Jineggegg on GitHub · 2026-11-26 19:42 UTC · original
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
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.