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

Open
Indy2l wants to merge 1 commit from upstream-pr/3226 into main
Indy2l commented 2026-11-26 13:44:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Indy2l on 2026-11-26T13:44:29Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5511148140 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3226). Originally posted by [Indy2l](https://github.com/Indy2l) on 2026-11-26T13:44:29Z. --- ## 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)
Dukestar69 commented 2026-11-26 13:47:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T13:47:51Z.

Review: APPROVED


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

<!-- greyfinch-sync:Marvisak/VIctory:review:6075226540 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3226#pullrequestreview-6075226540). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T13:47:51Z. **Review:** APPROVED --- 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).
Jackster commented 2026-11-26 22:44:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:44:11Z.


Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX:

  • Full cargo test -p victory-shader --lib --features host: 302 passed / 0 failed / 3 ignored (172 s) — the same counts as unpatched 63bcca4 here.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.

The change is in the test host only, so the suite is the whole check; this host has a real SM 6.6 device, so the tests take the device path rather than a skip. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204940364 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3226#issuecomment-7204940364). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:44:11Z. --- Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX: - Full `cargo test -p victory-shader --lib --features host`: **302 passed / 0 failed / 3 ignored** (172 s) — the same counts as unpatched `63bcca4` here. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. The change is in the test host only, so the suite is the whole check; this host has a real SM 6.6 device, so the tests take the device path rather than a skip. Synthetic only. AI-assisted.
fuzeofficlal commented 2026-11-26 23:35:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:35:44Z.

Review: APPROVED


LGTM! constants() (crates/victory-shader/src/emit/host.rs:69-71) cleanly promotes an empty slice to &[0], matching root_signature_for's .max(1) root constant slot width and avoiding NVIDIA's dangling-pointer access violation on empty root-constant slices.

Verified locally with cargo xtask policy, cargo clippy --locked -p victory-shader --all-targets -- -D warnings, cargo clippy --locked -p victory-shader --all-features -- -D warnings, and VICTORY_D3D12_DEBUG=1 (emit::host:: 1/1 and emit::tests:: 17/17 passed on both RTX 5090 VICTORY_WARP=0 and WARP VICTORY_WARP=1).

(Minor non-blocking polish: rustfmt --edition 2024 --check flags line length on the two edited Set*Root32BitConstants calls at host.rs:1167 and host.rs:1928, and adding a small dispatch/draw test passing Root::Constants(&[]) would directly lock in the empty-slice path.)

<!-- greyfinch-sync:Marvisak/VIctory:review:6081518387 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3226#pullrequestreview-6081518387). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T23:35:44Z. **Review:** APPROVED --- LGTM! `constants()` (`crates/victory-shader/src/emit/host.rs:69-71`) cleanly promotes an empty slice to `&[0]`, matching `root_signature_for`'s `.max(1)` root constant slot width and avoiding NVIDIA's dangling-pointer access violation on empty root-constant slices. Verified locally with `cargo xtask policy`, `cargo clippy --locked -p victory-shader --all-targets -- -D warnings`, `cargo clippy --locked -p victory-shader --all-features -- -D warnings`, and `VICTORY_D3D12_DEBUG=1` (`emit::host::` 1/1 and `emit::tests::` 17/17 passed on both RTX 5090 `VICTORY_WARP=0` and WARP `VICTORY_WARP=1`). *(Minor non-blocking polish: `rustfmt --edition 2024 --check` flags line length on the two edited `Set*Root32BitConstants` calls at `host.rs:1167` and `host.rs:1928`, and adding a small `dispatch`/`draw` test passing `Root::Constants(&[])` would directly lock in the empty-slice path.)*
kalberts0089-hash commented 2026-11-27 05:09:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kalberts0089-hash on 2026-11-27T05:09:42Z.


NVIDIA test report: RTX 4060 (driver 610.88), Windows 11 Pro, rustc 1.98.1. Head 828242d (base main 63bcca4), cargo test -p victory-shader --no-fail-fast.

  • emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index: passes. On main it kills the test process with 0xc0000005 on this card.
  • Lib suite: 298 passed, 4 failed, 3 ignored. Three of the failures are the known NVIDIA ones. The fourth, valu_tests::normalized_buffer_formats_load_correctly_rounded_quotients, failed with "dispatch failed: The GPU device instance has been suspended". Run alone with --exact it passed 3 of 3 times on this head (about 68 s each) and once on main, so I read it as a timeout under suite load, not a regression from this change.

Synthetic tests only, no game files. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7210400115 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3226#issuecomment-7210400115). Originally posted by [kalberts0089-hash](https://github.com/kalberts0089-hash) on 2026-11-27T05:09:42Z. --- NVIDIA test report: RTX 4060 (driver 610.88), Windows 11 Pro, rustc 1.98.1. Head `828242d` (base main `63bcca4`), `cargo test -p victory-shader --no-fail-fast`. - `emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index`: passes. On main it kills the test process with `0xc0000005` on this card. - Lib suite: 298 passed, 4 failed, 3 ignored. Three of the failures are the known NVIDIA ones. The fourth, `valu_tests::normalized_buffer_formats_load_correctly_rounded_quotients`, failed with "dispatch failed: The GPU device instance has been suspended". Run alone with `--exact` it passed 3 of 3 times on this head (about 68 s each) and once on main, so I read it as a timeout under suite load, not a regression from this change. Synthetic tests only, no game files. AI-assisted (Claude 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/3226:upstream-pr/3226'
git switch 'upstream-pr/3226'

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