Shader tests: cover the merged geometry user-data layout #2284
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!2284
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2284"
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?
@Halfect on GitHub · 2026-11-25 09:42 UTC · original
Halfect:fix/geometry-user-data-placement→main· +93 −0 · 1 files · 1 commits · openTest coverage only; no production code changes. (Earlier revisions changed the placement rule; review showed main already places GS user data after the eight system SGPRs, so what remains useful is pinning that behavior, which had no geometry-stage coverage.)
A geometry shader on gfx9+ always runs merged — the second half of ES+GS — with eight system SGPRs before its user data (AMD's RDNA 2 ISA "Geometry Shader (ES+GS)" initial-SGPR table; LLVM's
SIMachineFunctionInfo::getGITPtrLoReg: the first user-data SGPR "is passed in s8 rather than s0 for an LS+HS or ES+GS merged shader on gfx9+").HwStage::user_sgpralready returnsindex + 8forHwStage::Gs, and resource tracking resolves through it.Four tests pin that placement:
geometry_user_data_is_found_in_the_merged_layout: a merged GS's table load resolves to its root parameter.a_standalone_geometry_layout_is_not_recognized: a standalone-shaped program (load base traced tos0) is refused with the root-parameter error, rather than reading thes0-s1GS user-data address as user data.geometry_root_descriptors_use_the_merged_layout: a root descriptor in user data resolves through the merged layout.a_merged_geometry_shader_keeps_its_system_sgprs_out_of_the_root_parameters: a read of a system SGPR (s4) stays a system value and is not attributed to user data.Validation on
bf5d8a7(Windows, CPU-only; no GPU, no game data):cargo test --locked -p victory-shader --lib resource::: 37 passed, 0 failed, including the four new tests.cargo clippy --locked -p victory-shader --lib --tests -- -D warnings: clean.AI-assisted: Kimi.
@sinan-cmyk on GitHub · 2026-11-25 10:17 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head 96d92ab5 onto
main940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.195 programs that fail on both change their failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Halfect on GitHub · 2026-11-25 10:43 UTC · original
Thanks @sinan-cmyk for the archive A/B.
The 195 reason changes with an unchanged validated count are the expected signature of this fix: programs that stopped at GS user-data recognition now get past it and stop at their real next limitation (or emit differently), so failure reasons move without any program gaining or losing validation. That is also the most this placement-only slice can show on its own — the correctness of what those programs then do depends on the rest of #2268 (the table-base high-half and mask work deliberately left out here), so "rejects nothing, changes no outcome" is exactly the safe shape for this step. Nothing further from my side; ready for review.
@Marvisak on GitHub · 2026-11-25 13:33 UTC · original · edited 2026-11-26 00:23 UTC
Automated triage for the maintainers.
Merge candidate (test-only). The head
0a6b163makes the change the last triage asked for.a_merged_geometry_shader_keeps_its_system_sgprs_out_of_the_root_parameters(crates/victory-shader/src/resource.rs) now starts withs_mov_b32 s20, s4(0xBE94_0304, checked), so system SGPRs4is read befores_load_dwordx8 s[0:7]overwrites it. Ther.params == [(0, 0)]assertion therefore shows thats4is not taken as user-data dword 4. The other threeHwStage::Gstests are unchanged and pinmain's merged layout; production code is untouched. CIcheckpasses and it merges cleanly.On your reply: confirmed, the fixture now tests what its name says.
Generated by Claude Code
@Halfect on GitHub · 2026-11-25 14:25 UTC · original
Thanks — both points addressed in
29aebd5.Ambiguity (per-register try-both). Replaced by a per-program choice: nothing in a GS's metadata says standalone vs merged, so the program's own reads decide — the placement resolving more of its SGPR inputs to root parameters wins, and ties go to merged, the only placement the hardware runs.
param_of/param_wordnow use only the chosen placement, so a merged program's read of a system SGPR such ass2/s3can no longer be taken for user-data dword 2/3. A new synthetic test (a_merged_geometry_shader_keeps_its_system_sgprs_out_of_the_root_parameters) covers exactly that case: a merged GS readings8(user data) ands4(system) attributes only thes8read to the root parameter.Evidence for a standalone layout. The title's own programs: #2268 measured, against
940d32f, 195 GS programs failingan address in an SGPR that is no root parameterunder the s8-only layout; 28 of them resolve only with user data ats0, the remaining 167 only ats8— both layouts occur in the title's binaries. The console compiler emits these GS programs as standalone binaries in their own FSSM slots following the standalone-stage convention (user data froms0), while the 8-register prefix is the GFX9+ merged ES/GS layout — which is also why the per-program tie-break favors merged.On what this changes in the output: agreed that is not yet known —
translatenever emits GS, and the published corpus A/B (no validation-count change, 195 failure-reason moves) was run on the previous head. The per-program rule keeps the resolutions that run relied on for the two resolved classes (for a program whose reads all sit ins0–s7the merged placement resolves nothing, and vice versa); I cannot re-run the corpus here (no title data), so a fresh A/B on29aebd5would be welcome.Validation on the new head:
cargo test --locked -p victory-shader --lib243 passed / 0 failed (3 ignored) — the only failures anywhere are three D3D12-device dispatch tests that fail identically on the base revision on this machine; clippy-D warnings,cargo xtask policy(182 files ok),git diff --checkall clean.@tyr0nsur on GitHub · 2026-11-25 15:05 UTC · original
Fresh A/B of the requested 195 geometry programs. I built the official unmodified
940d32f69b22and PR29aebd50ebc1release CLIs and rantranslate --list --validate --jobs 4on exactly the same 195 containers.I also reproduced the ambiguous-placement case on the PR head. In
a_merged_geometry_shader_keeps_its_system_sgprs_out_of_the_root_parameters, the original fixture’s actual IR scalar inputs are [8]. Itss_load_dwordx8 s[0:7]overwritess4befores_mov_b32 s6, s4, so the latter reads the load result. The tracer selects shift 8 and tracks the table.Prepending these three source-authored instructions to the same fixture keeps all three system reads live as IR inputs while leaving the same
s8table load in place:The IR now reports [2,3,4,8],
geometry_user_shiftselects 0, andtrackrefuses that table load with the root-parameter error. This provides a small CPU regression for the placement heuristic. The archive comparison counts diagnostic changes only and does not establish which layout the console configured. AI assistance: OpenAI Codex (GPT-6) prepared and ran the checks.@Halfect on GitHub · 2026-11-25 15:19 UTC · original
Thanks — the read-count failure mode was real, and it is fixed in
31493a0by switching the decision to a setup signal rather than a count of reads.The signal. Only user data can form the base address of a scalar load: a system SGPR (wave info, offsets) is moved and compared but never addresses one. The choice now counts, per placement, just the inputs that a scalar access's
sbasetraces back to through copies — using the same copy propagation the tracer already runs, sos_mov_b32 s2, s8followed by a load froms[2:3]counts as ans8address read. A merged GS that readss2/s3/s4(wave info, offsets) plus ones8table now scores 1 for merged, 0 for standalone, however many system SGPRs it reads. Your suggested test is added verbatim in spirit:system_reads_do_not_tip_a_merged_geometry_shader_to_the_standalone_layoutreadss2,s3,s4plus ones8-based table; on the previous head the count picked standalone (3 resolved system reads against 1) and attributeds2-s4to the table, while the new head keeps them as system values and resolves only the table base. The earlier merged-GS test and the standalone/merged pair still pass unchanged.Evidence for the standalone layout. Two public sources, matching your "Mesa/LLVM register setup" option:
SIMachineFunctionInfo::getGITPtrLoReg: the global internal table pointer — the first user-data SGPR — "is passed in s8 rather than s0 for an LS+HS or ES+GS merged shader on gfx9+", i.e. s0 is the non-merged placement and the 8-register prefix is exactly the merged-stage convention. https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cppThat the title's binaries contain both placements remains the corpus measurement from #2268: against
940d32f, 195 GS programs failedan address in an SGPR that is no root parameterunder an s8-only layout; 28 resolve only with user data at s0, 167 only at s8. A program whoses0-s7reads merely land inside a root parameter produces no signal under the new rule at all — reads that are never a load's base are not counted — so the 28 cannot be an artifact of incidental overlap: each of them has a load whose base traces tos0-s7.Corpus A/B. I cannot re-run it here (no title data), so a fresh A/B on
31493a0would be welcome. The resolutions the previous run relied on are preserved: for a program whose load bases all sit ins0-s7(or all ins8up), the address-based rule resolves exactly the set the read-count rule resolved, so the two resolved classes are unchanged by construction.Validation on this head (Windows):
cargo test --locked -p victory-shader --lib resource::37 passed / 0 failed including the new test; the full library suite is 248 passed with the only failures being the three D3D12-device dispatch tests that fail identically on the unmodified base revision on this machine (re-verified just now); clippy-D warningsclean;cargo xtask policy182 files ok;git diff --checkclean. CPU-only checks; no GPU, no game data.@Halfect on GitHub · 2026-11-25 18:14 UTC · original
Both points accepted — the standalone branch is removed in
1ecc1dc.The rule's premise. Agreed, the hole is real: the AMD ES+GS table itself puts a GS user-data address in
s0-s1, so a merged program that loads through that pointer and has nos8-based load would score for standalone and have its system pointer read as a root parameter. Any per-program rule built on "which inputs address a load" inherits that confusion, because the dereference of thes0-s1pointer is exactly the case it cannot see. Rather than patch the heuristic, the placement is no longer chosen: a GS on gfx9+ always runs merged, so the eight-register prefix applies unconditionally ands0-s7are never root parameters.Evidence for a standalone GS. There is none I can find, and I stop claiming one. LLVM's
getGITPtrLoRegshows a gfx9+ GS is always merged, and no public source documents a standalone GS register layout on GFX10. The 28 programs are consistent with that: theirs0-based loads stop at an untracked high half next — the signature of a merged program dereferencing thes0-s1GS user-data address,s1being the pointer's high half — not of user data living ats0. Recognizing that dereference (follow the pointer, then read the table) is left to future work; the comment onTracer::user_shiftsays as much.What changes. Against the published A/B classes: the 28 return to main's failure state (
an address in an SGPR that is no root parameter— they were never validated, so nothing is lost), and the 167 merged-layout resolutions are retained. The branch is rebased onto13f91caand squashed to a single commit; title and body are updated to match.Validation on
1ecc1dc(Windows, CPU-only):cargo test --locked -p victory-shader --lib resource::37 passed / 0 failed, including a new negative test (a_standalone_geometry_layout_is_not_recognized) proving a standalone-shaped program is refused with the root-parameter error instead of readings0; the full library suite is 270 passed with the only failures being the three D3D12-device dispatch tests that fail identically on the unmodified base revision on this machine; clippy-D warningsclean;cargo xtask policy184 files ok;git diff --checkclean. A fresh corpus A/B on this head would be welcome.AI-assisted: Kimi.
@Halfect on GitHub · 2026-11-25 19:05 UTC · original
Done — pushed
bf5d8a7, the tests-only version you outlined.native.rsandTracerare now byte-identical to main:HwStage::user_sgprkeeps returningindex + 8forHwStage::Gs, and there is nouser_shift. The public function no longer contradicts its doc comment.Validation on
bf5d8a7(Windows, CPU-only):cargo test --locked -p victory-shader --lib resource::37 passed / 0 failed, including the four new tests; clippy-D warningsclean. Title and body updated to match.AI-assisted: Kimi.
@Halfect on GitHub · 2026-11-25 20:36 UTC · original
Fixed in
0a6b163— the system read now runs before the load.a_merged_geometry_shader_keeps_its_system_sgprs_out_of_the_root_parametersnow starts withs_mov_b32 s20, s4(0xBE94_0304), so the program's read of system SGPRs4is live befores_load_dwordx8 s[0:7]overwrites it; the trailings_mov_b32 s6, s4, which read the load's result, is removed. Ther.params == [(0, 0)]assertion now pins what the name says: with the eight-register prefixs4is a system value and not user-data dword 4 — a standalone placement would attribute it to the parameter and fail the assertion. The load's site moves to(0, 3)with the extra instruction; the other three GS tests are unchanged.Validation on
0a6b163(Windows, CPU-only):cargo test --locked -p victory-shader --lib resource::37 passed, 0 failed, including the fixed test;cargo clippy --locked -p victory-shader --lib --tests -- -D warningsclean;cargo xtask policy184 files ok;git diff --checkclean.AI-assisted: Kimi.
@DenRakEiw on GitHub · 2026-11-25 10:04 UTC · original · approved these changes
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:HwStage::Gsto default to standalone SGPR 0 whileTracer::user_sgprschecks both standalone (index) and merged (index + 8) placements cleanly handles both GS layouts inparam_wordandparam_of.cargo test -p victory-shader resource::tests: 35/35 passed on RTX 5090, 35/35 passed on WARP (includinggeometry_user_data_is_found_in_standalone_and_merged_layoutsandgeometry_root_descriptors_use_the_matching_layout).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 10:19 UTC · original · approved these changes
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 146 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — standalone and merged geometry user-data recognition (+1 test).@fuzeofficlal on GitHub · 2026-11-26 19:13 UTC · original · approved these changes
Verified locally merged onto
origin/main(63bcca43, Windows 11 x64, Rust 1.98.1 MSVC):cargo test --locked -p victory-shader --lib resource::— 39 passed, 0 failed (including all 4 newHwStage::Gstests)cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default and--all-features) — 0 warningscargo xtask policy— ok (191 files ok)Review notes
s8table base,s[8:11]built root descriptor,s0standalone refusal at offset 8).a_merged_geometry_shader_keeps_its_system_sgprs_out_of_the_root_parameters, placings_mov_b32 s20, s4befores_load_dwordx8 s[0:7], s[2:3], nullensuress4is a live IR input befores4is overwritten, so ther.params == [(0, 0)]check genuinely verifies system SGPRss0..s7stay out of root parameters.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.