Shader tests: heap buffer views are raw, as the host makes them #2357

Closed
github-bot wants to merge 1 commit from gh-pr/2357/head into gh-pr/2357/base
Owner

@⁠LICObr on GitHub · 2026-11-25 11:35 UTC · original
LICObr:shader-tests/raw-heap-views → main · +5 −2 · 2 files · 1 commits · closed without merging

Addresses parts 2 and 3 of #1835, the test-fixture ones: on NVIDIA, stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride and synthetic_tests::gathers_at_a_level_match_the_hardware. Part 1 (HEAP_VIEWS past 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 the VIEW_STRIDES table, plus the offset, and issues a raw byte-address load (raw_view, kind 11). The offen reads 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) and Stride::Structured(16)).

A raw load through a structured view is outside what DXIL defines:

  • WARP and AMD read the byte address, so the tests pass there.
  • NVIDIA applies the view's stride on top and reads the wrong elements. #1835 shows [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

  • Both views are now Stride::Raw. The stride still comes from the table only (data: vec![4, 12]), so the stride test checks what it is named for.
  • No translator or host change.

Verification

  • cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: clean.
  • CI on my fork (Windows, the repo's workflow, on 940d32f): both clippy steps clean, cargo test --workspace --locked passes. Run
  • NVIDIA, verified by @⁠DrDarkDK (RTX 4070 Ti, driver 621.01, native Windows; comment): both tests fail on 940d32f and pass on dd25e37. That includes the full gather comparison and the lane-0 mismatch from part 3 of #1835.
**@⁠LICObr** on GitHub · 2026-11-25 11:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357) `LICObr:shader-tests/raw-heap-views` → `main` · +5 −2 · 2 files · 1 commits · closed without merging Addresses parts 2 and 3 of #1835, the test-fixture ones: on NVIDIA, `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride` and `synthetic_tests::gathers_at_a_level_match_the_hardware`. Part 1 (`HEAP_VIEWS` past 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 the `VIEW_STRIDES` table, plus the offset, and issues a **raw** byte-address load (`raw_view`, kind 11). The `offen` reads 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)` and `Stride::Structured(16)`). A raw load through a structured view is outside what DXIL defines: - WARP and AMD read the byte address, so the tests pass there. - NVIDIA applies the view's stride on top and reads the wrong elements. #1835 shows `[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](https://git.gtahub.st/github/Marvisak--VIctory/issues/1835)). ## Change - Both views are now `Stride::Raw`. The stride still comes from the table only (`data: vec![4, 12]`), so the stride test checks what it is named for. - No translator or host change. ## Verification - `cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`: clean. - CI on my fork (Windows, the repo's workflow, on `940d32f`): both clippy steps clean, `cargo test --workspace --locked` passes. [Run](https://github.com/LICObr/VIctory/actions/runs/45605351327) - **NVIDIA, verified by @⁠DrDarkDK** (RTX 4070 Ti, driver 621.01, native Windows; [comment](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2357)): both tests fail on `940d32f` and pass on `dd25e37`. That includes the full gather comparison and the lane-0 mismatch from part 3 of #1835.
The shader reads a heap buffer by element as the hardware does: element
times the view's stride (the host's table) plus the offset, as a raw
byte-address load. `a_heap_buffer_read_by_element_takes_the_views_stride`
and `gathers_at_a_level_match_the_hardware` bound a structured view
there instead (stride 12 and 16). A raw load through a structured view
is outside what DXIL defines: WARP and AMD read the byte address, NVIDIA
applies the view's stride on top and reads the wrong elements (#1835).

The host makes every heap buffer view raw (`descriptor/host.rs`), so the
tests now bind raw views, and check what runs in the game.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:03:20 +00:00
github-bot closed this pull request 2026-11-26 05:03:20 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 11:39 UTC · original

I ran the two affected synthetic tests on native Windows with an RTX 4070 Ti (621.01). Both failed on 940d32f and passed on dd25e37.

  • a_heap_buffer_read_by_element_takes_the_views_stride: the parent returned [101, 104, 107, ...]; the PR passed the expected 200..231 readback.
  • 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_srv preserves 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.

**@⁠DrDarkDK** on GitHub · 2026-11-25 11:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7161332562) I ran the two affected synthetic tests on native Windows with an RTX 4070 Ti (621.01). Both failed on `940d32f` and passed on `dd25e37`. - `a_heap_buffer_read_by_element_takes_the_views_stride`: the parent returned `[101, 104, 107, ...]`; the PR passed the expected `200..231` readback. - `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_srv` preserves 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](https://git.gtahub.st/github/Marvisak--VIctory/issues/1835). *AI-assisted with Codex.*
Author
Owner

@⁠LICObr on GitHub · 2026-11-25 11:44 UTC · original

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_srv keeps 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.

**@⁠LICObr** on GitHub · 2026-11-25 11:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7161441571) 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_srv` keeps 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.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 12:25 UTC · original

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::Structured yields a raw byte-address SRV, as victory-gpu binds title buffers, plus a test that pins StructureByteStride = 0 so a structured descriptor cannot come back.

The evidence behind it is in #2317: on the 5070 Ti the failure read 101 + 3·lane where the buffer's elements are 12 bytes — element 3·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_tests half 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 for image_gather4_l at 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.

**@⁠Calvix2k** on GitHub · 2026-11-25 12:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7162346034) 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::Structured` yields a raw byte-address SRV, as `victory-gpu` binds title buffers, plus a test that pins `StructureByteStride = 0` so a structured descriptor cannot come back. The evidence behind it is in #2317: on the 5070 Ti the failure read `101 + 3·lane` where the buffer's elements are 12 bytes — element `3·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_tests` half 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 for `image_gather4_l` at 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.
Author
Owner

