Shader tests: bind a structured view as the raw view the host makes #2322

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

@⁠Calvix2k on GitHub · 2026-11-25 10:39 UTC · original
Calvix2k:codex/shader-test-structured-raw-2317 → main · +93 −40 · 1 files · 1 commits · closed without merging

Shader tests: bind a structured view as the raw view the host makes

The dispatch harness built a structured SRV (StructureByteStride) for
View::Buffer with Stride::Structured, while victory-gpu binds every
title buffer as a raw byte-address SRV and carries the element size in the
view-stride table; the lowered code multiplies by that stride itself
("Buffer views at computed heap indices"). A driver that honours the
descriptor's stride then scales the byte index a second time: on an
RTX 5070 Ti, a_heap_buffer_read_by_element_takes_the_views_stride read
element 3·lane+1 instead of lane (12-byte elements), which is index ×
stride/4, and ran off the buffer into zeros after element 31 (#2317). AMD
and WARP returned the byte address as written, which is why the test passes
on the card here.

Bind the raw view, as production does, and keep the typed arms unchanged.
The new test pins the raw descriptor so a structured one cannot come back.

249 passed, 3 ignored, clippy -D warnings clean on Windows 10 19045 /
RX 7800 XT with SM 6.6 through the Agility runtime for the test binaries.

**@⁠Calvix2k** on GitHub · 2026-11-25 10:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2322) `Calvix2k:codex/shader-test-structured-raw-2317` → `main` · +93 −40 · 1 files · 1 commits · closed without merging Shader tests: bind a structured view as the raw view the host makes The dispatch harness built a structured SRV (StructureByteStride) for `View::Buffer` with `Stride::Structured`, while `victory-gpu` binds every title buffer as a raw byte-address SRV and carries the element size in the view-stride table; the lowered code multiplies by that stride itself ("Buffer views at computed heap indices"). A driver that honours the descriptor's stride then scales the byte index a second time: on an RTX 5070 Ti, `a_heap_buffer_read_by_element_takes_the_views_stride` read element 3·lane+1 instead of lane (12-byte elements), which is index × stride/4, and ran off the buffer into zeros after element 31 (#2317). AMD and WARP returned the byte address as written, which is why the test passes on the card here. Bind the raw view, as production does, and keep the typed arms unchanged. The new test pins the raw descriptor so a structured one cannot come back. 249 passed, 3 ignored, clippy `-D warnings` clean on Windows 10 19045 / RX 7800 XT with SM 6.6 through the Agility runtime for the test binaries.
The dispatch harness built a structured SRV (StructureByteStride) for
`View::Buffer` with `Stride::Structured`, while `victory-gpu` binds every
title buffer as a raw byte-address SRV and carries the element size in the
view-stride table; the lowered code multiplies by that stride itself
("Buffer views at computed heap indices"). A driver that honours the
descriptor's stride then scales the byte index a second time: on an
RTX 5070 Ti, `a_heap_buffer_read_by_element_takes_the_views_stride` read
element 3·lane+1 instead of lane (12-byte elements), which is index ×
stride/4, and ran off the buffer into zeros after element 31 (#2317). AMD
and WARP returned the byte address as written, which is why the test passes
on the card here.

Bind the raw view, as production does, and keep the typed arms unchanged.
The new test pins the raw descriptor so a structured one cannot come back.

249 passed, 3 ignored, clippy `-D warnings` clean on Windows 10 19045 /
RX 7800 XT with SM 6.6 through the Agility runtime for the test binaries.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:14 +00:00
github-bot closed this pull request 2026-11-26 05:02:14 +00:00
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-25 11:10 UTC · original

Confirmed the translated shader fix on native Windows. I compared the parent 940d32f6 and this head 68470471 using the existing 12-byte element-stride test. Each cell below is the number of incorrect values in a completed 32-lane readback.

Adapter Parent This PR This PR with the native PC path split out
RTX 5080, driver 621.40 32/32 0/32 0/32
Built-in WARP, 10.0.26100.10068 0/32 0/32 0/32

On the RTX the first three lanes changed from 101, 104, 107 to the expected 200, 201, 202. Both new descriptor unit tests also passed.

One follow-up for the differential suite: translated_compute_matches_pc sends its original DXC-compiled HLSL through this same dispatch helper. I tested that path with an independent StructuredBuffer<uint4> shader reading the second word of 32 records. The parent returned all 32 expected values on both adapters. On this head, a check immediately before SRV creation found a raw view of 128 dwords with stride 0, where the shader declares 32 records with stride 16. The probe stopped there on each adapter, so there is no native readback for that cell.

I tried AlanQiang0418’s dispatch_pc split from #1887 on top of this head. Both adapters then returned 200…231 from the native shader and the translated test. Keeping that split would let this fix land without weakening the native reference that other shader PRs are compared against. These are synthetic Windows shader tests. Existing implementation in #1887

**@⁠steven-seagull27** on GitHub · 2026-11-25 11:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7160691511) Confirmed the translated shader fix on native Windows. I compared the parent `940d32f6` and this head `68470471` using the existing 12-byte element-stride test. Each cell below is the number of incorrect values in a completed 32-lane readback. | Adapter | Parent | This PR | This PR with the native PC path split out | |---|---:|---:|---:| | RTX 5080, driver 621.40 | 32/32 | 0/32 | 0/32 | | Built-in WARP, 10.0.26100.10068 | 0/32 | 0/32 | 0/32 | On the RTX the first three lanes changed from `101, 104, 107` to the expected `200, 201, 202`. Both new descriptor unit tests also passed. One follow-up for the differential suite: `translated_compute_matches_pc` sends its original DXC-compiled HLSL through this same `dispatch` helper. I tested that path with an independent `StructuredBuffer<uint4>` shader reading the second word of 32 records. The parent returned all 32 expected values on both adapters. On this head, a check immediately before SRV creation found a raw view of 128 dwords with stride 0, where the shader declares 32 records with stride 16. The probe stopped there on each adapter, so there is no native readback for that cell. I tried AlanQiang0418’s `dispatch_pc` split from #1887 on top of this head. Both adapters then returned `200…231` from the native shader **and** the translated test. Keeping that split would let this fix land without weakening the native reference that other shader PRs are compared against. These are synthetic Windows shader tests. [Existing implementation in #1887](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1887/commits/62bd980b02e54fb13ca114618a50ba1ed6d0c4cc)
Author
Owner

