shader: lower v_cvt_pknorm_i16_f32 and v_cvt_pknorm_u16_f32 in direct DXIL #3294

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

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-28T05:46:11Z.


Refs #2935.

Lower VOP3 v_cvt_pknorm_i16_f32 (0x368) and v_cvt_pknorm_u16_f32 (0x369) in DirectCompute::float_alu() (src/gfx1013_direct_compute.inl) for both direct Compute and Pixel DXIL:

  • Pack cvt_norm(S0.f32) into D[15:0] and cvt_norm(S1.f32) into D[31:16] (round_rne(clamp(x, -1, 1) * 32767) and round_rne(clamp(x, 0, 1) * 65535)).
  • Evaluate in exact 32-bit unsigned integer round-to-nearest-even arithmetic (m * (2^k - 1) split at bit k), avoiding desktop float rounding/ftz differences and i64 dependency.
  • Handle NaN -> 0, |x| >= 1.0 (±Inf included) saturation, < 2^-17 underflow to 0, VOP3 abs[1:0]/neg[1:0], and VGPR/SGPR/literal/inline sources, while keeping clamp, omod, op_sel, third-operand abs/neg, nonzero src2, and DPP/SDWA encodings refused.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6659920260 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/3294). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-28T05:46:11Z. --- Refs #2935. Lower VOP3 `v_cvt_pknorm_i16_f32` (`0x368`) and `v_cvt_pknorm_u16_f32` (`0x369`) in `DirectCompute::float_alu()` (`src/gfx1013_direct_compute.inl`) for both direct Compute and Pixel DXIL: - Pack `cvt_norm(S0.f32)` into `D[15:0]` and `cvt_norm(S1.f32)` into `D[31:16]` (`round_rne(clamp(x, -1, 1) * 32767)` and `round_rne(clamp(x, 0, 1) * 65535)`). - Evaluate in exact 32-bit unsigned integer round-to-nearest-even arithmetic (`m * (2^k - 1)` split at bit `k`), avoiding desktop float rounding/ftz differences and `i64` dependency. - Handle NaN -> `0`, `|x| >= 1.0` (`±Inf` included) saturation, `< 2^-17` underflow to `0`, VOP3 `abs[1:0]`/`neg[1:0]`, and VGPR/SGPR/literal/inline sources, while keeping `clamp`, `omod`, `op_sel`, third-operand `abs`/`neg`, nonzero `src2`, and DPP/SDWA encodings refused. 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#3294
No description provided.