@⁠qtLkz on GitHub · 2026-11-25 12:30 UTC · original

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 passes
  • stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride: now passes
  • stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros: still fails on this card, hardware: dispatch failed: invalid parameter at stride_tests.rs:347

Result: 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 #2317. #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).

**@⁠qtLkz** on GitHub · 2026-11-25 12:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7162465318) 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 passes - `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`: now passes - `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`: **still fails** on this card, `hardware: dispatch failed: invalid parameter` at `stride_tests.rs:347` Result: 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://git.gtahub.st/github/Marvisak--VIctory/issues/2317. #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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:33 UTC · original

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_RAW in descriptor/host.rs), so switching both fixtures to Stride::Raw matches 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 clears a_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

**@⁠Marvisak** on GitHub · 2026-11-25 15:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7167039243) <!-- victory-triage v1 head=dd25e37363dee6edf1a80df7d983872e14a67110 verdict=merge-candidate at=2026-11-25T15:40:00Z --> 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_RAW` in `descriptor/host.rs`), so switching both fixtures to `Stride::Raw` matches 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 clears `a_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](https://claude.ai/code)_
Author
Owner

@⁠Vedoxdev123 on GitHub · 2026-11-25 15:51 UTC · original

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 on main).

  • emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride now passes
  • emit::synthetic_tests::gathers_at_a_level_match_the_hardware now passes
  • Only 1 failure remains: emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros (hardware: dispatch failed: The parameter is incorrect.)
**@⁠Vedoxdev123** on GitHub · 2026-11-25 15:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7167375991) 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 on `main`). - `emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride` now **passes** - `emit::synthetic_tests::gathers_at_a_level_match_the_hardware` now **passes** - Only 1 failure remains: `emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` (`hardware: dispatch failed: The parameter is incorrect.`)
Author
Owner

@⁠fabianocoder on GitHub · 2026-11-25 16:14 UTC · original

Tested on NVIDIA GeForce RTX 3060 12 GB (driver 610.88, Windows 11).

cargo test -p victory-shader --lib --locked -- --test-threads=1

  • main (940d32f): 244 passed, 3 failed, 3 ignored
  • this PR (dd25e37): 246 passed, 1 failed, 3 ignored

Both a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware now 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 target

**@⁠fabianocoder** on GitHub · 2026-11-25 16:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7167722915) Tested on NVIDIA GeForce RTX 3060 12 GB (driver 610.88, Windows 11). `cargo test -p victory-shader --lib --locked -- --test-threads=1` - main (940d32f): 244 passed, 3 failed, 3 ignored - this PR (dd25e37): 246 passed, 1 failed, 3 ignored Both `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware` now 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 target
Author
Owner

@⁠alonso49noob on GitHub · 2026-11-25 17:43 UTC · original

First Blackwell run, and on the current head of main (13f91ca, 83 commits after the 940d32f used above): RTX 5060 8 GB, driver 621.01, Windows 11, Rust 1.98.1.

tree the two target tests cargo test -p victory-shader --lib
main 13f91ca both fail, same signatures as #1835: [101, 104, 107, …, 131, 0, …] and lane 0 [0, 1, 0, 0] aborts at the #2571 test
main + this PR (dd25e37) + #2587 (df8ee8e), local merge both pass, 3 of 3 270 passed, 1 failed, 3 ignored

This PR merges cleanly onto 13f91ca. #2587 is included only so the suite gets past the #2571 crash. The one failure left is a_heap_buffer_read_where_no_buffer_view_is_reads_zeros (stride_tests.rs:352), the HEAP_VIEWS cap from #1835 part 1, which this PR does not target.

Written with AI help (Claude Code); the numbers are from runs on my machine.

**@⁠alonso49noob** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7169902993) First Blackwell run, and on the current head of `main` (`13f91ca`, 83 commits after the `940d32f` used above): RTX 5060 8 GB, driver 621.01, Windows 11, Rust 1.98.1. | tree | the two target tests | `cargo test -p victory-shader --lib` | |---|---|---| | `main` `13f91ca` | both fail, same signatures as #1835: `[101, 104, 107, …, 131, 0, …]` and lane 0 `[0, 1, 0, 0]` | aborts at the #2571 test | | `main` + this PR (`dd25e37`) + #2587 (`df8ee8e`), local merge | **both pass, 3 of 3** | **270 passed, 1 failed**, 3 ignored | This PR merges cleanly onto `13f91ca`. #2587 is included only so the suite gets past the #2571 crash. The one failure left is `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` (`stride_tests.rs:352`), the `HEAP_VIEWS` cap from #1835 part 1, which this PR does not target. Written with AI help (Claude Code); the numbers are from runs on my machine.
Author
Owner

@⁠yumaste on GitHub · 2026-11-25 20:23 UTC · original

Verified on Windows 11 with an RTX 5080 Laptop GPU (driver 621.01).

Both targeted shader tests failed on 940d32f and passed with #2357 applied:

  • a_heap_buffer_read_by_element_takes_the_views_stride
  • gathers_at_a_level_match_the_hardware

I 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.

**@⁠yumaste** on GitHub · 2026-11-25 20:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7173588413) Verified on Windows 11 with an RTX 5080 Laptop GPU (driver 621.01). Both targeted shader tests failed on `940d32f` and passed with #2357 applied: - `a_heap_buffer_read_by_element_takes_the_views_stride` - `gathers_at_a_level_match_the_hardware` I 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:08 UTC · original

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 main does 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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2357#issuecomment-7175993642) 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 `main` does 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2357
No description provided.