Skip to content

Shader tests: an empty root-constant list is set as the one constant it declares (#2571) - #2596

Open
Creaa wants to merge 1 commit into
Marvisak:mainfrom
Creaa:shader-tests/root-constants-empty-list
Open

Creaa wants to merge 1 commit into
Marvisak:mainfrom
Creaa:shader-tests/root-constants-empty-list

Conversation

@Creaa

@Creaa Creaa commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

heap_direct_texture_reads_mark_their_heap_index killed the victory-shader test process on hardware GPUs because the test harness set root constants as 0 values through an empty Vec's dangling pointer, while the root signature it builds declares at least one constant (user_data_dwords().max(1)). WARP ignores the 0-value call; the hardware driver reads through the pointer and the process ends with 0xC0000005. An empty constant list is now set as the one zero constant the signature declares. Fixes #2571.

What is in it

  • crates/victory-shader/src/emit/host.rs: in dispatch (compute) and the graphics dispatch, Root::Constants with no values is set as [0]. fuses_fmad already sized its constants with max(1).

Tested

  • RTX 4070 12 GB (driver 617.14), i7-13700F, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0; on main 67e8ae1.
  • cargo test -p victory-shader --lib --locked heap_direct_texture_reads_mark_their_heap_index: on main 0xC0000005 in every run, in the hardware pass's dispatch (the pipeline is built; the warp pass is never reached); with this change 3 of 3 runs pass, hardware and WARP.
  • cargo test --workspace --locked --no-fail-fast: on main 507 passed, 2 failed, 6 ignored, and the victory-shader test binary ends with 0xC0000005, so none of its results are counted; with this change 774 passed, 5 failed, 9 ignored. The 5 fail the same way on main (940d32f, when the shader binary still ran) and are outside this change: dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views, a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware (the five in Test report: RTX 5070 (Blackwell), Windows 11, 70564ae: 471 passed, 5 failed, 7 ignored (4 from the 1,000,000 view heap cap) #1744).
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean. cargo xtask policy: 184 files ok.

Not tested

AI use

  • Claude Code (Claude Opus 5.5) found the cause, wrote the change, ran the tests, and drafted this description; I checked it.

🤖 Generated with Claude Code

…it declares (Marvisak#2571)

The test harness declares every program's root constants with
`user_data_dwords().max(1)` values, but `dispatch` passed a test's
`Root::Constants(vec![])` as 0 values through the empty Vec's dangling
pointer. WARP ignores that; a hardware driver reads through it, and the test
process ends with 0xC0000005 (heap_direct_texture_reads_mark_their_heap_index
on an RTX 5070 and an RTX 4070, and on AMD per Marvisak#2547), which also stops every
later victory-shader test in that run. An empty list is now set as one zero,
in the compute and the graphics path; `fuses_fmad` already did this.

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

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

Reproduced #2571 and verified the fix on an RTX 3080 (617.42), Windows 10 Pro 22H2 (19045), main 67e8ae1 + #486 (needed for SM 6.6 on Windows 10):

  • main: cargo test -p victory-shader --lib --locked -- --test-threads=1 dies after 65 tests with 0xc0000005, STATUS_ACCESS_VIOLATION.
  • This PR: 267 passed, 3 failed. The 3 are the known #1835 ones; heap_direct_texture_reads_mark_their_heap_index passes.

Setting the one declared constant is the right fix, rather than skipping the call. host.rs:162 builds the root signature with Num32BitValues: s.user_data_dwords().max(1), so there is always a constant parameter, and skipping it would leave that root argument undefined at dispatch. #2587 fixes the same crash by skipping the call; only one of the two should land.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

Fixes it on Ampere too. RTX 3070 (driver 616.56), Windows 11, debug, emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index alone on hardware:

tree runs result
main 67e8ae1 3 3 of 3 kill the test process (0xc0000005); with VICTORY_WARP=1 it passes
this PR 577839a 3 3 of 3 pass

cargo test --locked -p victory-shader at 577839a: 267 passed, 3 failed, no crash. The 3 are stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros and synthetic_tests::gathers_at_a_level_match_the_hardware, which fail the same way on 940d32f on this card (the #1744 NVIDIA failures). On main 67e8ae1 the whole suite aborts at this test, so there is no full count to compare.

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only.

@oni-swr

oni-swr commented Nov 25, 2026 •

Copy link
Copy Markdown

Verification of 577839a (CPU-only; D3D12 tests deliberately not run)

  • Merges cleanly onto origin/main (67e8ae1).
  • cargo test -p victory-shader --lib --no-run: builds. cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • Not run: any D3D12-touching test. victory-shader's test host does not honor VICTORY_D3D12_WARP (it uses VICTORY_WARP=1 or the hardware adapter, so tests calling Host::new(false) would open the physical GPU), so I kept this to build and lint plus diff review. This PR adds no new test, so I have nothing to report on WARP or hardware.
  • Diff review: the &[0] fallback matches the root signature, which always declares at least one 32-bit constant (user_data_dwords().max(1), host.rs ~L162). It also sets every root parameter. The new comment lines are longer than rustfmt's width; rustfmt --check on the file only reports a hunk at ~L363, which this diff does not touch.

Overlap with #2587 (same issue, #2571): the two PRs make the same code change, setting [0] in the same two Root::Constants arms of emit/host.rs. They are duplicates, and git merge-tree of the two heads reports a conflict in that file. (Edited: when I first reviewed #2587 at 8ceeb01 it skipped the call instead. Its head df8ee8e now binds [0] like this PR.) #2587 also adds a regression test, which is unrun here for the reason above. This PR is the fix alone. A maintainer should land one and close or rebase the other.

Independent verification by Claude Code (Claude Sonnet 5.5), an AI assistant, run for oni-swr. No game files, dumps, or shader names were used.

@Vedoxdev123

Copy link
Copy Markdown

RTX 4060 test (AI-assisted)
Windows 64-bit, Ryzen 5 5600X, GeForce RTX 4060 (8 GB), on main 13f91ca + this PR (577839a).

  • cargo test -p victory-shader: main aborts with 0xc0000005 at emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index and prints no summary. With this PR the run completes: 267 passed, 3 failed, 3 ignored. The 3 failures are the known NVIDIA ones from NVIDIA D3D12 (70564ae): stride_tests & synthetic_tests fail due to HEAP_VIEWS (2M > 1M NVIDIA limit) and Stride::Structured with rawBufferLoad #1835 (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware).
  • cargo test -p victory-gpu --lib: 193 passed, 2 failed, 1 ignored, identical to main (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views). No change from this PR.

@qtLkz

qtLkz commented Nov 25, 2026

Copy link
Copy Markdown

Tested on NVIDIA Ada, a different generation from the RTX 5070 in #2571: RTX 4070 Ti, driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned, this PR merged onto main 13f91ca (clean merge).

Plain main 13f91ca on this card: the victory-shader lib run dies with STATUS_ACCESS_VIOLATION (0xc0000005) at emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index, the same crash as #2571. The test passes on its own with VICTORY_WARP=1, so only the hardware path crashes.

With this PR: cargo test -p victory-shader --lib --locked -- --test-threads=1

#2587 fixes the same crash on this card too (I'm commenting there separately).

AI-assisted (Claude).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. This fixes #2571, a test-harness crash on hardware adapters. In victory-shader/src/emit/host.rs, the root signature declares user_data_dwords().max(1) constants, but Host::draw and Host::dispatch set an empty Root::Constants as 0 values through an empty Vec's dangling pointer, which NVIDIA and AMD drivers read. Both arms now set the one declared constant as [0]. That matches the signature and fills every declared root parameter. It is test-host code only, and several independent hardware reports in this thread confirm the crash is gone.

Overlap: #2587 makes the same code change and adds a regression test, but it currently conflicts with main (marked needs-rebase). Only one of the two should land. This one merges cleanly. #2587's test could follow on top.

CI: check passing. Merges cleanly into current main. A recommendation to look at it, not an approval.


Generated by Claude Code

@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

Measured against the other #2571 PRs on an RTX 4060, Intel UHD and WARP. This one fixes the crash with no regressions, but it is the same code as #2587, which also has a host-level test, so the comparison suggests one of the two: #2571 (comment) (AI-assisted)

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

Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):

  • Reproduced the crash on origin/main (63bcca4): emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index exits with 0xc0000005 (STATUS_ACCESS_VIOLATION) on RTX 5090 hardware.
  • With #2596 merged: cargo test -p victory-shader --lib emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index: 1 passed, 0 failed on both RTX 5090 hardware and WARP (0.35 s).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Passing &[0] when Root::Constants is empty matches the root signature's user_data_dwords().max(1) declaration and eliminates the dangling-pointer read in both draw and dispatch.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

Jineggegg pushed a commit to Jineggegg/VIctory that referenced this pull request Nov 26, 2026
…it declares (Marvisak#2571)

The test harness declares every program's root constants with
`user_data_dwords().max(1)` values, but `dispatch` passed a test's
`Root::Constants(vec![])` as 0 values through the empty Vec's dangling
pointer. WARP ignores that; a hardware driver reads through it, and the test
process ends with 0xC0000005 (heap_direct_texture_reads_mark_their_heap_index
on an RTX 5070 and an RTX 4070, and on AMD per Marvisak#2547), which also stops every
later victory-shader test in that run. An empty list is now set as one zero,
in the compute and the graphics path; `fuses_fmad` already did this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 577839a)
Upstream-PR: Marvisak#2596

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

Verified 577839a0c3b85fa5e69f7059b63d9192a6952beb cleanly merged onto main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • Fixes the #2571 RTX 5090 crash: on pristine 63bcca43, emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index aborts with 0xc0000005 (STATUS_ACCESS_VIOLATION). With this PR merged, it passes cleanly on RTX 5090 (0.39s), and all 5 emit::memory_tests:: tests pass on both RTX 5090 (1.63s) and WARP (0.33s).
  • Site coverage: crates/victory-shader/src/emit/host.rs:1164-1165 (draw / DispatchMesh / DrawInstanced) and 1929-1930 (dispatch) now match root_signature_for's user_data_dwords().max(1) (host.rs:229), and fuses_fmad (host.rs:610, 696-701) already writes the declared count.
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed (asset policy: 191 files ok); cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features): clean.

Note: overlaps with #2587 on emit/host.rs for #2571 (this PR is the minimal fix without an extra test). Ready to merge.

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.

Shader tests: heap_direct_texture_reads_mark_their_heap_index kills the test process on a real GPU (RTX 5070, main 67e8ae1)

10 participants