Skip to content

shader: lower binary16 VOP1 logarithm, sine and cosine - #3562

Closed
lambirou wants to merge 3 commits into
R0Y00:mainfrom
lambirou:shader/f16-log-trig
Closed

lambirou wants to merge 3 commits into
R0Y00:mainfrom
lambirou:shader/f16-log-trig

Conversation

@lambirou

Copy link
Copy Markdown
Contributor

Completes the plain VOP1 f16 group. Stacked on #3557; rebase after it lands.

This adds v_log_f16, v_sin_f16 and v_cos_f16 in e32 and e64 (six reference rows):

  • log: widen the low half, evaluate log2 in binary32, narrow, then apply the RDNA 2 special results and the 73 midpoint corrections from the source half. +infinity stays +infinity, NaN/negative non-zero gives 0x7e00, either zero gives 0xfc00.
  • sin/cos: reduce the turn count with turns16, evaluate the same binary32 intrinsic as the direct compute trig_turns helper, and narrow. Sin preserves -0; infinities/NaNs map to 0x7e00; the exact zero at half a turn (sin) or a quarter turn (cos) is selected before the intrinsic.
  • f16_log_trig_result keeps the same static-result contract as P4a/P4b; the Python midpoint table is checked against the C++ table.

Tests

Limits

DPP/SDWA variants remain out of scope. Sin/cos depend on the D3D intrinsic error; fixture values stay at least 5e-5 away from a binary16 midpoint except the exact zeroes. The high half of the destination is not observed, NaN/infinity sources are refused before lowering, and there is no console measurement.

The branch includes the commits of #3542/#3549/#3556/#3557; they drop out of the diff once those land.

AI-assisted.

@lambirou
lambirou force-pushed the shader/f16-log-trig branch from f706bfd to e3a3c6e Compare November 30, 2026 09:04
@lambirou

Copy link
Copy Markdown
Contributor Author

Merged as part of #3564: that PR was squashed onto main at f0a10b12, and the logarithm/sine/cosine lowerings are in main (the squash body lists this commit). Closing this now-redundant PR. The next DPP slice is #3578.

@lambirou lambirou closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant