Shaders: keep spilled compute root parameters from claiming s16+ system SGPRs #3038
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3038
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-26 04:36 UTC · original
fuzeofficlal:fix/cs-spilled-root-param-of→main· +195 −0 · 1 files · 1 commits · openSummary
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)@pawrenity on GitHub · 2026-11-26 05:04 UTC · original
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).
@Marvisak on GitHub · 2026-11-26 06:14 UTC · original
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.