Tests: bind a constant where a shader has no user data #2739

Open
github-bot wants to merge 1 commit from github-bot/gh-2739 into main AGit
Owner

@⁠Therecalloftheonion on GitHub · 2026-11-25 19:23 UTC · original
Therecalloftheonion:pr/shader-test-constants → main · +4 −4 · 1 files · 1 commits · open

What

The host root signature always declares at least one 32-bit constant (Num32BitValues.max(1)), but four memory tests sized their constant array from user_data_dwords() and could pass a count of 0 to SetComputeRoot32BitConstants.

Why

On the RX 6700 XT, SetComputeRoot32BitConstants(..., 0, ...) access-violates and aborts the test process; WARP tolerates it. That made the whole victory-shader suite unusable on this GPU (heap_direct_texture_reads_mark_their_heap_index died with STATUS_ACCESS_VIOLATION). Every other shader test already uses .max(1).

Testing

  • cargo test -p victory-shader --lib: 268 passed; the suite no longer aborts. Two pre-existing hardware assertions remain on this GPU (stride_tests::a_heap_buffer_read_by_element... and synthetic_tests::gathers_at_a_level_match_the_hardware), outside this change.
  • CI runs without a GPU.
**@⁠Therecalloftheonion** on GitHub · 2026-11-25 19:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2739) `Therecalloftheonion:pr/shader-test-constants` → `main` · +4 −4 · 1 files · 1 commits · open ## What The host root signature always declares at least one 32-bit constant (`Num32BitValues.max(1)`), but four memory tests sized their constant array from `user_data_dwords()` and could pass a count of 0 to `SetComputeRoot32BitConstants`. ## Why On the RX 6700 XT, `SetComputeRoot32BitConstants(..., 0, ...)` access-violates and aborts the test process; WARP tolerates it. That made the whole `victory-shader` suite unusable on this GPU (`heap_direct_texture_reads_mark_their_heap_index` died with `STATUS_ACCESS_VIOLATION`). Every other shader test already uses `.max(1)`. ## Testing - `cargo test -p victory-shader --lib`: 268 passed; the suite no longer aborts. Two pre-existing hardware assertions remain on this GPU (`stride_tests::a_heap_buffer_read_by_element...` and `synthetic_tests::gathers_at_a_level_match_the_hardware`), outside this change. - CI runs without a GPU.
The host root signature always declares one 32-bit constant (Num32BitValues.max(1)), but four memory tests sized their user data from user_data_dwords() and could pass a count of 0 to SetComputeRoot32BitConstants. On the RX 6700 XT the driver access-violates on that call (WARP tolerates it), killing the shader test process; the other shader tests already use max(1). Memory tests now do the same.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:13:08 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 20:05 UTC · original

Correct: user_data_dwords()==0 would panic on ud[u.index] in the loop or pass an empty slice to dispatch; .max(1) keeps both paths safe without changing semantics for shaders that do have user data.

**@⁠kotekompotek** on GitHub · 2026-11-25 20:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7173187599) Correct: user_data_dwords()==0 would panic on ud[u.index] in the loop or pass an empty slice to dispatch; .max(1) keeps both paths safe without changing semantics for shaders that do have user data.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 20:10 UTC · original

Verified f237a3cf on Windows 11 + NVIDIA GeForce RTX 5090 (rustc 1.98.1 MSVC, VICTORY_WARP unset).

  • cargo test --locked -p victory-shader --lib --features host emit::memory_tests: 4 passed, 0 failed — this directly resolves the 0xc0000005 crash in heap_direct_texture_reads_mark_their_heap_index on RTX 5090 as well (not just RX 6700 XT).
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default & --features host): 0 warnings; cargo xtask policy: 184 files ok.
  • Clean git merge-tree against 13f91ca and #2587 (complementary: #2587 guards empty slices in emit/host.rs, #2739 fixes the 4 memory_tests.rs callers).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 20:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7173297394) Verified `f237a3cf` on Windows 11 + NVIDIA GeForce RTX 5090 (`rustc 1.98.1` MSVC, `VICTORY_WARP` unset). - `cargo test --locked -p victory-shader --lib --features host emit::memory_tests`: **4 passed, 0 failed** — this directly resolves the `0xc0000005` crash in `heap_direct_texture_reads_mark_their_heap_index` on RTX 5090 as well (not just RX 6700 XT). - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default & `--features host`): **0 warnings**; `cargo xtask policy`: **184 files ok**. - Clean `git merge-tree` against `13f91ca` and `#2587` (complementary: `#2587` guards empty slices in `emit/host.rs`, `#2739` fixes the 4 `memory_tests.rs` callers).
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-25 22:53 UTC · original

