Shaders: keep spilled compute root parameters from claiming s16+ system SGPRs #3036
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3038"
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 fuzeofficlal on 2026-11-26T04:36:32Z.
Summary
In compute shaders (
HwStage::Cs), hardware provides at most 16 user SGPRs (s0..s15); root parameters withuser_data >= 16spill to memory (loaded vias[0:1]), whiles16+hold system inputs (SV_GroupID,GroupInfo).spill_loads,spilled_param, andparam_wordincrates/victory-shader/src/resource.rsalready excludeuser_data >= 16forHwStage::Cs, butTracer::param_ofdid not:When a compute shader has any spilled root parameter (
user_data >= 16) and readss16+,Tracer::param_offalsely maps the system SGPR to that spilled root parameter. Depending on hows16+is used, this either:Lower::inputs/Lower::getto replaceSV_GroupIDwithuser_data[16+], ors_load/global_loadindexed bySV_GroupID) with"an offset from a root parameter".Fix
Noneearly inTracer::param_ofwhenself.stage == HwStage::Cs && code >= 16.crates/victory-shader/src/resource.rs:compute_spilled_params_do_not_claim_system_sgprs: verifiestrack()acceptss16as a dynamics_loadoffset alongside a spilled root parameter atuser_data = 16, without mappings16intor.params.compute_group_id_in_s16_survives_spilled_root_constants: verifies fullemit()+ DXIL validation keepss16lowered asInput::GroupId(0)and never pulls spilleduser_data[16]intoshader.user_dataunless loaded froms[0:1].Verification
cargo test --locked -p victory-shader --lib resource::tests(37 passed)cargo test --locked -p victory-shader --test resource_tracking(3 passed)cargo clippy --locked -p victory-shader --all-targets -- -D warnings(clean)cargo xtask policy(191 files ok)Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-26T04:40:53Z.
Review: APPROVED
LGTM — correct hardware fact (CS user data ends at s15; s16+ are system inputs). The test is precise: s16 stays unmapped while the spilled param still resolves through its memory load.
Imported from Marvisak/VIctory. Originally posted by pawrenity on 2026-11-26T05:04:07Z.
VERIFY-3038: verified
aed7e97on NVIDIA GeForce RTX 4070, Windows 11 (plus WARP where the tests use it).Review (reading). The new guard in
Tracer::param_of(crates/victory-shader/src/resource.rs:635) makes it agree with the three compute-spill paths beside it:spill_loads,spilled_paramandparam_wordalready treatuser_data >= 16onHwStage::Csas memory reached throughs[0:1], never as SGPRs. Without the guard, aCsparameter atuser_data >= 16matcheds16+becauseHwStage::Cs.user_sgpr(i) == i.track()(line 172) andparam_value(line 528) are its only callers, and both now leaves16+to the system inputs (ComputeIo::system_sgprs). I found no defects.Regression check. I put the PR's test hunk alone on
origin/main63bcca4, with the 6-line guard taken out. Both new tests fail for the reasons the description gives:compute_spilled_params_do_not_claim_system_sgprs:trackreturnsUnsupported { what: "an offset from a root parameter" }compute_group_id_in_s16_survives_spilled_root_constants: panics on "s16 must not be claimed by the spilled root constant"At head:
cargo test --locked -p victory-shader --lib resource::: 37 passed, 0 failed. Both new tests pass, including their DXIL validation step (dxil.dllfrom Windows Kits 10.0.26100.0).cargo test --locked -p victory-shader --test resource_tracking: 3 passed, 1 ignored.cargo test --locked -p victory-shader --lib(one test skipped because it crashes the process on NVIDIA): 300 passed, 3 failed. The 3 (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) also fail on main on this card.cargo clippy --locked -p victory-shader --all-targets -- -D warnings: clean.origin/main63bcca4is clean.Not checked: whether any title shader is affected (no shader pack here).
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by fyernald on 2026-11-26T05:13:10Z.
Review: APPROVED
The two new tests check the translation (tracking,
user_data, DXIL validation) but never run the shader, so I dispatched both ofcompute_group_id_in_s16_survives_spilled_root_constants's programs on an RTX 3080 (driver 617.42), Windows 10 22H2. SameNativePrograms, 8 groups, spilled constant (user_data[16]) = 1000, a 12-dword raw UAV at heap index 0. Base ismain63bcca4+ #486 (Agility opt-in). Windows 10 has no SM 6.6 WARP here, so these are hardware results only.mainaed7e97)s16 + user_data[16]s16aloneOn
mainthe "s16 alone" shader'suser_dataalready includes{index: 16, root: Constants}, and nothing lands in the UAV. That's consistent with every group readings16as the spilled 1000 and storing past the buffer. With the PR,user_datahas only the table and each group writes its own id.Also on the PR, with #2596 so the suite gets past the #2571 crash:
resource::37 passed, and the fullvictory-shader --librun gives 300 passed, 4 failed, 3 ignored. The 4 are the NVIDIA failures that fail on the same base without this PR (the twostride_testsheap-buffer tests,gathers_at_a_level_match_the_hardware,pops_wait_loop_exits_immediately_for_inactive_lanes). The extra 2 passes are your new tests.A dispatch like this might be worth keeping in the test, since it's the only thing that checks the group id reaches the shader.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T06:47:42Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:NonefromTracer::param_ofwhenself.stage == HwStage::Cs && code >= 16ensures spilled compute root parameters (user_data >= 16) never falsely claims16+system SGPRs (SV_GroupID, group info).cargo test -p victory-shader resource::tests: 37 passed, 0 failed (includingcompute_spilled_params_do_not_claim_system_sgprsandcompute_group_id_in_s16_survives_spilled_root_constants).cargo test -p victory-shader --test resource_tracking: 3 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 Marvisak on 2026-11-26T06:14:19Z.
Automated triage for the maintainers.
Tracer::param_ofincrates/victory-shader/src/resource.rsnow returnsNonefors16+onHwStage::Cs. This makes it agree with whatmainalready does for compute programs inspill_loads,spilled_paramandparam_word: parameters atuser_data >= 16are read from memory throughs[0:1], never from SGPRs. Without the guard,HwStage::Cs.user_sgpr(i) == ilet a spilled parameter claim a system SGPR such as the group ID thatComputeIo::system_sgprsplaces after the user SGPRs. I checkedparam_of's callers (trackandparam_value). Both now leaves16+to the system inputs.The two new tests check what should happen, not only what the code currently does: the group ID is raised as
Input::GroupId(0), anduser_data[16]appears only when it is loaded throughs[0:1]. I found no repo-rule issues. CI:checkpassing.Generated by Claude Code
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.