emit host: an empty root-constant list is not passed to the runtime #2998
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3000"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-26T03:00:50Z.
emit host: an empty root-constant list is not passed to the runtime
Host::dispatch(the shader crate's test host) callsSetComputeRoot32BitConstants(param, data.len(), data.as_ptr(), 0)for everyRoot::Constantsthe test asks for. A program that declares no user data - thelowering puts the heap base elsewhere - makes the test pass
vec![0u32; shader.user_data_dwords()]withuser_data_dwords() == 0, so thecall is made with a count of 0 and a pointer into an empty vector.
On an NVIDIA card that takes the process down:
It does it on every run, alone (
--exact … --test-threads=1) as well as in thesuite, 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-shadergoes unreported. Measured with markersthrough the test and through
dispatch, the last one printed is the roots loopstarting, and the arm that follows is this call:
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-shadersuite now runs on this card, and three tests thatcould never be reached before fail:
emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_strideassertion left == right failed: hardware: lane 0emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosassertion left == right failed: hardwareemit::synthetic_tests::gathers_at_a_level_match_the_hardwarehardware: 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_testsat all.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.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T03:03:09Z.
Review: APPROVED
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.
Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-26T05:04:06Z.
Review: COMMENTED
Tested
ebc57bdon an RTX 3080 (driver 617.42), Windows 10 22H2. Base ismain63bcca4with the Agility opt-in from #486, since Windows 10's in-box runtime skips the SM 6.6 tests without it.mainemit::memory_tests::heap_direct_texture_reads_mark_their_heap_indexalone0xC0000005cargo test -p victory-shader --lib -- --test-threads=1The 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_hardwareandsynthetic_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:
SetGraphicsRoot32BitConstants,emit/host.rs:1159onmain), which makes the same call with an empty list's pointer. This PR changes only the compute path.user_data_dwords().max(1),host.rs:229), and D3D12 doesn't promise zeros for a root constant that was never set afterSetComputeRootSignature. 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.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T05:27:06Z.
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 emptyRoot::Constantslist is now skipped instead of being passed toSetComputeRoot32BitConstantswith a count of 0. The PR shows that call crashing the test process on NVIDIA inmemory_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::drawmakes the sameSetGraphicsRoot32BitConstantscall without the guard. Adding the same arm there would cover graphics tests too.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
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:11:39Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):SetComputeRoot32BitConstantswhendata.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).
Imported from Marvisak/VIctory. Originally posted by HoLa-Lee on 2026-11-26T13:56:48Z.
Both points are in,
242a83f(one file, +13/-0).Host::drawhas the same arm, so an empty list is now skipped there too:SetGraphicsRoot32BitConstantswith 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.Nothing else changed:
victory-shaderstill stops at FIND-11's three hardware-arm tests (stride_teststwice,synthetic_testsonce) which are @jujumoneylol's #2885, andcargo clippy -p victory-shader --all-targets --all-features -- -D warningsis clean.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T14:42:37Z.
Review: APPROVED
Skipping
SetGraphicsRoot32BitConstantsandSetComputeRoot32BitConstantswhenRoot::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 otherSet*Root32BitConstantscall site inemit/host.rs(L696) already uses.max(1).Local verification at
242a83f6:xtask policy(191 files ok),cargo clippy -p victory-shader --all-targets(defaultand--all-features, 0 warnings), andemit::hostunderVICTORY_D3D12_DEBUG=1passed on both RTX 5090 (1/1) and WARP (1/1). Running the fullvictory-shadersuite underVICTORY_D3D12_DEBUG=1matchedorigin/main(63bcca43) with zero regressions (299/302on RTX 5090 and298/302on WARP, with the same pre-existingstride_tests/synthetic_testsfailures confirmed on baseline). Approving.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.