Skip to content

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

Open
carlos-seiffert wants to merge 4 commits into
Marvisak:mainfrom
carlos-seiffert:fix/test-host-structured-views-are-raw
Open

carlos-seiffert wants to merge 4 commits into
Marvisak:mainfrom
carlos-seiffert:fix/test-host-structured-views-are-raw

Conversation

@carlos-seiffert

@carlos-seiffert carlos-seiffert commented Nov 25, 2026 •

Copy link
Copy Markdown

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

@Mericas77

Copy link
Copy Markdown

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.

@AlanQiang0418

Copy link
Copy Markdown
Contributor

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.

@carlos-seiffert

Copy link
Copy Markdown
Author

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

scarlos-source and others added 2 commits November 24, 2026 22:26
…ak#1835)

`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 (Marvisak#1779 fixes it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@carlos-seiffert
carlos-seiffert force-pushed the fix/test-host-structured-views-are-raw branch from 9ae875d to 62bd980 Compare November 25, 2026 01:28

@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: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.

144 passed / 0 failed / 2 ignored. Test-host structured buffer views marked raw per #1835 — test-infra correctness fix, no product change.

@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 locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib emit::stride_tests:: — 5 passed, 1 failed on both RTX 5090 and WARP: directly fixes a_heap_buffer_read_by_element_takes_the_views_stride on NVIDIA RTX 5090! (The 1 remaining failure, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, is the separate NVIDIA 1M view-heap cap issue covered by #2121.)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean fix making structured buffer views raw in the test host to match NVIDIA's rawBufferLoad behavior. Looks good.

AI-assisted (Gemini 4 Neon).

0xkn0wh3r3 added a commit to 0xkn0wh3r3/VIctory that referenced this pull request Nov 25, 2026
…mmit

Marvisak#2130 was rewritten on top of Marvisak#2120's update, so layering it on the old
merges kept two versions of it. This tree is upstream main (940d32f) with
all 32 open PRs of 0xkn0wh3r3 at their current commits, the upstream
fixes Marvisak#1887, Marvisak#1717, Marvisak#1832, Marvisak#1630, Marvisak#1763 and Marvisak#1613, and the demo-only
conformance list; the old history stays as this merge's first parent.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

…isak#1835)

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 <noreply@anthropic.com>
@carlos-seiffert

Copy link
Copy Markdown
Author

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

…untime

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@steven-seagull27

Copy link
Copy Markdown

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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants