[Piglit] [PATCH 2/2] vulkan: Add some tests for glsl450 builtin functions using doubles
Neil Roberts
nroberts at igalia.com
Sat Nov 3 07:03:44 UTC 2018
---
.../face-forward-double.vk_shader_test | 88 +++++++++++++++++++
.../glsl450/frexp-double.vk_shader_test | 61 +++++++++++++
.../glsl450/isinf-double.vk_shader_test | 81 +++++++++++++++++
.../glsl450/reflect-double.vk_shader_test | 55 ++++++++++++
.../glsl450/refract-double.vk_shader_test | 88 +++++++++++++++++++
5 files changed, 373 insertions(+)
create mode 100644 tests/vulkan/glsl450/face-forward-double.vk_shader_test
create mode 100644 tests/vulkan/glsl450/frexp-double.vk_shader_test
create mode 100644 tests/vulkan/glsl450/isinf-double.vk_shader_test
create mode 100644 tests/vulkan/glsl450/reflect-double.vk_shader_test
create mode 100644 tests/vulkan/glsl450/refract-double.vk_shader_test
diff --git a/tests/vulkan/glsl450/face-forward-double.vk_shader_test b/tests/vulkan/glsl450/face-forward-double.vk_shader_test
new file mode 100644
index 000000000..3ad439059
--- /dev/null
+++ b/tests/vulkan/glsl450/face-forward-double.vk_shader_test
@@ -0,0 +1,88 @@
+[require]
+shaderFloat64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 430
+
+layout(std140, push_constant) uniform block {
+ dvec2 arg0;
+ dvec2 arg1;
+ dvec2 arg2;
+ double tolerance;
+ dvec2 expected;
+};
+
+layout(location = 0) out vec4 color_out;
+
+void
+main()
+{
+ dvec2 result = faceforward(arg0, arg1, arg2);
+
+ color_out = (distance(result, expected) <= tolerance ?
+ vec4(0.0, 1.0, 0.0, 1.0) :
+ vec4(1.0, 0.0, 0.0, 1.0));
+}
+
+[test]
+clear color 0.0 0.0 1.0 0.0
+clear
+
+uniform dvec2 0 -0.10000000000000001 -1.2
+uniform dvec2 16 -0.10000000000000001 -1.2
+uniform dvec2 32 -0.10000000000000001 -1.2
+uniform dvec2 64 0.10000000000000001 1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.10000000000000001 -1.2
+uniform dvec2 16 -0.10000000000000001 -1.2
+uniform dvec2 32 -0.41999999999999998 0.47999999999999998
+uniform dvec2 64 -0.10000000000000001 -1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.10000000000000001 -1.2
+uniform dvec2 16 -0.41999999999999998 0.47999999999999998
+uniform dvec2 32 -0.10000000000000001 -1.2
+uniform dvec2 64 -0.10000000000000001 -1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.10000000000000001 -1.2
+uniform dvec2 16 -0.41999999999999998 0.47999999999999998
+uniform dvec2 32 -0.41999999999999998 0.47999999999999998
+uniform dvec2 64 0.10000000000000001 1.2
+uniform double 48 1.2041594578792297e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41999999999999998 0.47999999999999998
+uniform dvec2 16 -0.10000000000000001 -1.2
+uniform dvec2 32 -0.10000000000000001 -1.2
+uniform dvec2 64 0.41999999999999998 -0.47999999999999998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41999999999999998 0.47999999999999998
+uniform dvec2 16 -0.10000000000000001 -1.2
+uniform dvec2 32 -0.41999999999999998 0.47999999999999998
+uniform dvec2 64 -0.41999999999999998 0.47999999999999998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41999999999999998 0.47999999999999998
+uniform dvec2 16 -0.41999999999999998 0.47999999999999998
+uniform dvec2 32 -0.10000000000000001 -1.2
+uniform dvec2 64 -0.41999999999999998 0.47999999999999998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41999999999999998 0.47999999999999998
+uniform dvec2 16 -0.41999999999999998 0.47999999999999998
+uniform dvec2 32 -0.41999999999999998 0.47999999999999998
+uniform dvec2 64 0.41999999999999998 -0.47999999999999998
+uniform double 48 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/vulkan/glsl450/frexp-double.vk_shader_test b/tests/vulkan/glsl450/frexp-double.vk_shader_test
new file mode 100644
index 000000000..1fbae50b1
--- /dev/null
+++ b/tests/vulkan/glsl450/frexp-double.vk_shader_test
@@ -0,0 +1,61 @@
+[require]
+shaderFloat64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 430
+
+layout(location = 0) out vec4 color;
+
+layout(std140, push_constant) uniform block {
+ dvec4 given_doub;
+ dvec4 expected_mantissa;
+ ivec4 expected_exponent;
+};
+
+void main()
+{
+ /* Green if both pass. */
+ color = vec4(0.0, 1.0, 0.0, 1.0);
+
+ ivec4 exponent;
+ dvec4 mantissa;
+
+ mantissa = frexp(given_doub, exponent);
+
+ if (mantissa != expected_mantissa) {
+ color.r = 1.0;
+ }
+
+ if (exponent != expected_exponent) {
+ color.b = 1.0;
+ }
+}
+
+[test]
+uniform dvec4 0 0.0 -0.0 0.5 -0.5
+uniform dvec4 32 0.0 -0.0 0.5 -0.5
+uniform ivec4 64 0 0 0 0
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform dvec4 0 0.49 1.0 25.0 100
+uniform dvec4 32 0.98 0.5 0.78125 0.78125
+uniform ivec4 64 -1 1 5 7
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+# Test FLT_MIN/MAX in doubles
+uniform dvec4 0 1.1754943508222875e-38 -1.1754943508222875e-38 3.4028234699999998e+38 -3.4028234699999998e+38
+uniform dvec4 32 0.5 -0.5 0.99999994145762339 -0.99999994145762339
+uniform ivec4 64 -125 -125 128 128
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+
+# Test DBL_MIN/MAX
+uniform dvec4 0 2.2250738585072014e-308 -2.2250738585072014e-308 1.7976931348623157e+308 -1.7976931348623157e+308
+uniform dvec4 32 0.5 -0.5 0.99999999999999989 -0.99999999999999989
+uniform ivec4 64 -1021 -1021 1024 1024
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/vulkan/glsl450/isinf-double.vk_shader_test b/tests/vulkan/glsl450/isinf-double.vk_shader_test
new file mode 100644
index 000000000..2c6169929
--- /dev/null
+++ b/tests/vulkan/glsl450/isinf-double.vk_shader_test
@@ -0,0 +1,81 @@
+# Test proper behavior of the isinf(vec4) function.
+#
+# Note: testing behavior if isinf() is challenging because the GLSL
+# 1.50 spec does not explicitly define any circumstances under which
+# infinite values are required to be generated. This test assumes
+# that the expressions 1.0*exp(1000.0) and -1.0*exp(1000.0) produce
+# infinite values when evaluated in the shader.
+
+[require]
+shaderFloat64
+
+[vertex shader]
+#version 430
+
+layout(std140, push_constant) uniform block {
+ double tolerance;
+ dvec4 multiplier;
+ vec4 exponent;
+ dvec4 expected;
+};
+
+layout(location = 0) in vec4 piglit_vertex;
+layout(location = 0) out vec4 vscolor;
+
+void
+main()
+{
+ gl_Position = piglit_vertex;
+ vscolor = vec4(0.0);
+
+ dvec4 r4 = multiplier*exp(exponent);
+ dvec4 bl4 = dvec4(isinf(r4));
+ if (distance(bl4, expected) > tolerance)
+ vscolor.x = 1.0;
+
+ dvec3 r3 = multiplier.xyz*exp(exponent.xyz);
+ dvec3 bl3 = dvec3(isinf(r3));
+ if (distance(bl3, expected.xyz) > tolerance)
+ vscolor.y = 1.0;
+
+ dvec2 r2 = multiplier.zw*exp(exponent.zw);
+ dvec2 bl2 = dvec2(isinf(r2));
+ if (distance(bl2, expected.zw) > tolerance)
+ vscolor.z = 1.0;
+
+ double r1 = multiplier.x*exp(exponent.x);
+ double bl1 = double(isinf(r1));
+ if (distance(bl1, expected.x) > tolerance)
+ vscolor.w = 1.0;
+}
+
+[fragment shader]
+#version 430
+
+layout(location = 0) in vec4 vscolor;
+layout(location = 0) out vec4 color;
+
+void
+main()
+{
+ color = vscolor;
+}
+
+[test]
+clear color 0.0 0.0 1.0 0.0
+
+clear
+uniform double 0 0.0
+uniform dvec4 32 1.0 1.0 -1.0 -1.0
+uniform vec4 64 1.0 1000.0 1000.0 1.0
+uniform dvec4 96 0.0 1.0 1.0 0.0
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 0.0 0.0
+
+clear
+uniform double 0 0.0
+uniform dvec4 32 -1.0 -1.0 1.0 1.0
+uniform vec4 64 1000.0 1.0 1.0 1000.0
+uniform dvec4 96 1.0 0.0 0.0 1.0
+draw rect -1 -1 2 2
+probe all rgba 0.0 0.0 0.0 0.0
diff --git a/tests/vulkan/glsl450/reflect-double.vk_shader_test b/tests/vulkan/glsl450/reflect-double.vk_shader_test
new file mode 100644
index 000000000..4c1d48480
--- /dev/null
+++ b/tests/vulkan/glsl450/reflect-double.vk_shader_test
@@ -0,0 +1,55 @@
+[require]
+shaderFloat64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 430
+
+layout(std140, push_constant) uniform block {
+ dvec2 arg0;
+ dvec2 arg1;
+ double tolerance;
+ dvec2 expected;
+};
+
+layout(location = 0) out vec4 color_out;
+
+void
+main()
+{
+ dvec2 result = reflect(arg0, arg1);
+
+ color_out = (distance(result, expected) <= tolerance ?
+ vec4(0.0, 1.0, 0.0, 1.0) :
+ vec4(1.0, 0.0, 0.0, 1.0));
+}
+
+[test]
+clear color 0.0 0.0 1.0 0.0
+clear
+
+uniform dvec2 0 -0.10000000000000001 -1.2
+uniform dvec2 16 -0.083045479853739973 -0.99654575824487956
+uniform dvec2 48 0.099999999999999978 1.1999999999999995
+uniform double 32 1.2041594578792292e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.10000000000000001 -1.2
+uniform dvec2 16 -0.65850460786851817 0.75257669470687794
+uniform dvec2 48 -1.2026548672566375 0.060176991150442838
+uniform double 32 1.2041594578792299e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41999999999999998 0.47999999999999998
+uniform dvec2 16 -0.083045479853739973 -0.99654575824487956
+uniform dvec2 48 -0.49365517241379309 -0.40386206896551724
+uniform double 32 6.3780874876407897e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.41999999999999998 0.47999999999999998
+uniform dvec2 16 -0.65850460786851817 0.75257669470687794
+uniform dvec2 48 0.42000000000000032 -0.48000000000000043
+uniform double 32 6.3780874876407965e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
diff --git a/tests/vulkan/glsl450/refract-double.vk_shader_test b/tests/vulkan/glsl450/refract-double.vk_shader_test
new file mode 100644
index 000000000..3db728a9d
--- /dev/null
+++ b/tests/vulkan/glsl450/refract-double.vk_shader_test
@@ -0,0 +1,88 @@
+[require]
+shaderFloat64
+
+[vertex shader passthrough]
+
+[fragment shader]
+#version 430
+
+layout(std140, push_constant) uniform block {
+ dvec2 arg0;
+ dvec2 arg1;
+ float arg2;
+ double tolerance;
+ dvec2 expected;
+};
+
+layout(location = 0) out vec4 color_out;
+
+void
+main()
+{
+ dvec2 result = refract(arg0, arg1, arg2);
+
+ color_out = (distance(result, expected) <= tolerance ?
+ vec4(0.0, 1.0, 0.0, 1.0) :
+ vec4(1.0, 0.0, 0.0, 1.0));
+}
+
+[test]
+clear color 0.0 0.0 1.0 0.0
+clear
+
+uniform dvec2 0 -0.083045479853739973 -0.99654575824487956
+uniform dvec2 16 -0.083045479853739973 -0.99654575824487956
+uniform float 32 0.5
+uniform dvec2 48 0.083045479853739973 0.99654575824487956
+uniform double 40 9.9999999999999991e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.083045479853739973 -0.99654575824487956
+uniform dvec2 16 -0.083045479853739973 -0.99654575824487956
+uniform float 32 2.0
+uniform dvec2 48 0.08304547985373989 0.99654575824487868
+uniform double 40 9.9999999999999907e-06
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.083045479853739973 -0.99654575824487956
+uniform dvec2 16 -0.65850460786851817 0.75257669470687794
+uniform float 32 0.5
+uniform dvec2 48 0.34406582839171168 -0.93894552862939029
+uniform double 40 1.0000000000000001e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.083045479853739973 -0.99654575824487956
+uniform dvec2 16 -0.65850460786851817 0.75257669470687794
+uniform float 32 2.0
+uniform dvec2 48 -0.0 -0.0
+uniform double 40 0.0
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.65850460786851817 0.75257669470687794
+uniform dvec2 16 -0.083045479853739973 -0.99654575824487956
+uniform float 32 0.5
+uniform dvec2 48 -0.28062487247894746 0.95981752481717819
+uniform double 40 1.0000000000000001e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.65850460786851817 0.75257669470687794
+uniform dvec2 16 -0.083045479853739973 -0.99654575824487956
+uniform float 32 2.0
+uniform dvec2 48 -0.0 0.0
+uniform double 40 0.0
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.65850460786851817 0.75257669470687794
+uniform dvec2 16 -0.65850460786851817 0.75257669470687794
+uniform float 32 0.5
+uniform dvec2 48 0.65850460786851817 -0.75257669470687782
+uniform double 40 1.0000000000000001e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
+uniform dvec2 0 -0.65850460786851817 0.75257669470687794
+uniform dvec2 16 -0.65850460786851817 0.75257669470687794
+uniform float 32 2.0
+uniform dvec2 48 0.65850460786851905 -0.75257669470687905
+uniform double 40 1.0000000000000016e-05
+draw rect -1 -1 2 2
+probe all rgba 0.0 1.0 0.0 1.0
--
2.17.1
More information about the Piglit
mailing list