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

Closed
opened 2026-11-28 06:14:45 +00:00 by github-bot · 0 comments
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-28 06:13 UTC · original

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.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-28 06:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/issues/3298) 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 06:14:45 +00:00
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/R0Y00--Xbox2Windows#3300
No description provided.