shader: lower the remaining binary16 DPP unary forms #3586

Merged
lambirou merged 1 commit from upstream-pr/3586 into main 2026-11-30 11:39:15 +00:00
lambirou commented 2026-11-30 11:02:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T11:02:27Z.


Part of the f16 VOP1 DPP slice (Refs #839).

This adds the ten remaining quad-local binary16 VOP1 DPP unary forms: v_rsq_f16_dpp, v_exp_f16_dpp, v_log_f16_dpp, v_sin_f16_dpp and v_cos_f16_dpp, each in the DPP16 (quad_perm with row_mask:0xf bank_mask:0xf) and DPP8 encodings. The lowering reuses the plain opcode semantics exactly: the selected quad word's low half is widened, the same binary32 rsqrt/exp2/log2/sin16/cos16 operation runs, the result is narrowed to nearest even, and the same RDNA 2 special-result helpers (f16_rsq_result, f16_exp2_result, f16_log_result, f16_sin_result, f16_cos_result) apply. The value-tracking selectors are the same as the plain forms, so a finite proof is only recorded where the plain path records one. v_rcp_f16_dpp and v_sqrt_f16_dpp keep their existing lowering unchanged.

DPP16 accepts bit-15 abs/neg; DPP8, partial masks, bound_ctrl, fi, cross-quad or non-repeated DPP8, mixed controls, clamp, omod, a non-VGPR source and a non-entry EXEC mask stay refused. v_dot2c_f32_f16_dpp and the SDWA spellings are out of this slice.

Tests

  • pixel_aot_f16_dpp_unary_rest_warp and _hardware pass: four programs over exact and inexact values, signed zeros, subnormals, rsq of zero and negatives, exp of 2^-25 and two midpoint rows, log of zero and negatives, exact sin/cos zeros, the canonical NaN of a negative rsq, and DPP16↔DPP8 chains. Two mutations (mnemonic cycle and high-half source read) report pixel_mismatch on WARP and on the AMD Radeon RX 9060 XT (driver 32.0.32029.2010).
  • check_f16_dpp_unary_rest_controls pins the reference rows and every spelling, proof, control, modifier, mode, scheduling and reader refusal, and checks the four existing rcp/sqrt DPP forms still pass.
  • draw-f16-dpp-unary and draw-dpp-f16 still pass on both adapters.
  • form_coverage_check.py pins exactly the ten new forms; rdna2_tools_check.py passes 160 tests (19 skipped) including the scanner/translator agreement.
  • Expected full table after the merge: 1,589/1,968 gfx1013 and 1,574/1,863 gfx1030 (measured main at c7cbdf96: 1,579/1,968 and 1,564/1,863; this PR adds ten forms).

Limits

The high half of the destination is not observed; the D3D error windows of rsqrt/exp2/log2/sin/cos are not reproduced beyond the midpoint tables and exact references; runtime sources and NaN/infinity constants stay refused before lowering; lane routing is not measured because every lane of a statically proven source carries the same word. No title is known to execute these paths.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5563949454 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3586). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-30T11:02:27Z. --- Part of the f16 VOP1 DPP slice (Refs #839). This adds the ten remaining quad-local binary16 VOP1 DPP unary forms: `v_rsq_f16_dpp`, `v_exp_f16_dpp`, `v_log_f16_dpp`, `v_sin_f16_dpp` and `v_cos_f16_dpp`, each in the DPP16 (`quad_perm` with `row_mask:0xf bank_mask:0xf`) and DPP8 encodings. The lowering reuses the plain opcode semantics exactly: the selected quad word's low half is widened, the same binary32 `rsqrt`/`exp2`/`log2`/`sin16`/`cos16` operation runs, the result is narrowed to nearest even, and the same RDNA 2 special-result helpers (`f16_rsq_result`, `f16_exp2_result`, `f16_log_result`, `f16_sin_result`, `f16_cos_result`) apply. The value-tracking selectors are the same as the plain forms, so a finite proof is only recorded where the plain path records one. `v_rcp_f16_dpp` and `v_sqrt_f16_dpp` keep their existing lowering unchanged. DPP16 accepts bit-15 `abs`/`neg`; DPP8, partial masks, `bound_ctrl`, `fi`, cross-quad or non-repeated DPP8, mixed controls, clamp, omod, a non-VGPR source and a non-entry EXEC mask stay refused. `v_dot2c_f32_f16_dpp` and the SDWA spellings are out of this slice. ## Tests - `pixel_aot_f16_dpp_unary_rest_warp` and `_hardware` pass: four programs over exact and inexact values, signed zeros, subnormals, `rsq` of zero and negatives, `exp` of 2^-25 and two midpoint rows, `log` of zero and negatives, exact `sin`/`cos` zeros, the canonical NaN of a negative `rsq`, and DPP16↔DPP8 chains. Two mutations (mnemonic cycle and high-half source read) report `pixel_mismatch` on WARP and on the AMD Radeon RX 9060 XT (driver 32.0.32029.2010). - `check_f16_dpp_unary_rest_controls` pins the reference rows and every spelling, proof, control, modifier, mode, scheduling and reader refusal, and checks the four existing `rcp`/`sqrt` DPP forms still pass. - `draw-f16-dpp-unary` and `draw-dpp-f16` still pass on both adapters. - `form_coverage_check.py` pins exactly the ten new forms; `rdna2_tools_check.py` passes 160 tests (19 skipped) including the scanner/translator agreement. - Expected full table after the merge: **1,589/1,968** gfx1013 and **1,574/1,863** gfx1030 (measured `main` at `c7cbdf96`: 1,579/1,968 and 1,564/1,863; this PR adds ten forms). ## Limits The high half of the destination is not observed; the D3D error windows of `rsqrt`/`exp2`/`log2`/`sin`/`cos` are not reproduced beyond the midpoint tables and exact references; runtime sources and NaN/infinity constants stay refused before lowering; lane routing is not measured because every lane of a statically proven source carries the same word. No title is known to execute these paths. AI-assisted.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3586
No description provided.