Repository navigation
Shaders: keep spilled compute root parameters from claiming s16+ system SGPRs - #3038
fuzeofficlal wants to merge 1 commit into
Conversation
kotekompotek
left a comment
There was a problem hiding this comment.
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.
|
VERIFY-3038: verified Review (reading). The new guard in Regression check. I put the PR's test hunk alone on
At head:
Not checked: whether any title shader is affected (no shader pack here). AI-assisted (Claude Code). |
fyernald
left a comment
There was a problem hiding this comment.
The two new tests check the translation (tracking, user_data, DXIL validation) but never run the shader, so I dispatched both of compute_group_id_in_s16_survives_spilled_root_constants's programs on an RTX 3080 (driver 617.42), Windows 10 22H2. Same NativePrograms, 8 groups, spilled constant (user_data[16]) = 1000, a 12-dword raw UAV at heap index 0. Base is main 63bcca4 + #486 (Agility opt-in). Windows 10 has no SM 6.6 WARP here, so these are hardware results only.
| program | expected UAV[0..8] | main |
this PR (aed7e97) |
|---|---|---|---|
s16 + user_data[16] |
1000, 1001, …, 1007 | all 0 | 1000, 1001, …, 1007 |
s16 alone |
0, 1, …, 7 | all 0 | 0, 1, …, 7 |
On main the "s16 alone" shader's user_data already includes {index: 16, root: Constants}, and nothing lands in the UAV. That's consistent with every group reading s16 as the spilled 1000 and storing past the buffer. With the PR, user_data has 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 full victory-shader --lib run gives 300 passed, 4 failed, 3 ignored. The 4 are the NVIDIA failures that fail on the same base without this PR (the two stride_tests heap-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.
|
Automated triage for the maintainers.
The two new tests check what should happen, not only what the code currently does: the group ID is raised as Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64:
- Diff review: Returning
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).
…om claiming s16+ system SGPRs
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)