emit host: an empty root-constant list is not passed to the runtime #3000

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

@⁠HoLa-Lee on GitHub · 2026-11-26 03:00 UTC · original
HoLa-Lee:tests/empty-root-constants → main · +13 −0 · 1 files · 1 commits · open

emit host: an empty root-constant list is not passed to the runtime

Host::dispatch (the shader crate's test host) calls
SetComputeRoot32BitConstants(param, data.len(), data.as_ptr(), 0) for every
Root::Constants the test asks for. A program that declares no user data - the
lowering puts the heap base elsewhere - makes the test pass
vec![0u32; shader.user_data_dwords()] with user_data_dwords() == 0, so the
call is made with a count of 0 and a pointer into an empty vector.

On an NVIDIA card that takes the process down:

test emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index ...
process didn't exit successfully (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

It does it on every run, alone (--exact … --test-threads=1) as well as in the
suite, and because it is an access violation rather than a failed assertion the
harness prints neither the line nor which arm of the test was running - and
every test after it in victory-shader goes unreported
. Measured with markers
through the test and through dispatch, the last one printed is the roots loop
starting, and the arm that follows is this call:

MARK views done
MARK samplers done
MARK heaps set
MARK root 0
<STATUS_ACCESS_VIOLATION>

The change

An empty list means "nothing to set", so nothing is set: the root keeps its
zeros, which is what the shader would read anyway. Six lines, a guard arm and a
comment saying why.

What it unblocks

The whole victory-shader suite now runs on this card, and three tests that
could never be reached before fail
:

test failure
emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride assertion left == right failed: hardware: lane 0
emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros assertion left == right failed: hardware
emit::synthetic_tests::gathers_at_a_level_match_the_hardware hardware: dispatch failed: 参数错误

All three fail on the hardware arm only, which is FIND-11's territory ("heap
indexed buffer reads by element use a raw handle on the title's structured views,
which NVIDIA reads wrong"). They are not this PR's to fix - they are what this PR
makes visible, and they are exactly why the crash mattered: an NVIDIA run of the
shader crate has been reporting nothing past memory_tests at all.

cargo test -p victory-shader --lib --profile diag
299 passed, 3 failed, 3 ignored      (before: the process died mid-suite)

Why not in the test instead

The same guard in one test would leave the next test that reaches an empty
constants list to be discovered by another crash. The harness is where every
test's dispatch goes through, and "count 0 with a pointer" is not something to
hand a driver.

**@⁠HoLa-Lee** on GitHub · 2026-11-26 03:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/3000) `HoLa-Lee:tests/empty-root-constants` → `main` · +13 −0 · 1 files · 1 commits · open emit host: an empty root-constant list is not passed to the runtime `Host::dispatch` (the shader crate's test host) calls `SetComputeRoot32BitConstants(param, data.len(), data.as_ptr(), 0)` for every `Root::Constants` the test asks for. A program that declares no user data - the lowering puts the heap base elsewhere - makes the test pass `vec![0u32; shader.user_data_dwords()]` with `user_data_dwords() == 0`, so the call is made with a **count of 0 and a pointer into an empty vector**. On an NVIDIA card that takes the process down: test emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index ... process didn't exit successfully (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION) It does it on every run, alone (`--exact … --test-threads=1`) as well as in the suite, and because it is an access violation rather than a failed assertion the harness prints neither the line nor which arm of the test was running - **and every test after it in `victory-shader` goes unreported**. Measured with markers through the test and through `dispatch`, the last one printed is the roots loop starting, and the arm that follows is this call: MARK views done MARK samplers done MARK heaps set MARK root 0 <STATUS_ACCESS_VIOLATION> ## The change An empty list means "nothing to set", so nothing is set: the root keeps its zeros, which is what the shader would read anyway. Six lines, a guard arm and a comment saying why. ## What it unblocks The whole `victory-shader` suite now runs on this card, and **three tests that could never be reached before fail**: | test | failure | |---|---| | `emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride` | `assertion left == right failed: hardware: lane 0` | | `emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` | `assertion left == right failed: hardware` | | `emit::synthetic_tests::gathers_at_a_level_match_the_hardware` | `hardware: dispatch failed: 参数错误` | All three fail on the **hardware** arm only, which is FIND-11's territory ("heap indexed buffer reads by element use a raw handle on the title's structured views, which NVIDIA reads wrong"). They are not this PR's to fix - they are what this PR makes visible, and they are exactly why the crash mattered: an NVIDIA run of the shader crate has been reporting nothing past `memory_tests` at all. cargo test -p victory-shader --lib --profile diag 299 passed, 3 failed, 3 ignored (before: the process died mid-suite) ## Why not in the test instead The same guard in one test would leave the next test that reaches an empty constants list to be discovered by another crash. The harness is where every test's dispatch goes through, and "count 0 with a pointer" is not something to hand a driver.
`Host::dispatch` (the shader crate's test host) calls
`SetComputeRoot32BitConstants(param, data.len(), data.as_ptr(), 0)` for every
`Root::Constants` the test asks for. A program that declares no user data - the
lowering puts the heap base elsewhere - makes the test pass
`vec![0u32; shader.user_data_dwords()]` with `user_data_dwords() == 0`, so the
call is made with a **count of 0 and a pointer into an empty vector**.

On an NVIDIA card that takes the process down:

    test emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index ...
    process didn't exit successfully (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

It does it on every run, alone (`--exact … --test-threads=1`) as well as in the
suite, and because it is an access violation rather than a failed assertion the
harness prints neither the line nor which arm of the test was running - **and
every test after it in `victory-shader` goes unreported**. Measured with markers
through the test and through `dispatch`, the last one printed is the roots loop
starting, and the arm that follows is this call:

    MARK views done
    MARK samplers done
    MARK heaps set
    MARK root 0
    <STATUS_ACCESS_VIOLATION>

## The change

An empty list means "nothing to set", so nothing is set: the root keeps its
zeros, which is what the shader would read anyway. Six lines, a guard arm and a
comment saying why.

## What it unblocks

The whole `victory-shader` suite now runs on this card, and **three tests that
could never be reached before fail**:

| test | failure |
|---|---|
| `emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride` | `assertion left == right failed: hardware: lane 0` |
| `emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` | `assertion left == right failed: hardware` |
| `emit::synthetic_tests::gathers_at_a_level_match_the_hardware` | `hardware: dispatch failed: 参数错误` |

All three fail on the **hardware** arm only, which is FIND-11's territory ("heap
indexed buffer reads by element use a raw handle on the title's structured views,
which NVIDIA reads wrong"). They are not this PR's to fix - they are what this PR
makes visible, and they are exactly why the crash mattered: an NVIDIA run of the
shader crate has been reporting nothing past `memory_tests` at all.

    cargo test -p victory-shader --lib --profile diag
    299 passed, 3 failed, 3 ignored      (before: the process died mid-suite)

## Why not in the test instead

The same guard in one test would leave the next test that reaches an empty
constants list to be discovered by another crash. The harness is where every
test's dispatch goes through, and "count 0 with a pointer" is not something to
hand a driver.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:19:47 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 05:27 UTC · original

Automated triage for the maintainers.

Merge candidate (recommending a look, not approving). In the shader crate's test host (crates/victory-shader/src/emit/host.rs, Host::dispatch), an empty Root::Constants list is now skipped instead of being passed to SetComputeRoot32BitConstants with a count of 0. The PR shows that call crashing the test process on NVIDIA in memory_tests::heap_direct_texture_reads_mark_their_heap_index (the crash other reports here link to #2571), which hides every later test in the crate. The change is test-only and touches nothing the title runs. CI: not run on this head (no check runs).

Two small points:

  • Host::draw makes the same SetGraphicsRoot32BitConstants call without the guard. Adding the same arm there would cover graphics tests too.
  • The comment says the skipped root keeps "zeros". The root signature gives it user_data_dwords().max(1) = 1 constant, and D3D12 leaves unset root constants undefined, not zero. That is harmless here only because a program with no user data reads none, so please say that instead.

Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 05:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3000#issuecomment-7183496699) <!-- victory-triage v1 head=ebc57bd7a5c904abbbb02e2d2771b811aaa506fd verdict=merge-candidate at=2026-11-26T05:29:00Z --> Automated triage for the maintainers. **Merge candidate** (recommending a look, not approving). In the shader crate's test host (`crates/victory-shader/src/emit/host.rs`, `Host::dispatch`), an empty `Root::Constants` list is now skipped instead of being passed to `SetComputeRoot32BitConstants` with a count of 0. The PR shows that call crashing the test process on NVIDIA in `memory_tests::heap_direct_texture_reads_mark_their_heap_index` (the crash other reports here link to #2571), which hides every later test in the crate. The change is test-only and touches nothing the title runs. CI: not run on this head (no check runs). Two small points: - `Host::draw` makes the same `SetGraphicsRoot32BitConstants` call without the guard. Adding the same arm there would cover graphics tests too. - The comment says the skipped root keeps "zeros". The root signature gives it `user_data_dwords().max(1)` = 1 constant, and D3D12 leaves unset root constants undefined, not zero. That is harmless here only because a program with no user data reads none, so please say that instead. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot force-pushed github-bot/gh-3000 from ebc57bd7a5 to 242a83f6c0 2026-11-26 13:59:48 +00:00 Compare
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 03:03 UTC · original · approved these changes

LGTM — the empty-Constants arm sits before the general one, so a program with no user data skips the call entirely rather than passing count 0 with a pointer into nothing (documented NVIDIA crash path). Ordering is the fix; comment matches.

**@⁠kotekompotek** on GitHub · 2026-11-26 03:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3000#pullrequestreview-6067986075) · **approved these changes** LGTM — the empty-Constants arm sits before the general one, so a program with no user data skips the call entirely rather than passing count 0 with a pointer into nothing (documented NVIDIA crash path). Ordering is the fix; comment matches.
Author
Owner

@⁠fyernald on GitHub · 2026-11-26 05:04 UTC · original · reviewed

Tested ebc57bd on an RTX 3080 (driver 617.42), Windows 10 22H2. Base is main 63bcca4 with the Agility opt-in from #486, since Windows 10's in-box runtime skips the SM 6.6 tests without it.

main + this PR
emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index alone 0xC0000005 passes
cargo test -p victory-shader --lib -- --test-threads=1 dies at that test 298 passed, 4 failed, 3 ignored

The 4 failures are NVIDIA failures already on main: 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, synthetic_tests::gathers_at_a_level_match_the_hardware and synthetic_tests::pops_wait_loop_exits_immediately_for_inactive_lanes.

This is the crash reported in #2571. #2596 and #2587 fix it too and have been open since yesterday. On the same base, #2596 instead of this PR gives the identical suite result (298/4, same four tests). Two differences from #2596:

  1. #2596 changes the graphics path as well (SetGraphicsRoot32BitConstants, emit/host.rs:1159 on main), which makes the same call with an empty list's pointer. This PR changes only the compute path.
  2. The new comment says the skipped root stays zeros. The root signature still declares one constant (user_data_dwords().max(1), host.rs:229), and D3D12 doesn't promise zeros for a root constant that was never set after SetComputeRootSignature. The shader doesn't read it, so nothing breaks, but the comment isn't accurate. #2596 sets that constant to 0 explicitly.

Linking #2571 here would help triage see the three fixes together.

**@⁠fyernald** on GitHub · 2026-11-26 05:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/3000#pullrequestreview-6068810810) · **reviewed** Tested `ebc57bd` on an RTX 3080 (driver 617.42), Windows 10 22H2. Base is `main` `63bcca4` with the Agility opt-in from #486, since Windows 10's in-box runtime skips the SM 6.6 tests without it. | | `main` | + this PR | |---|---|---| | `emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index` alone | `0xC0000005` | passes | | `cargo test -p victory-shader --lib -- --test-threads=1` | dies at that test | 298 passed, 4 failed, 3 ignored | The 4 failures are NVIDIA failures already on `main`: `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`, `synthetic_tests::gathers_at_a_level_match_the_hardware` and `synthetic_tests::pops_wait_loop_exits_immediately_for_inactive_lanes`. This is the crash reported in #2571. #2596 and #2587 fix it too and have been open since yesterday. On the same base, #2596 instead of this PR gives the identical suite result (298/4, same four tests). Two differences from #2596: 1. #2596 changes the graphics path as well (`SetGraphicsRoot32BitConstants`, `emit/host.rs:1159` on `main`), which makes the same call with an empty list's pointer. This PR changes only the compute path. 2. The new comment says the skipped root stays zeros. The root signature still declares one constant (`user_data_dwords().max(1)`, `host.rs:229`), and D3D12 doesn't promise zeros for a root constant that was never set after `SetComputeRootSignature`. The shader doesn't read it, so nothing breaks, but the comment isn't accurate. #2596 sets that constant to 0 explicitly. Linking #2571 here would help triage see the three fixes together.
Author
Owner

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

Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):

  • Diff review: Skipping SetComputeRoot32BitConstants when data.is_empty() avoids passing a 0-count dangling slice pointer into the NVIDIA driver for shaders with no user data.
  • cargo test -p victory-shader emit::host -- --test-threads=1: 1 passed, 0 failed.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

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

**@⁠Dukestar69** on GitHub · 2026-11-26 06:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/3000#pullrequestreview-6069333655) · **approved these changes** Tested locally merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP): - Diff review: Skipping `SetComputeRoot32BitConstants` when `data.is_empty()` avoids passing a 0-count dangling slice pointer into the NVIDIA driver for shaders with no user data. - `cargo test -p victory-shader emit::host -- --test-threads=1`: 1 passed, 0 failed. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠HoLa-Lee on GitHub · 2026-11-26 13:56 UTC · original

Both points are in, 242a83f (one file, +13/-0).

  • Host::draw has the same arm, so an empty list is now skipped there too: SetGraphicsRoot32BitConstants with a count of 0 and a pointer into nothing is the same shape, and the graphics tests reach it the same way. The two arms carry the same comment pointing at the other one.
  • The comment no longer claims zeros. It says what is true: a root left unset is undefined in D3D12, not zero, and that is harmless only because a program that declares no user data reads none of its constants. Both comments say so.

Nothing else changed: victory-shader still stops at FIND-11's three hardware-arm tests (stride_tests twice, synthetic_tests once) which are @⁠jujumoneylol's #2885, and cargo clippy -p victory-shader --all-targets --all-features -- -D warnings is clean.

**@⁠HoLa-Lee** on GitHub · 2026-11-26 13:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/3000#issuecomment-7194057721) Both points are in, `242a83f` (one file, +13/-0). - **`Host::draw` has the same arm**, so an empty list is now skipped there too: `SetGraphicsRoot32BitConstants` with a count of 0 and a pointer into nothing is the same shape, and the graphics tests reach it the same way. The two arms carry the same comment pointing at the other one. - **The comment no longer claims zeros.** It says what is true: a root left unset is **undefined** in D3D12, not zero, and that is harmless only because a program that declares no user data reads none of its constants. Both comments say so. Nothing else changed: `victory-shader` still stops at FIND-11's three hardware-arm tests (`stride_tests` twice, `synthetic_tests` once) which are @⁠jujumoneylol's #2885, and `cargo clippy -p victory-shader --all-targets --all-features -- -D warnings` is clean.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 14:42 UTC · original · approved these changes

Skipping SetGraphicsRoot32BitConstants and SetComputeRoot32BitConstants when Root::Constants(data) is empty (crates/victory-shader/src/emit/host.rs:1159-1164, 1922-1932) looks good. A shader that reads no user-data root constants leaves that placeholder slot unread, while avoiding passing a 0-count empty-slice pointer to the NVIDIA driver. Non-empty constant lists and all other root arguments remain unchanged, and the other Set*Root32BitConstants call site in emit/host.rs (L696) already uses .max(1).

Local verification at 242a83f6: xtask policy (191 files ok), cargo clippy -p victory-shader --all-targets (default and --all-features, 0 warnings), and emit::host under VICTORY_D3D12_DEBUG=1 passed on both RTX 5090 (1/1) and WARP (1/1). Running the full victory-shader suite under VICTORY_D3D12_DEBUG=1 matched origin/main (63bcca43) with zero regressions (299/302 on RTX 5090 and 298/302 on WARP, with the same pre-existing stride_tests / synthetic_tests failures confirmed on baseline). Approving.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 14:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/3000#pullrequestreview-6076045918) · **approved these changes** Skipping `SetGraphicsRoot32BitConstants` and `SetComputeRoot32BitConstants` when `Root::Constants(data)` is empty (`crates/victory-shader/src/emit/host.rs:1159-1164, 1922-1932`) looks good. A shader that reads no user-data root constants leaves that placeholder slot unread, while avoiding passing a 0-count empty-slice pointer to the NVIDIA driver. Non-empty constant lists and all other root arguments remain unchanged, and the other `Set*Root32BitConstants` call site in `emit/host.rs` (`L696`) already uses `.max(1)`. Local verification at `242a83f6`: `xtask policy` (`191 files ok`), `cargo clippy -p victory-shader --all-targets` (`default` and `--all-features`, 0 warnings), and `emit::host` under `VICTORY_D3D12_DEBUG=1` passed on both RTX 5090 (`1/1`) and WARP (`1/1`). Running the full `victory-shader` suite under `VICTORY_D3D12_DEBUG=1` matched `origin/main` (`63bcca43`) with zero regressions (`299/302` on RTX 5090 and `298/302` on WARP, with the same pre-existing `stride_tests` / `synthetic_tests` failures confirmed on baseline). Approving.
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/3000/head:github-bot/gh-3000'
git switch 'github-bot/gh-3000'

Merge

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