[Piglit] [PATCH 3/8] arb_gpu_shader5: Add ldexp fragment shader execution test.

Matt Turner mattst88 at gmail.com
Thu Aug 22 16:07:29 PDT 2013


---
 .../built-in-functions/fs-ldexp.shader_test        | 88 ++++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test

diff --git a/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test b/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test
new file mode 100644
index 0000000..0b07b2b
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/execution/built-in-functions/fs-ldexp.shader_test
@@ -0,0 +1,88 @@
+[require]
+GLSL >= 1.50
+GL_ARB_gpu_shader5
+
+[vertex shader]
+in vec4 vertex;
+
+void main() {
+	gl_Position = vertex;
+}
+
+[fragment shader]
+#extension GL_ARB_gpu_shader5 : enable
+
+out vec4 color;
+
+uniform vec4 expected_float;
+uniform vec4 given_float;
+uniform ivec4 given_exponent;
+
+void main()
+{
+	/* Green if both pass. */
+	color = vec4(0.0, 1.0, 0.0, 1.0);
+
+	/* Compare the results after going through floatBitsToInt() allows us
+	 * to distinguish -0.0f from 0.0f.
+	 */
+	if (floatBitsToInt(expected_float) !=
+	    floatBitsToInt(ldexp(given_float, given_exponent))) {
+		color.r = 1.0;
+	}
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+ 1.0  1.0
+-1.0  1.0
+
+[test]
+# Basic tests with exponent = 0.
+uniform vec4 expected_float 0.0 -0.0 0.5 -0.5
+uniform vec4 given_float 0.0 -0.0 0.5 -0.5
+uniform ivec4 given_exponent 0 0 0 0
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
+
+# Basic tests.
+uniform vec4 expected_float 0.49 1.0 25.0 100
+uniform vec4 given_float 0.98 0.5 0.78125 0.78125
+uniform ivec4 given_exponent -1 1 5 7
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
+
+# Test generating FLT_MIN (1.1754944e-38) and FLT_MAX (3.40282347e38).
+uniform vec4 expected_float 1.1754944e-38 -1.1754944e-38 3.40282347e38 -3.40282347e38
+uniform vec4 given_float 0.5 -0.5 0.999999940 -0.999999940
+uniform ivec4 given_exponent -125 -125 128 128
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
+
+# Test FLT_MIN (1.1754944e-38) and FLT_MAX (3.40282347e38) as inputs.
+uniform vec4 expected_float 0.5 -0.5 0.999999940 -0.999999940
+uniform vec4 given_float 1.1754944e-38 -1.1754944e-38 3.40282347e38 -3.40282347e38
+uniform ivec4 given_exponent 125 125 -128 -128
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
+
+# Test underflow generates zero with sign of x.
+uniform vec4 expected_float 0.0 -0.0 0.0 -0.0
+uniform vec4 given_float 0.0 -0.0 0.5 -0.5
+uniform ivec4 given_exponent -127 -127 -127 -127
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
+
+uniform vec4 expected_float 0.0 -0.0 0.0 -0.0
+uniform vec4 given_float 1.1754944e-38 -1.1754944e-38 3.40282347e38 -3.40282347e38
+# For the FLT_MAX case -255 comes from (-127 + -127 + -1).
+#   ldexp(FLT_MAX, -127)           = 0x1.fffffep+0 (1.999999881)
+#   ldexp(FLT_MAX, -127 - 127)     = 0x1p-126 (epsilon above FLT_MIN)
+#   ldexp(FLT_MAX, -127 - 127 - 1) = 0.0
+uniform ivec4 given_exponent -1 -1 -255 -255
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
+
+# Overflow is undefined according to the GLSL spec, so nothing to test.
-- 
1.8.3.2



More information about the Piglit mailing list