Skip to content

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

Open
Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/shader-test-structured-raw-2317
Open

Calvix2k wants to merge 1 commit into
Marvisak:mainfrom
Calvix2k:codex/shader-test-structured-raw-2317

Conversation

@Calvix2k

Copy link
Copy Markdown
Contributor

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 (Marvisak#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 DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: merged into main 940d32f, 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

Copy link
Copy Markdown

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

@welisonzika14-jpg

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants