shader: give 64-bit operands the f64 encoding of float inline constants #1219
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!1219
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1219/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?
@TheCruZ on GitHub · 2026-10-08 18:24 UTC · original
pr/inline-f64-constants→main· +44 −8 · 2 files · 1 commits · closed without mergingSummary
Float inline constants (
0.5,1.0,2.0,1/(2*pi), ...) read by a 64-bit operand of an integer B64 instruction now get their double-precision encoding, as on hardware. Found while going through the shaders of Grand Theft Auto V (PPSA04263); I have not tied a visible symptom in the game to it, it is an ISA accuracy fix.Problem
Inline constants 240-248 read by a 64-bit operand are the double-precision value for integer B64 opcodes too: LLVM encodes
s_mov_b64 s[0:1], 1.0as0x3ff0000000000000(getLit64Encodingcovers INT64 and FP64 operands alike).The f64 conversion only lived in the F64 path of
ReadOperand.ReadU32Pairreturned{f32 bits, 0}, soS_MOV_B64,S_*_B64,S_CSELECT_B64,V_LSHRREV_B64,V_CMP_*_U64andV_MAD_U64_U32got{0x3f800000, 0}instead of{0, 0x3ff00000}for1.0.Change
The conversion moves into
ReadU32Pair, so every 64-bit read (integer or float) gets the double encoding (including the special1/(2*pi)value). Wave32 lane masks are 32-bit operands, soReadMaskkeeps the single-precision word there.Testing
shader_recompiler_compute_tests: newScalarVector64BitFloatInlineConstantscase (--inline-f64-only) withs_mov_b64,s_or_b64andv_lshrrev_b64reading float inline constants. The default run andshader_cfg_testspass.AI usage
AI (Claude Opus 5.5) was used to investigate the issue and to implement the change. I reviewed the code, understand it, tested it as described above, and wrote this description myself, in general fully tested the game while doing few missions and playing in-game with my GTA V fork, i will be bringing PRs here after test them enough.
Float inline constants (240-248) read by a 64-bit operand are the double-precision value for integer B64 opcodes too; LLVM encodes s_mov_b64 s[0:1], 1.0 as 0x3ff0000000000000 (getLit64Encoding covers INT64 and FP64 operands alike). ReadU32Pair returned {f32 bits, 0}, so only the F64 ReadOperand path had the right value; S_MOV_B64, S_*_B64, S_CSELECT_B64, V_LSHRREV_B64, V_CMP_*_U64 and V_MAD_U64_U32 got {0x3f800000, 0} instead. Move the conversion into ReadU32Pair. Wave32 lane masks are 32-bit operands, so ReadMask keeps the single-precision word there. Test: --inline-f64-only (ScalarVector64BitFloatInlineConstants).@coderabbitai[bot] on GitHub · 2026-10-08 18:31 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
9d2b01a3-9381-4bb2-b6ad-74b3e5137076📥 Commits
Reviewing files that changed from the base of the PR and between
2f4b8a335dand6ed17df006.📒 Files selected for processing (2)
src/graphics/shader/recompiler/frontend/translate/Translate.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
Walkthrough
Float inline constants now convert to double-precision bits in
ReadU32Pair.ReadMaskhandles immediate operands as a single 32-bit value for wave32 and as a 64-bit pair for wave64. A new compute test checks float inline constants in scalar and vector 64-bit operations. The test is registered and can run through the--inline-f64-onlyselector.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
6ed17The translation preserves wave32 mask behavior while supplying the intended 64-bit inline-constant patterns; no concrete user-facing regression is indicated.
🚥 Pre-merge checks | ✅ 4 | ❓ 1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. (1 skipped: 1 too large.)
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.Pull request closed