shader: give 64-bit operands the f64 encoding of float inline constants #1219

Closed
github-bot wants to merge 1 commit from gh-pr/1219/head into gh-pr/1219/base
Owner

@⁠TheCruZ on GitHub · 2026-10-08 18:24 UTC · original
pr/inline-f64-constants → main · +44 −8 · 2 files · 1 commits · closed without merging

Summary

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.0 as 0x3ff0000000000000 (getLit64Encoding covers INT64 and FP64 operands alike).

The f64 conversion only lived in the F64 path of ReadOperand. ReadU32Pair returned {f32 bits, 0}, so S_MOV_B64, S_*_B64, S_CSELECT_B64, V_LSHRREV_B64, V_CMP_*_U64 and V_MAD_U64_U32 got {0x3f800000, 0} instead of {0, 0x3ff00000} for 1.0.

Change

The conversion moves into ReadU32Pair, so every 64-bit read (integer or float) gets the double encoding (including the special 1/(2*pi) value). Wave32 lane masks are 32-bit operands, so ReadMask keeps the single-precision word there.

Testing

  • Grand Theft Auto V (PPSA04263): played in my fork with this change, no regressions seen.
  • shader_recompiler_compute_tests: new ScalarVector64BitFloatInlineConstants case (--inline-f64-only) with s_mov_b64, s_or_b64 and v_lshrrev_b64 reading float inline constants. The default run and shader_cfg_tests pass.
  • Tested on Windows 11 with AMD Ryzen 5900x and RTX 3090.

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.

**@⁠TheCruZ** on GitHub · 2026-10-08 18:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1219) `pr/inline-f64-constants` → `main` · +44 −8 · 2 files · 1 commits · closed without merging ## Summary 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.0` as `0x3ff0000000000000` (`getLit64Encoding` covers INT64 and FP64 operands alike). The f64 conversion only lived in the F64 path of `ReadOperand`. `ReadU32Pair` returned `{f32 bits, 0}`, so `S_MOV_B64`, `S_*_B64`, `S_CSELECT_B64`, `V_LSHRREV_B64`, `V_CMP_*_U64` and `V_MAD_U64_U32` got `{0x3f800000, 0}` instead of `{0, 0x3ff00000}` for `1.0`. ## Change The conversion moves into `ReadU32Pair`, so every 64-bit read (integer or float) gets the double encoding (including the special `1/(2*pi)` value). Wave32 lane masks are 32-bit operands, so `ReadMask` keeps the single-precision word there. ## Testing - Grand Theft Auto V (PPSA04263): played in my fork with this change, no regressions seen. - `shader_recompiler_compute_tests`: new `ScalarVector64BitFloatInlineConstants` case (`--inline-f64-only`) with `s_mov_b64`, `s_or_b64` and `v_lshrrev_b64` reading float inline constants. The default run and `shader_cfg_tests` pass. - Tested on Windows 11 with AMD Ryzen 5900x and RTX 3090. ## 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](https://github.com/TheCruZ/KytyPS5-GTA), 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).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:48:33 +00:00
github-bot closed this pull request 2026-11-26 09:48:33 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 18:31 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d2b01a3-9381-4bb2-b6ad-74b3e5137076
📥 Commits

Reviewing files that changed from the base of the PR and between 2f4b8a335d and 6ed17df006.

📒 Files selected for processing (2)
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included 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. ReadMask handles 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-only selector.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 6ed17

The 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)

Check name Status Explanation Resolution
Docstring Coverage ❓ Inconclusive 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately explains the 64-bit inline-constant encoding fix, the affected code paths, and the reported tests.
Title check ✅ Passed The title clearly and concisely states the main change: applying f64 encoding to float inline constants used by 64-bit operands.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
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.)

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 18:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1219#issuecomment-6066484314) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1219?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `9d2b01a3-9381-4bb2-b6ad-74b3e5137076` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 2f4b8a335d5e27a5153bdea670bd877a061e37b1 and 6ed17df0060e21e46b4bad8064bea8f54de1052e. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough Float inline constants now convert to double-precision bits in `ReadU32Pair`. `ReadMask` handles 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-only` selector. **Suggested reviewers:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"6ed17df0060e21e46b4bad8064bea8f54de1052e" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `6ed17` <!-- final_review_risk_coverage:{"sourceCommitId":"6ed17df0060e21e46b4bad8064bea8f54de1052e","coveredCommitId":"6ed17df0060e21e46b4bad8064bea8f54de1052e","kind":"reviewed"} --> The translation preserves wave32 mask behavior while supplying the intended 64-bit inline-constant patterns; no concrete user-facing regression is indicated. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❓ 1</summary> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :---------------- | :------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ❓ Inconclusive | 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 … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------ | :------- | :------------------------------------------------------------------------------------------------------------------------------- | | Description check | ✅ Passed | The description accurately explains the 64-bit inline-constant encoding fix, the affected code paths, and the reported tests. | | Title check | ✅ Passed | The title clearly and concisely states the main change: applying f64 encoding to float inline constants used by 64-bit operands. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> <details> <summary>Full details: Docstring Coverage</summary> **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.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1219)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.