mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 20:10:17 +01:00
nir: push up abs in atan2 calculation
everybody has abs on fmul, not everyone has abs on bcsel. should help agx and bifrost. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30934>
This commit is contained in:
parent
398e1ad46c
commit
ab8547a002
1 changed files with 3 additions and 2 deletions
|
|
@ -273,7 +273,8 @@ nir_atan2(nir_builder *b, nir_def *y, nir_def *x)
|
|||
nir_def *scale = nir_bcsel(b, nir_fge_imm(b, nir_fabs(b, t), huge_val),
|
||||
nir_imm_floatN_t(b, 0.25, bit_size), one);
|
||||
nir_def *rcp_scaled_t = nir_frcp(b, nir_fmul(b, t, scale));
|
||||
nir_def *s_over_t = nir_fmul(b, nir_fmul(b, s, scale), rcp_scaled_t);
|
||||
nir_def *abs_s_over_t = nir_fmul(b, nir_fabs(b, nir_fmul(b, s, scale)),
|
||||
nir_fabs(b, rcp_scaled_t));
|
||||
|
||||
/* For |x| = |y| assume tan = 1 even if infinite (i.e. pretend momentarily
|
||||
* that ∞/∞ = 1) in order to comply with the rather artificial rules
|
||||
|
|
@ -293,7 +294,7 @@ nir_atan2(nir_builder *b, nir_def *y, nir_def *x)
|
|||
* well).
|
||||
*/
|
||||
nir_def *tan = nir_bcsel(b, nir_feq(b, nir_fabs(b, x), nir_fabs(b, y)),
|
||||
one, nir_fabs(b, s_over_t));
|
||||
one, abs_s_over_t);
|
||||
|
||||
/* Calculate the arctangent and fix up the result if we had flipped the
|
||||
* coordinate system.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue