Properly analyze edge0>=edge1 cases in smoothstep
authorBoris Zanin <boris.zanin@mobica.com>
Thu, 18 Oct 2018 08:50:25 +0000 (10:50 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 22 Nov 2018 10:38:11 +0000 (05:38 -0500)
Smoothstep result is undefined if edge0 >= edge1. Make tests
return NaNs for such cases to them.

Affected tests:
 * dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.*
 * dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.*
 * dEQP-VK.glsl.builtin.precision_fp16_storage16b.smoothstep.compute.*
 * dEQP-VK.glsl.builtin.precision_fp16_storage32b.smoothstep.compute.*

Components: Vulkan

VK-GL-CTS issue: 1425

Change-Id: Ieafc34c176c6681c2377898dde9a4934a3e5bcd3
(cherry picked from commit 4b16ba6bbd7e97b47244e4fb52ed6ccda37b3a48)

android/cts/master/src/vk-test-issues.txt
android/cts/master/vk-master.txt
external/vulkancts/modules/vulkan/shaderexecutor/vktShaderBuiltinPrecisionTests.cpp
external/vulkancts/mustpass/1.1.2/src/test-issues.txt
external/vulkancts/mustpass/1.1.2/vk-default-no-waivers.txt
external/vulkancts/mustpass/1.1.2/vk-default.txt

index 1f2bff291cee7dc8ca4aabde9b34732109259324..373fc70a10ac9873912fe476ea342a415250d8b5 100644 (file)
@@ -1,7 +1,5 @@
 # Issue 217: Built-in function precision test issues
 dEQP-VK.glsl.builtin.precision.dot.highp_compute.*
-dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.*
-dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.*
 dEQP-VK.glsl.builtin.precision.atan2.highp_compute.*
 dEQP-VK.glsl.builtin.precision.acosh.highp_compute.*
 dEQP-VK.glsl.builtin.precision.atanh.highp_compute.*
index d23dd789912cc1270839ca86ed9daa18ed0fe336..0522bab5b28e131dfa83fdbd2f9256a2f6c084ec 100755 (executable)
@@ -252227,6 +252227,14 @@ dEQP-VK.glsl.builtin.precision.step.highp_compute.scalar
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec2
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec3
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec4
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.scalar
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec2
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec3
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec4
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.scalar
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec2
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec3
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec4
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.scalar
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.vec2
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.vec3
index 05e3b11e4ca1a37537f3d18fe9cedfe06f336bb0..936666423494041783d36d52c4e61a74374fc183 100644 (file)
@@ -1191,7 +1191,7 @@ typename Traits<T>::IVal Expr<T>::evaluate (const EvalContext& ctx) const
                                                                                         tcu::MAYBE,
                                                                                         tcu::YES,
                                                                                         tcu::MAYBE);
