shader: implement V_SIN_F16 #399
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!399
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/399/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?
@MehmetCambaz on GitHub · 2026-08-29 15:07 UTC · original
MehmetCambaz:feat/vop1-sin-cos-f16→main· +99 −15 · 7 files · 1 commits · merged 2026-08-29 21:32 UTCSummary
Rebased onto
1a87cfe, which implemented V_COS_F16. This now adds only its sibling, V_SIN_F16 (VOP1 0x60), still missing from the decode tables — a shader using half precision sine fails to decode. Reported against #281.Follows the shape of V_COS_F16: entries in the VOP1 and VOP3-encoded VOP1 tables, an SDWA rule, and a translator that widens to f32 and back.
The half-cycle results are architecturally exact zero. Evaluating sin(pi) with a rounded F32 PI lands on a half-precision subnormal (0x8001) instead, so the two crossings are selected back to zero — the same correction V_COS_F16 applies at its quarter cycles. An infinite source produces the invalid result rather than a NaN bit pattern.
Checking the fraction rather than the source also covers negatives, since fract(-0.5) = 0.5.
Encoding cross-checked against LLVM's AMDGPU backend:
defm V_SIN_F16 : VOP1_Real_gfx10<0x060>;
defm V_COS_F16 : VOP1_Real_gfx10<0x061>;
Test plan
Windows 11 25H2, clang-cl 20.1.8, RTX 2060. New VectorSinF16 case in ShaderRecompilerComputeTests, executed on the GPU.
ctest: 35/35.
Covers sin(0) = 0, sin(0.5 rev) = 0 exactly, sin(0.25 rev) = 1, sin(-0.25 rev) = -1.
sin(0.5 rev) is the case that matters: it returns 0x8001 without the exactness correction and 0x0000 with it, so the test fails if that handling is removed. Verified by taking the select out and re-running.
The negative source covers the sign path, and sin(0.25 rev) = 1 confirms the revolutions-to-radians conversion, which would give 0.247 if the source were treated as radians.
I do not have the reporting title, so I cannot say how much further DRAGON QUEST VII gets — this removes one decode failure and nothing more is claimed.
AI use
Written with AI assistance (Claude). It traced the decode and translate paths, mirrored the V_COS_F16 structure, and ran the builds, GPU runs and the removal check above on my machine. I reviewed the diff and confirmed the opcode against the LLVM definitions.
@MehmetCambaz on GitHub · 2026-08-29 15:29 UTC · original
After this PR you implemented a similar solution :)
@Jeffslash666 on GitHub · 2026-08-29 23:40 UTC · original
I retested Dragon Quest VII, and now it gets past the logo screen and into the game, but there is no sound and some textures are missing; I will update the information regarding the game's issues later. In any case, it was a huge step forward! S2
@MehmetCambaz on GitHub · 2026-08-29 23:43 UTC · original
Heyy that's some good news! We will get there one step at a time :)