@⁠welisonzika14-jpg on GitHub · 2026-11-25 11:37 UTC · original

RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC. No game files, unit tests only. Head 6847047 merged onto main 940d32f, cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.

victory-shader
main 244 ok, 3 fail
this PR 248 ok, 1 fail

a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware pass on this card with it. The one left is a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, the view heap cap (#1744). victory-gpu is the same as main (141 ok, the 2 heap cap tests fail). No new failures.

This matches what I saw with the same test-host change by hand yesterday (in #1762). #2323 fixes only the gather test of the two, so the two overlap.

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

**@⁠welisonzika14-jpg** on GitHub · 2026-11-25 11:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7161296809) RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC. No game files, unit tests only. Head `6847047` merged onto `main` `940d32f`, `cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast`. | | `victory-shader` | |---|---| | `main` | 244 ok, 3 fail | | this PR | **248 ok, 1 fail** | `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware` pass on this card with it. The one left is `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, the view heap cap (#1744). `victory-gpu` is the same as `main` (141 ok, the 2 heap cap tests fail). No new failures. This matches what I saw with the same test-host change by hand yesterday (in #1762). #2323 fixes only the gather test of the two, so the two overlap. Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Author
Owner

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

Automated triage for the maintainers.

Needs work. The diagnosis is right: the translated code reads heap buffers by byte address, so a structured descriptor makes NVIDIA apply the stride twice (#2317). But buffer_view_desc in emit/host.rs changes Stride::Structured for every caller of Host::dispatch, including the native PC reference in diff_tests::translated_compute_matches_pc. That shader is compiled with DXC and declares StructuredBuffer<S> structured : register(t2); with this change it gets a raw SRV with stride 0. Binding a raw view to a structured declaration is undefined, so the reference other shader PRs are compared against becomes unreliable (a commenter here reports the same). Please either keep the structured descriptor for the PC-side dispatch (for example the dispatch_pc split from #1887), or change only the fixtures whose translated code reads raw; #2357 does the latter for both failing tests without touching the harness. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7166621792) <!-- victory-triage v1 head=684704712f5da53604736d2fea826e0779443099 verdict=needs-work at=2026-11-25T15:19:00Z --> Automated triage for the maintainers. **Needs work.** The diagnosis is right: the translated code reads heap buffers by byte address, so a structured descriptor makes NVIDIA apply the stride twice (#2317). But `buffer_view_desc` in `emit/host.rs` changes `Stride::Structured` for every caller of `Host::dispatch`, including the native PC reference in `diff_tests::translated_compute_matches_pc`. That shader is compiled with DXC and declares `StructuredBuffer<S> structured : register(t2)`; with this change it gets a raw SRV with stride 0. Binding a raw view to a structured declaration is undefined, so the reference other shader PRs are compared against becomes unreliable (a commenter here reports the same). Please either keep the structured descriptor for the PC-side dispatch (for example the `dispatch_pc` split from #1887), or change only the fixtures whose translated code reads raw; #2357 does the latter for both failing tests without touching the harness. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

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

Closing in favour of #2357, as the triage proposes: it fixes both failing tests by changing only the fixtures whose translated code reads raw, without binding a raw view to the StructuredBuffer the PC-side reference in diff_tests::translated_compute_matches_pc declares. That is the safer split, and it is green. The diagnosis here stands and #2357 carries it.

**@⁠Calvix2k** on GitHub · 2026-11-25 16:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7167628961) Closing in favour of #2357, as the triage proposes: it fixes both failing tests by changing only the fixtures whose translated code reads raw, without binding a raw view to the `StructuredBuffer` the PC-side reference in `diff_tests::translated_compute_matches_pc` declares. That is the safer split, and it is green. The diagnosis here stands and #2357 carries it.

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!2322
No description provided.