shader: decode trap temporaries as extended scalar registers #1687
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1687
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1687/head"
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?
@theantipopau on GitHub · 2026-10-19 03:13 UTC · original
theantipopau:shader/ttmp-scalar-regs→main· +178 −11 · 6 files · 6 commits · closed without mergingFixes the Yumia abort in #1627 (follow-up after #1683/#1684): the game reads TTMP3 (scalar source operand 0x73), which hit EXIT in DecodeScalarSource.\n\nTrap temporaries (TTMP0-11, operand codes 112-123) are wavefront-persistent scratch like SGPRs, so they decode into the scalar slots right past the SGPR file (NumScalarRegs 106 -> 118). All range checks keyed off NumScalarRegs grow automatically; the s105+1 VCC crossover for plain SGPRs is preserved, and ReadScalarCode maps hardware codes 112-123 explicitly. Disassembly prints them as ttmpN.\n\nAdds TestNewShaderRecompilerTrapTemporaries (decode + SPIR-V validation). Local syntax-check of both source TUs with g++ is clean; full build/tests rely on CI (local cmake configure cannot fetch FFmpeg in this environment).
@coderabbitai[bot] on GitHub · 2026-10-19 03:19 UTC · original · edited 2026-10-20 11:59 UTC
📝 Walkthrough
The shader recompiler now defines 106 SGPRs and 16 trap-temporary registers. The decoder maps operand codes 108–123 to trap-temporary scalar sources and destinations and formats them as TTMP registers. The translator, control-flow analysis, and scalar-state tracking preserve distinct trap-temporary and VCC mappings. Regression tests cover TTMP mappings, liveness, 64-bit transfers, and SPIR-V validation.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
01239No demonstrated behavior defect blocks merging. Adding the VCC interleave would strengthen regression coverage.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 5 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-19 03:24 UTC · original · reviewed
🧹 Nitpick comments: 1
ℹ️ Review info
⚙️ Run configuration
a90efc8a-476b-4b8a-8922-661c0eb619f1📥 Commits
Reviewing files that changed from the base of the PR and between
099de8dea6and 0f756cf06cc7d09ad81b335780e24ac7a19062ea.📒 Files selected for processing: 4
src/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.cppsrc/graphics/shader/recompiler/ir/Reg.htests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@theantipopau on GitHub · 2026-10-20 00:43 UTC · original
Note on the current CI failure: it is not from this PR. Upstream main went red at
742fe171when #1726 merged — controller.cpp calls PadVrPortHand/PadVrPort/PadVrClose, which controller_settings_tests doesn't link (undefined references, Linux + macOS). Main-branch run for742fe171fails the same way. Fix is in #1741 (stub the VR ports in the test, matching its existing fake convention); once that merges, this PR's checks should go green on a re-run.@coderabbitai[bot] on GitHub · 2026-10-20 03:14 UTC · original · reviewed
🧹 Nitpick comments: 1
ℹ️ Review info
⚙️ Run configuration
28af1de9-8ddc-4f84-8dd2-34da572a5977📥 Commits
Reviewing files that changed from the base of the PR and between
55fa638e61and0123990fbe.📒 Files selected for processing: 3
src/graphics/shader/recompiler/ShaderRecompiler.cppsrc/graphics/shader/recompiler/frontend/cfg/ShaderCFG.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@theantipopau on GitHub · 2026-10-20 08:34 UTC · original
Response to the two CodeRabbit nitpicks on the TTMP tests:
Keep the TTMP result live (review 2026-10-19): already addressed by later commits. The fixtures now chain the TTMP-fed values into observable adds (
s3, s2, s1/s4, s2, s3) with IR checks on the chained op plus SPIR-V validation, so a wrong-register translation cannot pass. No further change needed.Exercise the TTMP0/VCC collision (review 2026-10-20): valid and still open — the
boundsfixture writes/readsttmp0but never touchesVCC, so it proves TTMP0 lowers throughs106but does not prove VCC state stays distinct. The production fix (track by hardware scalar code,ScalarSlotToCode/ScalarOperandCode) is covered indirectly, but an interleaved VCC write/read with separate assertions would make the regression explicit. Happy to add that as a follow-up here if you want it in this PR.@theantipopau on GitHub · 2026-10-20 11:59 UTC · original
Follow-up: the interleaved VCC regression test is now on this branch (
7025cb2f).Added a
vcc_collisionfixture toTestNewShaderRecompilerTrapTemporariesin tests/shaderCfgTests.cpp:s_add_u32 vcc_lowrite/read interleaved between the TTMP0 write and read. It asserts TTMP traffic lowers through scalar slots106while VCC traffic lowers throughvcc_lo(ScalarAddCarryU32 vcc_lo, s0, s1/ScalarAddCarryU32 s3, vcc_lo, s1), plus decoded-text checks and SPIR-V validation.Verification notes: I could not execute
shader_cfg_testslocally — that target is EXCLUDE_FROM_ALL and not built by any CI job, and this machine's only toolchain (MinGW GCC 16.1) fails on pre-existing issues unrelated to this change (Vulkan-Hppvk::Extent3Dbraced-init ambiguity, OpenXR-Werror=undef; MSVC is rejected by the build as unsupported and no clang is installed). What I did verify: the MinGW compile of the test TU reports no errors in the added line range; every assertion string mirrors a form already proven by neighboring passing asserts (TTMP bounds fixture fors106, RDNA2 scalar-opcode test for post-SSAvcc_lodst/src positions); and the VCC Get/Set ops are consumed by SsaRewrite before the SPIR-V emitter (whose Get/Set handlers are unreachable), matching the existing VCC tests that validate SPIR-V. Worth a run on a working toolchain before merge.@Nmzik on GitHub · 2026-10-20 13:46 UTC · original
Not confirmed bug
Pull request closed