Shader tests: the test host's structured buffer views are raw (#1835) #1887

Closed
github-bot wants to merge 4 commits from gh-pr/1887/head into gh-pr/1887/base
Owner

@⁠carlos-seiffert on GitHub · 2026-11-25 00:04 UTC · original
carlos-seiffert:fix/test-host-structured-views-are-raw → main · +63 −10 · 3 files · 4 commits · closed without merging

Test-host part of #1835: a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware fail on NVIDIA. The heap cap failure there is #1779's. This PR does not fix the runtime; see "What stays open".

Cause

The test host's Stride::Structured made a structured SRV (DXGI_FORMAT_UNKNOWN with a StructureByteStride), and the translated shader reads it with a byte-addressed load, taking the element size from the stride table. WARP ignores the view's stride for that load; NVIDIA applies it a second time, so the hardware run reads the wrong elements ([101, 104, 107, ...]).

Change (test-only, crates/victory-shader/src/emit)

  • Stride::Structured makes a raw view for translated shaders, the form the runtime's raw_view_at/raw_pair_at use.
  • dispatch_pc binds the declared structured view for the original PC bytecode in diff_tests::translated_compute_matches_pc (commit by @⁠AlanQiang0418).
  • New Stride::StructuredDesc makes the structured view as the runtime makes it today from a title's structured descriptor (descriptor::host::buffer_srv keeps StructureByteStride). The by-element read runs through both. The new a_heap_buffer_read_by_element_through_the_runtimes_structured_view passes on WARP and fails on NVIDIA hardware until the runtime makes such views raw, so the raw test host does not hide that bug.

What stays open

The runtime still hands NVIDIA structured views for title buffers read by translated byte-addressed loads. #2178 makes those views raw in buffer_srv/buffer_uav. StructuredDesc reproduces the runtime's view inside the test host, so it does not go green when the runtime is fixed: it describes the runtime only until then. If #2178 lands, the StructuredDesc test should go with it, and I'll drop it here on rebase.

On the RTX 2060 the two are complementary: #2178 alone leaves gathers_at_a_level_match_the_hardware failing, and #2178 + #1887 passes it (numbers on #2178).

Results

RTX 2060 6 GB (Turing), driver 621.40, Windows 11 26300, on main ccfb029, cargo test -p victory-shader -- --test-threads=1 (hardware, then WARP):

result
main (measured at 70564ae and d763582) #1835's three fail
this PR 245 passed, 2 failed: the heap cap (#1779) and the new structured-view test (the runtime bug, hardware only)
this PR, VICTORY_WARP=1 both by-element tests pass

cargo clippy -p victory-shader --all-targets is clean. translated_compute_matches_pc skips here (no console compiler); its native PC path was checked by @⁠AlanQiang0418 on an RTX 5080.

🤖 Generated with Claude Code

**@⁠carlos-seiffert** on GitHub · 2026-11-25 00:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887) `carlos-seiffert:fix/test-host-structured-views-are-raw` → `main` · +63 −10 · 3 files · 4 commits · closed without merging Test-host part of #1835: `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware` fail on NVIDIA. The heap cap failure there is #1779's. This PR does **not** fix the runtime; see "What stays open". ### Cause The test host's `Stride::Structured` made a structured SRV (`DXGI_FORMAT_UNKNOWN` with a `StructureByteStride`), and the translated shader reads it with a byte-addressed load, taking the element size from the stride table. WARP ignores the view's stride for that load; NVIDIA applies it a second time, so the hardware run reads the wrong elements (`[101, 104, 107, ...]`). ### Change (test-only, `crates/victory-shader/src/emit`) - `Stride::Structured` makes a raw view for translated shaders, the form the runtime's `raw_view_at`/`raw_pair_at` use. - `dispatch_pc` binds the declared structured view for the original PC bytecode in `diff_tests::translated_compute_matches_pc` (commit by @⁠AlanQiang0418). - New `Stride::StructuredDesc` makes the structured view **as the runtime makes it today** from a title's structured descriptor (`descriptor::host::buffer_srv` keeps `StructureByteStride`). The by-element read runs through both. The new `a_heap_buffer_read_by_element_through_the_runtimes_structured_view` passes on WARP and **fails on NVIDIA hardware** until the runtime makes such views raw, so the raw test host does not hide that bug. ### What stays open The runtime still hands NVIDIA structured views for title buffers read by translated byte-addressed loads. #2178 makes those views raw in `buffer_srv`/`buffer_uav`. `StructuredDesc` reproduces the runtime's view inside the test host, so it does not go green when the runtime is fixed: it describes the runtime only until then. If #2178 lands, the `StructuredDesc` test should go with it, and I'll drop it here on rebase. On the RTX 2060 the two are complementary: #2178 alone leaves `gathers_at_a_level_match_the_hardware` failing, and #2178 + #1887 passes it (numbers on #2178). ### Results RTX 2060 6 GB (Turing), driver 621.40, Windows 11 26300, on `main` `ccfb029`, `cargo test -p victory-shader -- --test-threads=1` (hardware, then WARP): | | result | |---|---| | `main` (measured at `70564ae` and `d763582`) | #1835's three fail | | this PR | 245 passed, 2 failed: the heap cap (#1779) and the new structured-view test (the runtime bug, hardware only) | | this PR, `VICTORY_WARP=1` | both by-element tests pass | `cargo clippy -p victory-shader --all-targets` is clean. `translated_compute_matches_pc` skips here (no console compiler); its native PC path was checked by @⁠AlanQiang0418 on an RTX 5080. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`Stride::Structured` made a structured SRV (`DXGI_FORMAT_UNKNOWN` with a
`StructureByteStride`), while the GPU host makes every buffer view it hands
a translated shader raw (`victory-gpu`, `descriptor::host`: R32_TYPELESS,
stride 0, `D3D12_BUFFER_SRV_FLAG_RAW`). The element size reaches the shader
through the stride table, and the translated read is a byte-addressed load
of the view. WARP ignores the view's stride for that load; NVIDIA applies it
a second time, so `a_heap_buffer_read_by_element_takes_the_views_stride` and
`gathers_at_a_level_match_the_hardware` read the wrong elements on the
hardware device. The test host now makes the same raw view as the GPU host.

