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

Open
Therecalloftheonion wants to merge 1 commit from upstream-pr/2739 into main
Therecalloftheonion commented 2026-11-25 19:23:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Therecalloftheonion on 2026-11-25T19:23:51Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6611993499 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2739). Originally posted by [Therecalloftheonion](https://github.com/Therecalloftheonion) on 2026-11-25T19:23:51Z. --- ## 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.
kotekompotek commented 2026-11-25 20:06:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:05:54Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173187599 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7173187599). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T20:05:54Z. --- 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.
fuzeofficlal commented 2026-11-25 21:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:10:47Z.


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).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7173297394 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7173297394). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T20:10:47Z. --- 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).
HAL9000RELOADED commented 2026-11-25 23:06:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by HAL9000RELOADED on 2026-11-25T22:53:19Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176902559 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7176902559). Originally posted by [HAL9000RELOADED](https://github.com/HAL9000RELOADED) on 2026-11-25T22:53:19Z. --- 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.
KainanP commented 2026-11-25 23:06:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-25T22:53:53Z.


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://github.com/Marvisak/VIctory/issues/2571#issuecomment-7176908308 (AI-assisted)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176913644 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7176913644). Originally posted by [KainanP](https://github.com/KainanP) on 2026-11-25T22:53:53Z. --- 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://github.com/Marvisak/VIctory/issues/2571#issuecomment-7176908308 (AI-assisted)
Marvisak commented 2026-11-26 00:03:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:23:21Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177491817 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2739#issuecomment-7177491817). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:23:21Z. --- <!-- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2739:upstream-pr/2739'
git switch 'upstream-pr/2739'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2739'
git switch 'upstream-pr/2739'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2739'
git switch 'upstream-pr/2739'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2739'
git switch 'main'
git merge --squash 'upstream-pr/2739'
git switch 'main'
git merge --ff-only 'upstream-pr/2739'
git switch 'main'
git merge 'upstream-pr/2739'
git push origin 'main'
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!2737
No description provided.