[Mesa-dev] [PATCH v3 05/44] spirv/glsl450: fix atan2(0, 0) lowering
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Wed Feb 6 10:44:34 UTC 2019
We were returning 3*pi/4 when we should return 0.0 according to IEEE 754.
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
src/compiler/spirv/vtn_glsl450.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/compiler/spirv/vtn_glsl450.c b/src/compiler/spirv/vtn_glsl450.c
index 04807700b72..21a2464d5e7 100644
--- a/src/compiler/spirv/vtn_glsl450.c
+++ b/src/compiler/spirv/vtn_glsl450.c
@@ -381,8 +381,12 @@ build_atan2(nir_builder *b, nir_ssa_def *y, nir_ssa_def *x)
* continuous along the whole positive y = 0 half-line, so it won't affect
* the result significantly.
*/
- return nir_bcsel(b, nir_flt(b, nir_fmin(b, y, rcp_scaled_t), zero),
- nir_fneg(b, arc), arc);
+ nir_ssa_def *result = nir_bcsel(b, nir_flt(b, nir_fmin(b, y, rcp_scaled_t), zero),
+ nir_fneg(b, arc), arc);
+ nir_ssa_def *is_xy_zero = nir_iand(b,
+ nir_feq(b, x, zero),
+ nir_feq(b, y, zero));
+ return nir_bcsel(b, is_xy_zero, zero, result);
}
static nir_ssa_def *
--
2.19.1
More information about the mesa-dev
mailing list