RDNA3 data point for f237a3c: RX 7900 XTX, driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 through #969 (VICTORY_D3D12_AGILITY). Base: 3e8c00a (main 13f91ca + #969).

  • With the PR: victory-shader 273 passed, 0 failed, no abort.
  • On main + #969 without the PR, the suite doesn't abort either. heap_direct_texture_reads_mark_their_heap_index passes there too, so on this card a count of 0 to SetComputeRoot32BitConstants is tolerated, as on WARP.
  • The two assertions your RX 6700 XT still trips pass here, with and without the PR: a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware.

So the abort looks specific to RDNA2 (or its driver). The .max(1) change is harmless here.

**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 22:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7176902559) RDNA3 data point for `f237a3c`: RX 7900 XTX, driver 32.0.32015.7029, Windows 10 22H2 (19045), Agility SDK 1.620 through #969 (`VICTORY_D3D12_AGILITY`). Base: `3e8c00a` (main `13f91ca` + #969). - With the PR: `victory-shader` 273 passed, 0 failed, no abort. - On main + #969 without the PR, the suite doesn't abort either. `heap_direct_texture_reads_mark_their_heap_index` passes there too, so on this card a count of 0 to `SetComputeRoot32BitConstants` is tolerated, as on WARP. - The two assertions your RX 6700 XT still trips pass here, with and without the PR: `a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware`. So the abort looks specific to RDNA2 (or its driver). The `.max(1)` change is harmless here.
Author
Owner

@⁠KainanP on GitHub · 2026-11-25 22:53 UTC · original

Measured in the #2571 comparison: it fixes the 4 memory_tests callers, but #2587's host-level test still crashes on an RTX 4060 with only this PR. It merges cleanly alongside the host fix as optional hygiene: #2571 (AI-assisted)

**@⁠KainanP** on GitHub · 2026-11-25 22:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7176913644) Measured in the #2571 comparison: it fixes the 4 `memory_tests` callers, but #2587's host-level test still crashes on an RTX 4060 with only this PR. It merges cleanly alongside the host fix as optional hygiene: https://git.gtahub.st/github/Marvisak--VIctory/issues/2571 (AI-assisted)
Author
Owner

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

Automated triage for the maintainers.

The change is harmless and matches how the root signature is declared (Num32BitValues: s.user_data_dwords().max(1) in Host::root_signature_for, crates/victory-shader/src/emit/host.rs), but it fixes only four callers. On current main there are still callers that size root constants from user_data_dwords() without .max(1): the straddling-write test in crates/victory-shader/src/emit/memory_tests.rs (around line 879, added after this PR's base) and crates/victory-shader/src/emit/valu_tests.rs (around line 395), so the description's "every other shader test already uses .max(1)" does not hold any more. The root cause (an empty slice's dangling pointer reaching SetComputeRoot32BitConstants) is addressed for every caller at the host level by open PR #2587 (Host::dispatch / Host::draw), which needs a rebase.

What would change the verdict: either rebase and cover all remaining callers, or a maintainer decides to take #2587 instead, in which case this PR is not needed. CI (check) passes.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 23:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7177491817) <!-- victory-triage v1 head=f237a3cfa91dad583e74bcd98a88bc84f41de5ab verdict=needs-work at=2026-11-25T23:23:13Z --> Automated triage for the maintainers. The change is harmless and matches how the root signature is declared (`Num32BitValues: s.user_data_dwords().max(1)` in `Host::root_signature_for`, `crates/victory-shader/src/emit/host.rs`), but it fixes only four callers. On current `main` there are still callers that size root constants from `user_data_dwords()` without `.max(1)`: the straddling-write test in `crates/victory-shader/src/emit/memory_tests.rs` (around line 879, added after this PR's base) and `crates/victory-shader/src/emit/valu_tests.rs` (around line 395), so the description's "every other shader test already uses `.max(1)`" does not hold any more. The root cause (an empty slice's dangling pointer reaching `SetComputeRoot32BitConstants`) is addressed for every caller at the host level by open PR #2587 (`Host::dispatch` / `Host::draw`), which needs a rebase. What would change the verdict: either rebase and cover all remaining callers, or a maintainer decides to take #2587 instead, in which case this PR is not needed. CI (`check`) passes. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2739/head:github-bot/gh-2739'
git switch 'github-bot/gh-2739'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2739'
git switch 'github-bot/gh-2739'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2739'
git switch 'github-bot/gh-2739'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2739'
git switch 'main'
git merge --squash 'github-bot/gh-2739'
git switch 'main'
git merge --ff-only 'github-bot/gh-2739'
git switch 'main'
git merge 'github-bot/gh-2739'
git push origin 'main'
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!2739
No description provided.