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

Closed
Calvix2k wants to merge 1 commit from upstream-pr/2322 into main
Calvix2k commented 2026-11-25 10:39:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T10:39:53Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6602590523 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2322). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T10:39:53Z. --- 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.
DenRakEiw commented 2026-11-25 11:04:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T10:44:21Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • Confirmed on RTX 5090 that emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride now passes (fixing #2317)! (The remaining stride_tests failure on RTX 5090 is the separate pre-existing #1835 a_heap_buffer_read_where_no_buffer_view_is_reads_zeros.)
  • cargo test -p victory-shader stride_tests: 5/6 passed on RTX 5090 (target test passing), 6/6 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).

<!-- greyfinch-sync:Marvisak/VIctory:review:6056088381 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2322#pullrequestreview-6056088381). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T10:44:21Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 (Blackwell) and WARP: - Confirmed on RTX 5090 that `emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride` now passes (fixing `#2317`)! (The remaining `stride_tests` failure on RTX 5090 is the separate pre-existing `#1835` `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`.) - `cargo test -p victory-shader stride_tests`: 5/6 passed on RTX 5090 (target test passing), 6/6 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).
catminou4 commented 2026-11-25 11:04:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T10:53:59Z.

Review: APPROVED


Tested locally: merged into main 940d32f69b, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — test-only: structured view bound as the raw view the host takes.

<!-- greyfinch-sync:Marvisak/VIctory:review:6056241924 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2322#pullrequestreview-6056241924). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T10:53:59Z. **Review:** APPROVED --- Tested locally: merged into main 940d32f69b, `cargo test -p victory-shader --locked` on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — test-only: structured view bound as the raw view the host takes.
steven-seagull27 commented 2026-11-25 12:03:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-25T11:10:26Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160691511 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7160691511). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-25T11:10:26Z. --- 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://github.com/Marvisak/VIctory/pull/1887/commits/62bd980b02e54fb13ca114618a50ba1ed6d0c4cc)
welisonzika14-jpg commented 2026-11-25 12:03:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T11:37:55Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161296809 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7161296809). Originally posted by [welisonzika14-jpg](https://github.com/welisonzika14-jpg) on 2026-11-25T11:37:55Z. --- 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.
Marvisak commented 2026-11-25 16:09:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:17:59Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166621792 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7166621792). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:17:59Z. --- <!-- 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)_
Calvix2k commented 2026-11-25 16:09:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T16:08:31Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7167628961 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2322#issuecomment-7167628961). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T16:08:31Z. --- 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.
upstream-sync closed this pull request 2026-11-25 17:03:55 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2320
No description provided.