Skip to content

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

Open
Therecalloftheonion wants to merge 1 commit into
Marvisak:mainfrom
Therecalloftheonion:pr/shader-test-constants
Open

Therecalloftheonion wants to merge 1 commit into
Marvisak:mainfrom
Therecalloftheonion:pr/shader-test-constants

Conversation

@Therecalloftheonion

Copy link
Copy Markdown

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.
@kotekompotek

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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).

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
@HAL9000RELOADED

Copy link
Copy Markdown

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 + GPU: load the Agility SDK through ID3D12SDKConfiguration1 (#749) #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

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

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 (comment) (AI-assisted)

Copy link
Copy Markdown
Owner

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

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.

6 participants