We were returning 3*pi/4 when we should return 0.0 according to IEEE 754.
Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]>
---
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 0a641077513..db4e3287b3c 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
_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev