Shaders: the test host never passes NVIDIA an empty root-constant slice #3226

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

@⁠Indy2l on GitHub · 2026-11-26 13:44 UTC · original
Indy2l:shader/nvidia-heap-direct-crash → main · +17 −12 · 1 files · 1 commits · open

What

On NVIDIA, the victory-shader unit tests abort the whole test process with STATUS_ACCESS_VIOLATION. The first casualty is emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index, and every test after it goes unreported.

Under cdb, the fault is inside the driver, reading address 0x4:

nvwgf2umx!NVAPI_Thunk+0x1d1b05
D3D12Core!CGraphicsCommandList::SetComputeRoot32BitConstants_...
victory_shader::emit::host::Host::dispatch
victory_shader::emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index

Fixes #2571.

That shader has no user data, so user_data_dwords() == 0 and the test passes Root::Constants(vec![]). root_signature_for still declares user_data_dwords().max(1) values. An empty Vec's pointer is dangling (0x4), and NVIDIA's driver dereferences it even for a count of 0. WARP doesn't, so CI never sees it.

Change

The test host (emit/host.rs) gets a constants() helper that returns one zero for empty data, matching the declared parameter. It's used at all three root-constant call sites.

The runtime is not affected: victory-gpu's pipeline/host.rs leaves the parameter out when dwords == 0.

Testing

  • RTX 3060, driver 32.0.16.2140, Windows 11.
  • cargo test -p victory-shader --lib --locked: no longer aborts. 299 passed, 3 ignored.
  • cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings: clean.

With the abort gone, three NVIDIA failures that were hidden behind it now show up. They're separate issues and not part of this PR:

  • stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros: "dispatch failed: The parameter is incorrect". View::NullBuffers asks for a 2^21-slot view heap, above NVIDIA's 1,000,000 cap (the same cap as #3122).
  • stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride: hardware reads [101, 104, ...], then zeros, where [200, 201, ...] is expected.
  • synthetic_tests::gathers_at_a_level_match_the_hardware: lane 0 gathers [0, 1, 0, 0] where [0, 0, 0, 0] is expected.

🤖 Generated with Claude Code

**@⁠Indy2l** on GitHub · 2026-11-26 13:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/3226) `Indy2l:shader/nvidia-heap-direct-crash` → `main` · +17 −12 · 1 files · 1 commits · open ## What On NVIDIA, the `victory-shader` unit tests abort the whole test process with `STATUS_ACCESS_VIOLATION`. The first casualty is `emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index`, and every test after it goes unreported. Under `cdb`, the fault is inside the driver, reading address `0x4`: ``` nvwgf2umx!NVAPI_Thunk+0x1d1b05 D3D12Core!CGraphicsCommandList::SetComputeRoot32BitConstants_... victory_shader::emit::host::Host::dispatch victory_shader::emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index ``` Fixes #2571. That shader has no user data, so `user_data_dwords() == 0` and the test passes `Root::Constants(vec![])`. `root_signature_for` still declares `user_data_dwords().max(1)` values. An empty `Vec`'s pointer is dangling (`0x4`), and NVIDIA's driver dereferences it even for a count of 0. WARP doesn't, so CI never sees it. ## Change The test host (`emit/host.rs`) gets a `constants()` helper that returns one zero for empty data, matching the declared parameter. It's used at all three root-constant call sites. The runtime is not affected: `victory-gpu`'s `pipeline/host.rs` leaves the parameter out when `dwords == 0`. ## Testing - RTX 3060, driver 32.0.16.2140, Windows 11. - `cargo test -p victory-shader --lib --locked`: no longer aborts. 299 passed, 3 ignored. - `cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings`: clean. With the abort gone, three NVIDIA failures that were hidden behind it now show up. They're separate issues and not part of this PR: - `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`: "dispatch failed: The parameter is incorrect". `View::NullBuffers` asks for a 2^21-slot view heap, above NVIDIA's 1,000,000 cap (the same cap as #3122). - `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`: hardware reads `[101, 104, ...]`, then zeros, where `[200, 201, ...]` is expected. - `synthetic_tests::gathers_at_a_level_match_the_hardware`: lane 0 gathers `[0, 1, 0, 0]` where `[0, 0, 0, 0]` is expected. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A shader with no user data gets user_data_dwords() == 0, so tests pass
Root::Constants(vec![]) while root_signature_for still declares one
value. An empty slice's pointer is dangling (0x4), and NVIDIA's driver
reads it even for a count of 0: SetComputeRoot32BitConstants faults in
nvwgf2umx with an access violation at 0x4, taking the whole
victory-shader test process down (first at
memory_tests::heap_direct_texture_reads_mark_their_heap_index). WARP
tolerates it.

The test host now sets one zero where the data is empty, matching the
declared parameter, at its three root-constant call sites. The runtime
(victory-gpu pipeline/host.rs) leaves the parameter out when a shader
has no user data, so it is not affected.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:47:23 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 13:47 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-shader --lib emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index -- --test-threads=1: PASSED on RTX 5090! (Previously crashed with 0xc0000005 under #2571 on clean origin/main.)
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Great NVIDIA driver workaround: passing &[0] instead of an empty dangling slice avoids NVIDIA's Set*Root32BitConstants read at 0x4.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 13:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/3226#pullrequestreview-6075226540) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index -- --test-threads=1`: **PASSED on RTX 5090!** (Previously crashed with `0xc0000005` under `#2571` on clean `origin/main`.) - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Great NVIDIA driver workaround: passing `&[0]` instead of an empty dangling slice avoids NVIDIA's `Set*Root32BitConstants` read at `0x4`. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
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/3226/head:github-bot/gh-3226'
git switch 'github-bot/gh-3226'

Merge

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