shader: read float inline constants on 16-bit operands as half bits #1582
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!1582
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1582/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?
@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 UTCThe 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.
Read16LaneBitsconverted the 32-bit value at run time instead, throughPackHalf2x16. The AMD driver compiles that to a round-toward-zero pack (measured in #1575), so 1/(2pi) became0x3117, andFloatInlineConstantF16UsesNumericValuefails 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 13PackHalf2x16are gone.Tests
FloatInlineConstantF16UsesNumericValuefails before the change on the RX 9070 XT and on the Ryzen 7600X iGPU (0xbbbb3117and0x31173c00instead of0xbbbb3118and0x31183c00), 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.42bb0da5: the other 711 compute-suite entries in both subgroup modes and the 30 graphics cases keep their status.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
@coderabbitai[bot] on GitHub · 2026-10-17 02:59 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
567cd705-882c-4577-8ac0-f378f64eae28📥 Commits
Reviewing files that changed from the base of the PR and between
b95ea4bb5fandd399fb8d0c.📒 Files selected for processing: 1
src/graphics/shader/recompiler/frontend/translate/Translate.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
📝 Walkthrough
Read16LaneBitsnow derives half-precision bits directly from float inline constants. It maps0x3e22f983to0x3118and constructs other values from their encoded sign and exponent.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
d399fAll 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:
4 ·
1
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.