Shader tests: heap buffer views are raw, as the host makes them #2355
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2357"
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 LICObr on 2026-11-25T11:35:37Z.
Addresses parts 2 and 3 of #1835, the test-fixture ones: on NVIDIA,
stride_tests::a_heap_buffer_read_by_element_takes_the_views_strideandsynthetic_tests::gathers_at_a_level_match_the_hardware. Part 1 (HEAP_VIEWSpast NVIDIA's 1,000,000 cap) is a host design question with several open PRs and is not touched here.Problem
A heap buffer read by element has no used-resource entry, so the translator addresses it as the hardware does (
lower.rs, "A heap-indexed buffer read by element"). It computes element × the view's stride from theVIEW_STRIDEStable, plus the offset, and issues a raw byte-address load (raw_view, kind 11). Theoffenreads in the synthetic test take the same raw path.The host's own buffer views are raw:
R32_TYPELESS,StructureByteStride = 0,BUFFER_SRV_FLAG_RAW(descriptor/host.rs). The two tests bound a structured view there instead (Stride::Structured(12)andStride::Structured(16)).A raw load through a structured view is outside what DXIL defines:
[101, 104, 107, …, 131, 0, …]instead of[200, 201, …]: dwords 3, 12, 21, …, then out of bounds.So on NVIDIA the tests failed on the fixture, not on the translation.
Scope: this covers the raw fixtures only. A structured SRV the title creates keeps its stride when the host makes its view (
buffer_srv), and a raw load reaching such a view at runtime is the case still tracked in #1835 (comment).Change
Stride::Raw. The stride still comes from the table only (data: vec![4, 12]), so the stride test checks what it is named for.Verification
cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: clean.940d32f): both clippy steps clean,cargo test --workspace --lockedpasses. Run940d32fand pass ondd25e37. That includes the full gather comparison and the lane-0 mismatch from part 3 of #1835.Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:41:38Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:Stride::Rawfor heap buffer views fixesa_heap_buffer_read_by_element_takes_the_views_strideon RTX 5090 (note: overlaps in scope with#2322/#1887).cargo test -p victory-shader a_heap_buffer_read_by_element_takes_the_views_stride: 1/1 passed on RTX 5090, 1/1 passed on WARP.cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:56:17Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — test-only: heap buffer views raw, as the host makes them.Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T11:39:35Z.
I ran the two affected synthetic tests on native Windows with an RTX 4070 Ti (621.01). Both failed on
940d32fand passed ondd25e37.a_heap_buffer_read_by_element_takes_the_views_stride: the parent returned[101, 104, 107, ...]; the PR passed the expected200..231readback.gathers_at_a_level_match_the_hardware: the parent failed at lane 0 with[0, 1, 0, 0]versus[0, 0, 0, 0]. The raw fixture passed the full comparison, including lane 0.One scope clarification for the description:
buffer_srvpreserves an explicit structured SRV’s stride when it creates the host view. This verifies the raw fixtures. The runtime structured-view case is still tracked in #1835.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by LICObr on 2026-11-25T11:44:39Z.
Thanks for running it on real NVIDIA hardware, that's exactly the confirmation this needed. Good catch on the scope too: you're right that
buffer_srvkeeps a title-made structured SRV's stride, so "the host makes every heap buffer view raw" was too broad. I've updated the description to say this covers the raw fixtures only, with the runtime structured-view case still tracked in #1835, and added your results (including lane 0) under Verification.Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T12:25:09Z.
Part 2 of #1835 is already in flight: #2322 (
Shader tests: bind a structured view as the raw view the host makes) makes exactly that change —Stride::Structuredyields a raw byte-address SRV, asvictory-gpubinds title buffers, plus a test that pinsStructureByteStride = 0so a structured descriptor cannot come back.The evidence behind it is in #2317: on the 5070 Ti the failure read
101 + 3·lanewhere the buffer's elements are 12 bytes — element3·lane + 1, i.e.(12·lane + 4) × 12/4, the byte index the DXIL passes scaled by the descriptor's stride a second time. AMD and WARP take the byte index as written, which is why it passes everywhere else.So if #2322 lands first, the
stride_testshalf of this PR disappears in the rebase and only your part 3 remains:synthetic_tests::gathers_at_a_level_match_the_hardware— the RDNA2 rounding the test asserts (the comment in that file says the hardware rounds the exact product to 1/256 of a texel, half up, which WARP does not). That one is worth doing properly, and it is not a fixture question in the same sense: DXIL has no form forimage_gather4_lat a non-zero level, so the expectation has to come from somewhere. Comparing against the same gather at level 0 with pre-multiplied coordinates, or skipping the non-zero-level case with a comment naming the vendor difference, are both defensible; the second is smaller and honest.Not asking you to drop anything — just so neither of us is surprised when one of the two stride patches conflicts with the other. If yours is preferred for some reason, the test I add (
a_structured_test_view_is_bound_as_the_host_binds_it) is the only thing worth carrying over from mine.Imported from Marvisak/VIctory. Originally posted by qtLkz on 2026-11-25T12:30:24Z.
Tested on an RTX 4070 Ti (NVIDIA driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned), on top of main
940d32f,cargo test -p victory-shader --lib --locked --no-fail-fast:synthetic_tests::gathers_at_a_level_match_the_hardware: now passesstride_tests::a_heap_buffer_read_by_element_takes_the_views_stride: now passesstride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros: still fails on this card,hardware: dispatch failed: invalid parameteratstride_tests.rs:347Result: 246 passed, 1 failed, 3 ignored (on plain
940d32f: 244 passed, 3 failed).For comparison on the same machine, #2322 (which fixes the shared test harness instead of the individual tests) makes all three pass: 249 passed, 0 failed, 3 ignored, see https://github.com/Marvisak/VIctory/issues/2317#issuecomment-7162296847. #2323 also targets the gather test only. These three PRs cover the same NVIDIA false failures, so only one of them should land; on NVIDIA, #2322 is the only one that clears all three.
AI-assisted (Claude).
upstream-sync referenced this pull request2026-11-25 13:02:56 +00:00
upstream-sync referenced this pull request2026-11-25 13:03:06 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:33:57Z.
Automated triage for the maintainers.
Merge candidate (test fixture). Two synthetic tests bound a structured SRV for a buffer that the lowered code reads by byte address, using the stride from
VIEW_STRIDES(lower.rs, "A heap-indexed buffer read by element"). The host makes such views raw (R32_TYPELESS,StructureByteStride: 0,BUFFER_SRV_FLAG_RAWindescriptor/host.rs), so switching both fixtures toStride::Rawmatches the host, and the stride still comes from the table only, so the stride test still tests what it is named for. No translator or host code changes. A contributor confirmed both tests fail before and pass after on an RTX 4070 Ti. Overlap: #2322 does this in the harness instead (and is needs-work because it also changes the PC reference path); #2323 is the gather half alone. One NVIDIA run reports #2322 also clearsa_heap_buffer_read_where_no_buffer_view_is_reads_zeros, which still fails with this PR (the heap-cap issue, #1744). CI: passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Vedoxdev123 on 2026-11-25T15:51:36Z.
Tested on Windows with AMD Ryzen 5 5600X + NVIDIA GeForce RTX 4060:
cargo test -p victory-shader-> 246 passed; 1 failed; 3 ignored (down from 3 failures onmain).emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stridenow passesemit::synthetic_tests::gathers_at_a_level_match_the_hardwarenow passesemit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros(hardware: dispatch failed: The parameter is incorrect.)Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-25T16:28:31Z.
Review: CHANGES_REQUESTED
The fix is right, and it does what it says on Windows 10 too: Windows 10 Pro 22H2 (19045), RTX 3080 (617.42),
main+ #486,cargo test -p victory-shader --lib --locked -- --test-threads=1:victory-shaderdd25e37)a_heap_buffer_read_where_no_buffer_view_is_reads_zerosleft: the heap cap)One change before merging: the new comment in
stride_tests.rsstill saysYou agreed in this thread that this is too broad.
buffer_srv(crates/victory-gpu/src/descriptor/host.rs) passes the title's own description toCreateShaderResourceView, so a title's structured view stays structured. The PR description was updated, but this comment will outlive it. It also tells the next person looking atFIND-11(the runtime's structured views on NVIDIA) that the runtime case can't happen. Something like this would match what the code does:The
synthetic_tests.rscomment ("a raw view, as the host makes") has the same problem, though less strongly worded.Imported from Marvisak/VIctory. Originally posted by fabianocoder on 2026-11-25T16:14:59Z.
Tested on NVIDIA GeForce RTX 3060 12 GB (driver 610.88, Windows 11).
cargo test -p victory-shader --lib --locked -- --test-threads=1940d32f): 244 passed, 3 failed, 3 ignoreddd25e37): 246 passed, 1 failed, 3 ignoredBoth
a_heap_buffer_read_by_element_takes_the_views_strideandgathers_at_a_level_match_the_hardwarenow pass on hardware.The remaining failure is
a_heap_buffer_read_where_no_buffer_view_is_reads_zeros(E_INVALIDARG, the HEAP_VIEWS cap from #1835 part 1), which this PR doesn't targetImported from Marvisak/VIctory. Originally posted by alonso49noob on 2026-11-25T17:43:12Z.
First Blackwell run, and on the current head of
main(13f91ca, 83 commits after the940d32fused above): RTX 5060 8 GB, driver 621.01, Windows 11, Rust 1.98.1.cargo test -p victory-shader --libmain13f91ca[101, 104, 107, …, 131, 0, …]and lane 0[0, 1, 0, 0]main+ this PR (dd25e37) + #2587 (df8ee8e), local mergeThis PR merges cleanly onto
13f91ca. #2587 is included only so the suite gets past the #2571 crash. The one failure left isa_heap_buffer_read_where_no_buffer_view_is_reads_zeros(stride_tests.rs:352), theHEAP_VIEWScap from #1835 part 1, which this PR does not target.Written with AI help (Claude Code); the numbers are from runs on my machine.
Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-25T20:23:01Z.
Verified on Windows 11 with an RTX 5080 Laptop GPU (driver 621.01).
Both targeted shader tests failed on
940d32fand passed with #2357 applied:a_heap_buffer_read_by_element_takes_the_views_stridegathers_at_a_level_match_the_hardwareI used the same local adapter-selection change in both runs and confirmed in the D3D12 logs that the NVIDIA GPU was used. Both tests also passed on WARP with the fix applied.
Test automation and write-up assisted by Codex.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:08:46Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because the old fixtures are the faithful ones. The heap-indexed read gets its 12-byte stride from the view-stride table, which only a structured view gives, and the gather test's input is a table SRV with a used-resource stride; the runtime keeps such a view structured. Switching the fixtures to raw would make the tests describe a runtime
maindoes not have, and hide the NVIDIA defect they currently show (#1835). The fix belongs in the runtime: raw host views for buffers the translator reads raw, or structured handles in the translation.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed