Properly analyze edge0>=edge1 cases in smoothstep
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
diff --git a/android/cts/master/src/vk-test-issues.txt b/android/cts/master/src/vk-test-issues.txt
index ef1f4a7..b929fcb 100644
--- a/android/cts/master/src/vk-test-issues.txt
+++ b/android/cts/master/src/vk-test-issues.txt
@@ -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.*
diff --git a/android/cts/master/vk-master.txt b/android/cts/master/vk-master.txt
index bcb905b..5c34608 100755
--- a/android/cts/master/vk-master.txt
+++ b/android/cts/master/vk-master.txt
@@ -261147,6 +261147,14 @@
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
diff --git a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderBuiltinPrecisionTests.cpp b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderBuiltinPrecisionTests.cpp
index 05e3b11..9366664 100644
--- a/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderBuiltinPrecisionTests.cpp
+++ b/external/vulkancts/modules/vulkan/shaderexecutor/vktShaderBuiltinPrecisionTests.cpp
@@ -1191,7 +1191,7 @@
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 @@
{
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 @@
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 @@
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));
diff --git a/external/vulkancts/mustpass/1.1.3/src/test-issues.txt b/external/vulkancts/mustpass/1.1.3/src/test-issues.txt
index 4ffdf58..8ca4a6c 100644
--- a/external/vulkancts/mustpass/1.1.3/src/test-issues.txt
+++ b/external/vulkancts/mustpass/1.1.3/src/test-issues.txt
@@ -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.*
diff --git a/external/vulkancts/mustpass/1.1.3/vk-default-no-waivers.txt b/external/vulkancts/mustpass/1.1.3/vk-default-no-waivers.txt
index 467a551..ad32d7c 100644
--- a/external/vulkancts/mustpass/1.1.3/vk-default-no-waivers.txt
+++ b/external/vulkancts/mustpass/1.1.3/vk-default-no-waivers.txt
@@ -261164,6 +261164,14 @@
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
diff --git a/external/vulkancts/mustpass/1.1.3/vk-default.txt b/external/vulkancts/mustpass/1.1.3/vk-default.txt
index 86514d7..4d2f380 100644
--- a/external/vulkancts/mustpass/1.1.3/vk-default.txt
+++ b/external/vulkancts/mustpass/1.1.3/vk-default.txt
@@ -261126,6 +261126,14 @@
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