-       EvalContext                                     newCtx          (ctx.format, ctx.basicType,
+       EvalContext                                     newCtx          (ctx.format, ctx.floatPrecision,
                                                                                         ctx.env, ctx.callDepth + 1);
        const IVal                                      ret                     = this->doEvaluate(newCtx);
 
@@ -4292,6 +4292,34 @@ ExprP<float> clamp(const ExprP<float>& x, const ExprP<float>& minVal, const Expr
 {
        return app<Clamp< Signature<float, float, float, float> > >(x, minVal, maxVal);
 }
+
+template <class T>
+class NanIfGreaterOrEqual : public FloatFunc2<T>
+{
+public:
+       string  getName         (void) const { return "nanIfGreaterOrEqual"; }
+
+       double  applyExact      (double edge0, double edge1) const
+       {
+               return (edge0 >= edge1) ? TCU_NAN : 0.0;
+       }
+
+       double  precision       (const EvalContext&, double, double edge0, double edge1) const
+       {
+               return (edge0 >= edge1) ? TCU_NAN : 0.0;
+       }
+};
+
+ExprP<deFloat16> nanIfGreaterOrEqual(const ExprP<deFloat16>& edge0, const ExprP<deFloat16>& edge1)
+{
+       return app<NanIfGreaterOrEqual< Signature<deFloat16, deFloat16, deFloat16> > >(edge0, edge1);
+}
+
+ExprP<float> nanIfGreaterOrEqual(const ExprP<float>& edge0, const ExprP<float>& edge1)
+{
+       return app<NanIfGreaterOrEqual< Signature<float, float, float> > >(edge0, edge1);
+}
+
 DEFINE_DERIVED_FLOAT3(Mix, mix, x, y, a, alternatives((x * (constant(1.0f) - a)) + y * a,
                                                                                                          x + (y - x) * a));
 
@@ -4328,9 +4356,9 @@ ExprP<SmoothStep< Signature<float, float, float, float> >::Ret>   SmoothStep< Sign
        const ExprP<float>&             edge0   = args.a;
        const ExprP<float>&             edge1   = args.b;
        const ExprP<float>&             x               = args.c;
-       const ExprP<float>                      tExpr   = clamp((x - edge0) / (edge1 - edge0),
-                                                                               constant(0.0f), constant(1.0f));
-       const ExprP<float>                      t               = bindExpression("t", ctx, tExpr);
+       const ExprP<float>              tExpr   = clamp((x - edge0) / (edge1 - edge0), constant(0.0f), constant(1.0f))
+                                                                       + nanIfGreaterOrEqual(edge0, edge1); // force NaN (and non-analyzable result) for cases edge0 >= edge1
+       const ExprP<float>              t               = bindExpression("t", ctx, tExpr);
 
        return (t * t * (constant(3.0f) - constant(2.0f) * t));
 }
@@ -4342,7 +4370,8 @@ ExprP<SmoothStep< Signature<deFloat16, deFloat16, deFloat16, deFloat16> >::TRet>
        const ExprP<deFloat16>&         edge1   = args.b;
        const ExprP<deFloat16>&         x               = args.c;
        const ExprP<deFloat16>          tExpr   = clamp(( x - edge0 ) / ( edge1 - edge0 ),
-                                                                                       constant((deFloat16)FLOAT16_0_0), constant((deFloat16)FLOAT16_1_0));
+                                                                                       constant((deFloat16)FLOAT16_0_0), constant((deFloat16)FLOAT16_1_0))
+                                                                               + nanIfGreaterOrEqual(edge0, edge1); // force NaN (and non-analyzable result) for cases edge0 >= edge1
        const ExprP<deFloat16>          t               = bindExpression("t", ctx, tExpr);
 
        return (t * t * (constant((deFloat16)FLOAT16_3_0) - constant((deFloat16)FLOAT16_2_0) * t));
index 4ffdf58b3e3735b1a8a77d0dc7abf4ef21dd0033..8ca4a6c9ca79c80895b42bb06d5ce9bbb368c805 100644 (file)
@@ -1,7 +1,5 @@
 # Issue 217: Built-in function precision test issues
 dEQP-VK.glsl.builtin.precision.dot.highp_compute.*
-dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.*
-dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.*
 dEQP-VK.glsl.builtin.precision.acosh.highp_compute.*
 dEQP-VK.glsl.builtin.precision.atanh.highp_compute.*
 dEQP-VK.glsl.builtin.precision.atanh.mediump_compute.*
index be1007356d6f226427477d3ffc89b081e91eaf0f..9d83292cf3959595243861f1b5c77ec6a0dad621 100644 (file)
@@ -252244,6 +252244,14 @@ dEQP-VK.glsl.builtin.precision.step.highp_compute.scalar
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec2
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec3
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec4
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.scalar
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec2
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec3
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec4
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.scalar
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec2
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec3
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec4
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.scalar
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.vec2
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.vec3
index 71f47e8e2d5f00d511eca59c09eac64478f1b16b..3eaf5576c411efd85e8ac7d89c0d38e0626e15a9 100644 (file)
@@ -252206,6 +252206,14 @@ dEQP-VK.glsl.builtin.precision.step.highp_compute.scalar
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec2
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec3
 dEQP-VK.glsl.builtin.precision.step.highp_compute.vec4
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.scalar
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec2
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec3
+dEQP-VK.glsl.builtin.precision.smoothstep.mediump_compute.vec4
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.scalar
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec2
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec3
+dEQP-VK.glsl.builtin.precision.smoothstep.highp_compute.vec4
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.scalar
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.vec2
 dEQP-VK.glsl.builtin.precision.length.mediump_compute.vec3