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 1f2bff2..373fc70 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 d23dd78..0522bab 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 05e3b11..9366664 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 4ffdf58..8ca4a6c 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 be10073..9d83292 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 71f47e8..3eaf557 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