shader: read float inline constants on 16-bit operands as half bits #1582

Manually merged
github merged 1 commit from gh-pr/1582/head into gh-pr/1582/base 2026-11-26 10:00:46 +00:00
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 02:56 UTC · original
Nawid3333:shader/f16-inline-constants → main · +5 −3 · 1 files · 1 commits · merged 2026-10-17 03:05 UTC

The RDNA2 ISA guide gives inline floats in single, double or half precision, and for 1/(2pi) "the exact value used is: half: 0x3118". The other eight (±0.5, ±1.0, ±2.0, ±4.0) are exact halves. Read16LaneBits converted the 32-bit value at run time instead, through PackHalf2x16. The AMD driver compiles that to a round-toward-zero pack (measured in #1575), so 1/(2pi) became 0x3117, and FloatInlineConstantF16UsesNumericValue fails on both AMD GPUs here.

Change: use the half encodings directly. This is the 16-bit counterpart of #1576.

Size: in FloatInlineConstantF16UsesNumericValue (nine inline floats on 16-bit operands) the SPIR-V function body goes from 217 to 177 instructions; 9 of its 13 PackHalf2x16 are gone.

Tests

  • FloatInlineConstantF16UsesNumericValue fails before the change on the RX 9070 XT and on the Ryzen 7600X iGPU (0xbbbb3117 and 0x31173c00 instead of 0xbbbb3118 and 0x31183c00), also with the harness forced to 32-wide subgroups (a local switch). After it, it passes in all four configurations, with no validation-layer messages.
  • On both GPUs, compared with 42bb0da5: the other 711 compute-suite entries in both subgroup modes and the 30 graphics cases keep their status.
  • Fork CI (build and tests on Windows, Linux and macOS) passes.

If you'd like this done differently, tell me and I'll change it.

Written with Claude Code (AI): it wrote the change and ran the tests and measurements on my PC (driver 26.8.1, Windows 11). I reviewed the diff and this description before opening the PR.

🤖 Generated with Claude Code

**@⁠Nawid3333** on GitHub · 2026-10-17 02:56 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1582) `Nawid3333:shader/f16-inline-constants` → `main` · +5 −3 · 1 files · 1 commits · merged 2026-10-17 03:05 UTC The RDNA2 ISA guide gives inline floats in single, double or half precision, and for 1/(2*pi) "the exact value used is: half: 0x3118". The other eight (±0.5, ±1.0, ±2.0, ±4.0) are exact halves. `Read16LaneBits` converted the 32-bit value at run time instead, through `PackHalf2x16`. The AMD driver compiles that to a round-toward-zero pack (measured in #1575), so 1/(2*pi) became `0x3117`, and `FloatInlineConstantF16UsesNumericValue` fails on both AMD GPUs here. **Change:** use the half encodings directly. This is the 16-bit counterpart of #1576. **Size:** in `FloatInlineConstantF16UsesNumericValue` (nine inline floats on 16-bit operands) the SPIR-V function body goes from 217 to 177 instructions; 9 of its 13 `PackHalf2x16` are gone. **Tests** - `FloatInlineConstantF16UsesNumericValue` fails before the change on the RX 9070 XT and on the Ryzen 7600X iGPU (`0xbbbb3117` and `0x31173c00` instead of `0xbbbb3118` and `0x31183c00`), also with the harness forced to 32-wide subgroups (a local switch). After it, it passes in all four configurations, with no validation-layer messages. - On both GPUs, compared with 42bb0da5: the other 711 compute-suite entries in both subgroup modes and the 30 graphics cases keep their status. - Fork CI (build and tests on Windows, Linux and macOS) passes. If you'd like this done differently, tell me and I'll change it. Written with Claude Code (AI): it wrote the change and ran the tests and measurements on my PC (driver 26.8.1, Windows 11). I reviewed the diff and this description before opening the PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The 16-bit encodings of the float inline constants are fixed: the exact
halves of 0.5, 1.0, 2.0 and 4.0 and their negations, and 0x3118 for
1/(2*pi). Read16LaneBits converted the 32-bit value at run time instead,
through PackHalf2x16, which the AMD driver rounds toward zero, so
1/(2*pi) became 0x3117. Use the encodings directly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:00:42 +00:00
github manually merged commit d399fb8d0c into gh-pr/1582/base 2026-11-26 10:00:46 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-17 02:59 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: 567cd705-882c-4577-8ac0-f378f64eae28
📥 Commits

Reviewing files that changed from the base of the PR and between b95ea4bb5f and d399fb8d0c.

📒 Files selected for processing: 1
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

📝 Walkthrough

Read16LaneBits now derives half-precision bits directly from float inline constants. It maps 0x3e22f983 to 0x3118 and constructs other values from their encoded sign and exponent.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d399f

All reachable inline float constants retain their intended 16-bit encodings, including the corrected constant. This change presents no material merge-readiness risk; proceed with normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: reading float inline constants as half-precision bits for 16-bit operands.
Description check Passed The description directly explains the bug, the implementation change, the expected encoding, and the reported test results.
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.
  • Autofix · 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-17 02:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1582#issuecomment-6228789366) <!-- 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/1582?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `567cd705-882c-4577-8ac0-f378f64eae28` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between b95ea4bb5f28624285dfec197388921df44bf393 and d399fb8d0ce7148c9f022755e300786d0dcdf4f5. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 1</strong></summary> <dl> <dd> * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> `Read16LaneBits` now derives half-precision bits directly from float inline constants. It maps `0x3e22f983` to `0x3118` and constructs other values from their encoded sign and exponent. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"d399fb8d0ce7148c9f022755e300786d0dcdf4f5" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>d399f</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `d399f` --> <!-- final_review_risk_coverage:{"sourceCommitId":"d399fb8d0ce7148c9f022755e300786d0dcdf4f5","coveredCommitId":"d399fb8d0ce7148c9f022755e300786d0dcdf4f5","kind":"reviewed"} --> All reachable inline float constants retain their intended 16-bit encodings, including the corrected constant. This change presents no material merge-readiness risk; proceed with normal checks. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | 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 1 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------ | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: reading float inline constants as half-precision bits for 16-bit operands. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the bug, the implementation change, the expected encoding, and the reported test results. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </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">Autofix</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=1582)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [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) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.