shader: lower v_sin_f16 and v_cos_f16 in direct Compute DXIL #3298

Closed
opened 2026-11-28 06:13:12 +00:00 by legacy-code-archaeologist · 0 comments
legacy-code-archaeologist commented 2026-11-28 06:13:12 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-28T06:13:12Z.


The direct Compute DXIL translator lowers binary16 VOP1/VOP3 transcendentals (v_rcp_f16, v_sqrt_f16, v_exp_f16, v_rsq_f16) via binary16_unary(), and lowers v_sin_f32 / v_cos_f32 with turn-based range reduction (part = a - trunc(a)), signed-zero preservation, and exact quarter-turn zeros. v_sin_f16 (0x60 / 0x1e0) and v_cos_f16 (0x61 / 0x1e1) are still unlowered.

Plan:

  • Add v_sin_f16 and v_cos_f16 to binary16_unary() in src/gfx1013_compute_native.cpp (preserving DPP refusal, SDWA low/high half selection, MODE checks, and D[31:16] preservation).
  • Lower both in DirectCompute::float_alu() (src/gfx1013_direct_compute.inl) using turn reduction (a - trunc(a)), -0 preservation, quarter-turn exact zeros (|part| == 0.5 for sin, 0.25 / 0.75 for cos), packed_half_rne, +-Inf/NaN -> 0x7e00, and -0.0 preservation on v_sin_f16.
  • Add tests/native_sin_cos_f16_check.py (ir, controls, hardware), tests/cmake/native_sin_cos_f16.cmake, and docs/experiments/native-sin-cos-f16.md.

Refs #2935.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6660219201 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3298). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-28T06:13:12Z. --- The direct Compute DXIL translator lowers binary16 VOP1/VOP3 transcendentals (`v_rcp_f16`, `v_sqrt_f16`, `v_exp_f16`, `v_rsq_f16`) via `binary16_unary()`, and lowers `v_sin_f32` / `v_cos_f32` with turn-based range reduction (`part = a - trunc(a)`), signed-zero preservation, and exact quarter-turn zeros. `v_sin_f16` (`0x60` / `0x1e0`) and `v_cos_f16` (`0x61` / `0x1e1`) are still unlowered. Plan: - Add `v_sin_f16` and `v_cos_f16` to `binary16_unary()` in `src/gfx1013_compute_native.cpp` (preserving DPP refusal, SDWA low/high half selection, `MODE` checks, and `D[31:16]` preservation). - Lower both in `DirectCompute::float_alu()` (`src/gfx1013_direct_compute.inl`) using turn reduction (`a - trunc(a)`), `-0` preservation, quarter-turn exact zeros (`|part| == 0.5` for sin, `0.25` / `0.75` for cos), `packed_half_rne`, `+-Inf`/NaN -> `0x7e00`, and `-0.0` preservation on `v_sin_f16`. - Add `tests/native_sin_cos_f16_check.py` (`ir`, `controls`, `hardware`), `tests/cmake/native_sin_cos_f16.cmake`, and `docs/experiments/native-sin-cos-f16.md`. Refs #2935. AI-assisted.
Sign in to join this conversation.
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#3298
No description provided.