From 7d995c5a8ecc99e976ae5e41536abe9d792a2655 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Antto=20M=C3=A4kinen?= Date: Fri, 17 Jun 2022 13:52:15 +0300 Subject: [PATCH] Fix division by zero in glsBuiltinPrecisionTests GLSL precision tests were using 1 / InverseSqrt(x) to calculate reference values for square root. This is problematic when x = 0, as it causes a division by zero. VK-GL-CTS Issue: 3330 Affects: dEQP-GLES3*.functional.shaders.builtin_functions.precision.* Components: OpenGL ES Change-Id: I199f16b2eeb66ab042f0bb1ab6b588246efeb6d5 --- modules/glshared/glsBuiltinPrecisionTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/glshared/glsBuiltinPrecisionTests.cpp b/modules/glshared/glsBuiltinPrecisionTests.cpp index 2af7126..98564dc 100644 --- a/modules/glshared/glsBuiltinPrecisionTests.cpp +++ b/modules/glshared/glsBuiltinPrecisionTests.cpp @@ -2276,7 +2276,7 @@ ExprP NAME (const ExprP& arg0, const ExprP& arg1, \ return app(arg0, arg1, arg2, arg3); \ } -DEFINE_DERIVED_FLOAT1(Sqrt, sqrt, x, constant(1.0f) / app(x)); +DEFINE_DERIVED_FLOAT1(Sqrt, sqrt, x, (x == 0.0f ? constant(1.0f) : (constant(1.0f) / app(x)))); DEFINE_DERIVED_FLOAT2(Pow, pow, x, y, exp2(y * log2(x))); DEFINE_DERIVED_FLOAT1(Radians, radians, d, (constant(DE_PI) / constant(180.0f)) * d); DEFINE_DERIVED_FLOAT1(Degrees, degrees, r, (constant(180.0f) / constant(DE_PI)) * r); -- 2.7.4