shader: lower binary16 VOP1 logarithm, sine and cosine #3564

Closed
github-bot wants to merge 3 commits from github-bot/gh-3562 into main AGit
Owner

@⁠lambirou on GitHub · 2026-11-30 07:00 UTC · original
lambirou:shader/f16-log-trig → main · +1353 −28 · 7 files · 3 commits · closed without merging

Completes the plain VOP1 f16 group. Stacked on #3559; 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

  • Direct draw-f16-log-trig passes on WARP and on the AMD RX 9060 XT.
  • Five mutations report mismatch: cycled operation, high-half source read, a midpoint shifted by one ULP, log2 replaced by ln, and removed exact zeroes.
  • tests/form_coverage_check.py passes, including check_f16_log_trig_forms; rdna2_tools_check.py reports 159 tests and 19 LLVM_LIB skips.
  • Expected full table after #3551/#3556/#3557 and this PR: 1,556/1,968 gfx1013 and 1,547/1,863 gfx1030. The complete 196-entry replay was not finished; the six forms are checked by the targeted test and coverage assertions.

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 #3544/#3549/#3556/#3557; they drop out of the diff once those land.

AI-assisted.

**@⁠lambirou** on GitHub · 2026-11-30 07:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3562) `lambirou:shader/f16-log-trig` → `main` · +1353 −28 · 7 files · 3 commits · closed without merging Completes the plain VOP1 f16 group. Stacked on #3559; 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 - Direct `draw-f16-log-trig` passes on WARP and on the AMD RX 9060 XT. - Five mutations report `mismatch`: cycled operation, high-half source read, a midpoint shifted by one ULP, `log2` replaced by `ln`, and removed exact zeroes. - `tests/form_coverage_check.py` passes, including `check_f16_log_trig_forms`; `rdna2_tools_check.py` reports 159 tests and 19 `LLVM_LIB` skips. - Expected full table after #3551/#3556/#3557 and this PR: **1,556/1,968** gfx1013 and **1,547/1,863** gfx1030. The complete 196-entry replay was not finished; the six forms are checked by the targeted test and coverage assertions. ## 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 #3544/#3549/#3556/#3557; they drop out of the diff once those land. AI-assisted.
case6 of startup_resource_retire_title releases the newer wrapper and calls settle() without waiting for the queues. Every release signals a release-time fence on each registered queue, and settle() only resubmits the drain list, so a fence that has not completed leaves both wrappers retained and the stage fails with retained=131072/2 against 65536/1. Sync the direct and gated queues before settle(), as #3457 did for startup_resource_retire. The expectation is unchanged.

Refs #3507
Lower the 62 v_cmpx_*_sdwa forms of gfx1013/rdna2 in the pixel translator,
reusing the existing v_cmpx EXEC region opener. VOPC SDWA has no destination:
the comparison writes EXEC, so the non-SDWA path is unchanged.

Add draw-cmpx-sdwa (warp/hardware), the static controls and the coverage
assertions, and teach the scanner the new spellings.

Tests: draw-cmpx-sdwa warp/hardware, draw-cmpx-regions warp,
draw-sdwa-cmp warp, form_coverage_check, rdna2_tools_check.
Coverage: 62 of 62 forms in each reference; 1542/1968 gfx1013 and
1533/1863 gfx1030 in the 194-entry WARP replay.
Add v_rcp_f16 and v_sqrt_f16 to the plain pixel VOP1 path in e32 and e64, matching the direct compute binary32 operation and binary16 narrowing. Cover finite-source proofs, mode and modifier refusals, exact and rounded values, chains, readers, scanner agreement, and form coverage.

Refs #839
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 07:06:11 +00:00
github-bot force-pushed github-bot/gh-3562 from f706bfdcc7 to e3a3c6e90e 2026-11-30 09:10:21 +00:00 Compare
Author
Owner

@⁠lambirou on GitHub · 2026-11-30 10:06 UTC · original

Merged as part of #3566: 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 #3580.

**@⁠lambirou** on GitHub · 2026-11-30 10:06 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3562#issuecomment-7275138010) Merged as part of #3566: 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 #3580.
github-bot closed this pull request 2026-11-30 10:12:22 +00:00

Pull request closed

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