On an RTX 2060 (Turing, driver 621.40), `cargo test -p victory-shader` goes
from 206 passed / 3 failed to 208 / 1; the one left is the 1,000,000-view
heap cap (#1779 fixes it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The runtime does not make every buffer view raw: `buffer_srv` in
`victory-gpu`'s `descriptor::host` keeps a title's structured descriptor,
`StructureByteStride` included. With the test host's views raw, nothing
would still read through such a view, so the NVIDIA failure the runtime
has today would be hidden.

`Stride::StructuredDesc` makes the structured view as the runtime does,
whoever reads it, and the by-element read now runs through both. Through
the structured view it passes on WARP and fails on NVIDIA hardware (on an
RTX 2060: [101, 104, 107, ...]) until the runtime makes such views raw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:41 +00:00
github-bot closed this pull request 2026-11-26 04:47:41 +00:00
Author
Owner

@⁠Mericas77 on GitHub · 2026-11-25 00:23 UTC · original

Tested bb5acba on an NVIDIA host: RTX 4070 12 GB, driver 621.01, Windows 11 (build 26300), debug build, base 70564ae.

cargo test -p victory-shader --locked --no-fail-fast 70564ae this PR this PR + #1762
result 206 passed, 3 failed 208 passed, 1 failed 208 passed, 1 failed

With this PR, a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware pass on this card. The gather test fails on main for the same reason as the stride test: it reads its input records (offset, u, v, level) from a Stride::Structured(16) buffer, so on NVIDIA the gather runs on the wrong coordinates. The remaining failure is a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, which comes from the view heap cap (#1779).

One caveat about the premise: "the GPU host makes them raw" is not true at 70564ae. buffer_srv/buffer_uav in victory-gpu/src/descriptor/host.rs pass the title's structured desc (DXGI_FORMAT_UNKNOWN + StructureByteStride) through unchanged, and only #1762 makes them raw. On this card, #1762's raw_reads_of_structured_views_are_right fails against main's runtime (wrong data from dword 16 on) and passes with #1762.

So merged alone, this PR would turn these two tests green on NVIDIA while the runtime still reads structured views wrong in-game. I'd suggest landing it with #1762 or after it. The two merge cleanly, and with both applied the results are as above.

**@⁠Mericas77** on GitHub · 2026-11-25 00:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887#issuecomment-7148455923) Tested `bb5acba` on an NVIDIA host: RTX 4070 12 GB, driver 621.01, Windows 11 (build 26300), debug build, base `70564ae`. | `cargo test -p victory-shader --locked --no-fail-fast` | `70564ae` | this PR | this PR + #1762 | |---|---|---|---| | result | 206 passed, 3 failed | 208 passed, 1 failed | 208 passed, 1 failed | With this PR, `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware` pass on this card. The gather test fails on `main` for the same reason as the stride test: it reads its input records (offset, u, v, level) from a `Stride::Structured(16)` buffer, so on NVIDIA the gather runs on the wrong coordinates. The remaining failure is `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, which comes from the view heap cap (#1779). One caveat about the premise: "the GPU host makes them raw" is not true at `70564ae`. `buffer_srv`/`buffer_uav` in `victory-gpu/src/descriptor/host.rs` pass the title's structured desc (`DXGI_FORMAT_UNKNOWN` + `StructureByteStride`) through unchanged, and only #1762 makes them raw. On this card, #1762's `raw_reads_of_structured_views_are_right` fails against `main`'s runtime (wrong data from dword 16 on) and passes with #1762. So merged alone, this PR would turn these two tests green on NVIDIA while the runtime still reads structured views wrong in-game. I'd suggest landing it with #1762 or after it. The two merge cleanly, and with both applied the results are as above.
Author
Owner

@⁠AlanQiang0418 on GitHub · 2026-11-25 00:27 UTC · original

The translated gather and indexed-buffer tests both pass on my RTX 5080 with this change. There is a separate caller that needs the original structured SRV: translated_compute_matches_pc also dispatches native PC bytecode, and that HLSL declares StructuredBuffer<S> at t2.

I compiled the existing “sizes from descriptors” and “sizes for scalar loads” cases with PC DXC and checked each lane's four output words against the CPU expectation on driver 621.14. I kept the HLSL, input bytes, constants and dispatch dimensions fixed.

Native PC input at t2 RTX 5080 mismatching lanes (each case) Microsoft WARP (each case)
Raw SRV as created at bb5acba 256/256 0/256
Structured SRV, 8 elements × 16 bytes 0/256 0/256

For example, word 2 of “sizes from descriptors” on RTX was 0xC0 with the raw view and the expected 0x78 with the structured view.

Follow-up commit for this PR keeps your raw view for translated shaders and binds a real structured descriptor for the original PC reference dispatch. The legacy gather, indexed read, and shader all-targets Clippy pass with the follow-up. I ran the two native PC cases independently; the full console-versus-PC suite skipped locally because the console compiler is unavailable.

**@⁠AlanQiang0418** on GitHub · 2026-11-25 00:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887#issuecomment-7148537247) The translated gather and indexed-buffer tests both pass on my RTX 5080 with this change. There is a separate caller that needs the original structured SRV: `translated_compute_matches_pc` also dispatches native PC bytecode, and that HLSL declares `StructuredBuffer<S>` at t2. I compiled the existing “sizes from descriptors” and “sizes for scalar loads” cases with PC DXC and checked each lane's four output words against the CPU expectation on driver 621.14. I kept the HLSL, input bytes, constants and dispatch dimensions fixed. | Native PC input at t2 | RTX 5080 mismatching lanes (each case) | Microsoft WARP (each case) | | --- | ---: | ---: | | Raw SRV as created at `bb5acba` | 256/256 | 0/256 | | Structured SRV, 8 elements × 16 bytes | 0/256 | 0/256 | For example, word 2 of “sizes from descriptors” on RTX was `0xC0` with the raw view and the expected `0x78` with the structured view. [Follow-up commit for this PR](https://github.com/AlanQiang0418/VIctory/commit/a55b9328d542ea9b84d1067217ce484b348459c5) keeps your raw view for translated shaders and binds a real structured descriptor for the original PC reference dispatch. The legacy gather, indexed read, and shader all-targets Clippy pass with the follow-up. I ran the two native PC cases independently; the full console-versus-PC suite skipped locally because the console compiler is unavailable.
Author
Owner

@⁠carlos-seiffert on GitHub · 2026-11-25 00:59 UTC · original

Thanks @⁠Mericas77 for the RTX 4070 run, and @⁠AlanQiang0418 for catching the native PC reference and for the fix. I've taken your commit as is (9ae875d, authorship kept): translated shaders keep the raw view, and dispatch_pc binds the declared structured view for the original PC bytecode. The other native PC dispatch in diff_tests (cube_gradients_pick_the_level) binds no buffer views, so it needs nothing.

Re-run on the RTX 2060 (driver 621.40) with both commits: cargo test -p victory-shader -- --test-threads=1 is still 208 passed, 1 failed (the heap cap, #1779), and cargo clippy -p victory-shader --all-targets is clean. Here too translated_compute_matches_pc skips internally (no console compiler), so its native PC path is covered only by your run.

🤖 Generated with Claude Code

**@⁠carlos-seiffert** on GitHub · 2026-11-25 00:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887#issuecomment-7149101494) Thanks @⁠Mericas77 for the RTX 4070 run, and @⁠AlanQiang0418 for catching the native PC reference and for the fix. I've taken your commit as is (9ae875d, authorship kept): translated shaders keep the raw view, and `dispatch_pc` binds the declared structured view for the original PC bytecode. The other native PC dispatch in `diff_tests` (`cube_gradients_pick_the_level`) binds no buffer views, so it needs nothing. Re-run on the RTX 2060 (driver 621.40) with both commits: `cargo test -p victory-shader -- --test-threads=1` is still 208 passed, 1 failed (the heap cap, #1779), and `cargo clippy -p victory-shader --all-targets` is clean. Here too `translated_compute_matches_pc` skips internally (no console compiler), so its native PC path is covered only by your run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:19 UTC · original · edited 2026-11-25 11:21 UTC

Automated triage for the maintainers.

Merge candidate. This is a test-only change in crates/victory-shader/src/emit. In host.rs (dispatch_with_views), Stride::Structured now makes a raw view for translated shaders. dispatch_pc keeps the declared structured view for the original PC bytecode in diff_tests::translated_compute_matches_pc. The new Stride::StructuredDesc builds a view the way descriptor::host::buffer_srv in victory-gpu does today, keeping StructureByteStride.

On your reply: this takes the second route from the previous review. The corrected description no longer claims that the runtime makes every view raw. a_heap_buffer_read_by_element_through_the_runtimes_structured_view runs the same read as a_heap_buffer_read_by_element_takes_the_views_stride through the runtime's current structured view, so the raw test host no longer hides #1835.

One thing for the maintainer to know: that new test is expected to fail on NVIDIA hardware, and it will keep failing after the runtime is fixed, because it builds its own view. It should be removed when #2178 (open) or another runtime fix lands, as the description says. CI: passing (check).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887#issuecomment-7156892675) · edited 2026-11-25 11:21 UTC <!-- victory-triage v1 head=0172e6bae21bed0c7fea7006d4b23966b2a8686c verdict=merge-candidate at=2026-11-25T11:21:46Z --> Automated triage for the maintainers. **Merge candidate.** This is a test-only change in `crates/victory-shader/src/emit`. In `host.rs` (`dispatch_with_views`), `Stride::Structured` now makes a raw view for translated shaders. `dispatch_pc` keeps the declared structured view for the original PC bytecode in `diff_tests::translated_compute_matches_pc`. The new `Stride::StructuredDesc` builds a view the way `descriptor::host::buffer_srv` in `victory-gpu` does today, keeping `StructureByteStride`. On your reply: this takes the second route from the previous review. The corrected description no longer claims that the runtime makes every view raw. `a_heap_buffer_read_by_element_through_the_runtimes_structured_view` runs the same read as `a_heap_buffer_read_by_element_takes_the_views_stride` through the runtime's current structured view, so the raw test host no longer hides #1835. One thing for the maintainer to know: that new test is expected to fail on NVIDIA hardware, and it will keep failing after the runtime is fixed, because it builds its own view. It should be removed when #2178 (open) or another runtime fix lands, as the description says. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠carlos-seiffert on GitHub · 2026-11-25 09:39 UTC · original

The triage is right: I wrote that the runtime makes every buffer view raw, and buffer_srv does not. Since #1762 is closed, I took the second route: 5f3cb18 adds Stride::StructuredDesc, a structured view as buffer_srv makes it today, and runs the by-element read through it as well. On the RTX 2060 that test fails on hardware with the same [101, 104, 107, ...] and passes on WARP, so the raw test host no longer hides the runtime bug. The description is corrected and says what stays open.

🤖 Generated with Claude Code

**@⁠carlos-seiffert** on GitHub · 2026-11-25 09:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887#issuecomment-7158624016) The triage is right: I wrote that the runtime makes every buffer view raw, and `buffer_srv` does not. Since #1762 is closed, I took the second route: 5f3cb18 adds `Stride::StructuredDesc`, a structured view as `buffer_srv` makes it today, and runs the by-element read through it as well. On the RTX 2060 that test fails on hardware with the same `[101, 104, 107, ...]` and passes on WARP, so the raw test host no longer hides the runtime bug. The description is corrected and says what stays open. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

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

I added a Windows-SDK-only regression for the native PC path in AlanQiang0418’s dispatch_pc fix. It compiles a small StructuredBuffer<uint4> compute shader and reads the second word of 32 distinct records through Stride::Structured(16). It runs with VICTORY_CONSOLE_DXC unset, so contributors can exercise the native reference on a machine where the full translated-versus-PC comparison skips. The commit is based directly on 0172e6b. Regression test, 57c170f

Windows adapter Shader-reported count and stride Values read back
RTX 5080, driver 621.40 32 records, 16 bytes 32/32 correct, 200…231
Built-in WARP, 10.0.26100.10068 32 records, 16 bytes 32/32 correct, 200…231

I also checked the assertions in local controls on both adapters. Appending a 33rd valid record failed the count check. Changing only record 17’s second word from 217 to 317 failed the payload check. The committed test uses the original 32 records.

To pick it onto this branch:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr1887-native-structured-reference
git cherry-pick 57c170fd324747a480d3b11631fea32052c4680d

To reproduce with the Windows SDK’s dxc.exe installed:

$env:VICTORY_WARP = '0'
cargo test -p victory-shader --lib --locked native_pc_reads_structured_records -- --nocapture
$env:VICTORY_WARP = '1'
cargo test -p victory-shader --lib --locked native_pc_reads_structured_records -- --nocapture

A completed device run prints native PC readback matched 32 records with a 16-byte stride.

**@⁠steven-seagull27** on GitHub · 2026-11-25 12:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887#issuecomment-7162804429) I added a Windows-SDK-only regression for the native PC path in AlanQiang0418’s `dispatch_pc` fix. It compiles a small `StructuredBuffer<uint4>` compute shader and reads the second word of 32 distinct records through `Stride::Structured(16)`. It runs with `VICTORY_CONSOLE_DXC` unset, so contributors can exercise the native reference on a machine where the full translated-versus-PC comparison skips. The commit is based directly on `0172e6b`. [Regression test, `57c170f`](https://github.com/steven-seagull27/VIctory/commit/57c170fd324747a480d3b11631fea32052c4680d) | Windows adapter | Shader-reported count and stride | Values read back | |---|---|---| | RTX 5080, driver 621.40 | 32 records, 16 bytes | 32/32 correct, `200…231` | | Built-in WARP, 10.0.26100.10068 | 32 records, 16 bytes | 32/32 correct, `200…231` | I also checked the assertions in local controls on both adapters. Appending a 33rd valid record failed the count check. Changing only record 17’s second word from 217 to 317 failed the payload check. The committed test uses the original 32 records. To pick it onto this branch: ```powershell git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr1887-native-structured-reference git cherry-pick 57c170fd324747a480d3b11631fea32052c4680d ``` To reproduce with the Windows SDK’s `dxc.exe` installed: ```powershell $env:VICTORY_WARP = '0' cargo test -p victory-shader --lib --locked native_pc_reads_structured_records -- --nocapture $env:VICTORY_WARP = '1' cargo test -p victory-shader --lib --locked native_pc_reads_structured_records -- --nocapture ``` A completed device run prints `native PC readback matched 32 records with a 16-byte stride`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:03 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 it breaks the differential test. Merged onto main and run with the console compiler set (VICTORY_CONSOLE_DXC), emit::diff_tests::translated_compute_matches_pc fails in three cases ("buffers and root views", "sizes from descriptors", "sizes for scalar loads"); main passes them. Table-bound structured buffers with a used-resource stride are read through structured handles (sizes in elements, structured loads), and those need the structured view the runtime binds, so the fixtures cannot all be raw. Without the console compiler that test is skipped, which is probably why it passed for the testers here. The NVIDIA symptom of #1835 belongs to the runtime's view creation in victory-gpu.

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:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1887#issuecomment-7175886628) Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because it breaks the differential test. Merged onto `main` and run with the console compiler set (`VICTORY_CONSOLE_DXC`), `emit::diff_tests::translated_compute_matches_pc` fails in three cases ("buffers and root views", "sizes from descriptors", "sizes for scalar loads"); `main` passes them. Table-bound structured buffers with a used-resource stride are read through structured handles (sizes in elements, structured loads), and those need the structured view the runtime binds, so the fixtures cannot all be raw. Without the console compiler that test is skipped, which is probably why it passed for the testers here. The NVIDIA symptom of #1835 belongs to the runtime's view creation in `victory-gpu`. 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!1887
No description provided.