[Piglit] [PATCH 5/8] arb_gpu_shader5: Add ldexp constant eval execution test.

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


---
 .../built-in-functions/const-ldexp.shader-test     | 62 ++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 tests/spec/arb_gpu_shader5/execution/built-in-functions/const-ldexp.shader-test

diff --git a/tests/spec/arb_gpu_shader5/execution/built-in-functions/const-ldexp.shader-test b/tests/spec/arb_gpu_shader5/execution/built-in-functions/const-ldexp.shader-test
new file mode 100644
index 0000000..5a6752c
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/execution/built-in-functions/const-ldexp.shader-test
@@ -0,0 +1,62 @@
+[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
+
+void bad_constant_folding();
+
+out vec4 color;
+
+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(vec4(0.0, -0.0, 0.5, -0.5)) !=
+	    floatBitsToInt(ldexp(vec4(0.0, -0.0, 0.5, -0.5), ivec4(0)))) {
+		bad_constant_folding();
+	}
+	if (floatBitsToInt(vec4(0.49, 1.0, 25.0, 100.0)) !=
+	    floatBitsToInt(ldexp(vec4(0.98, 0.5, 0.78125, 0.78125), ivec4(-1, 1, 5, 7)))) {
+		bad_constant_folding();
+	}
+	if (floatBitsToInt(vec4(1.1754944e-38, -1.1754944e-38, 3.40282347e38, -3.40282347e38)) !=
+	    floatBitsToInt(ldexp(vec4(0.5, -0.5, 0.999999940, -0.999999940), ivec4(-125, -125, 128, 128)))) {
+		bad_constant_folding();
+	}
+	if (floatBitsToInt(vec4(0.5, -0.5, 0.999999940, -0.999999940)) !=
+	    floatBitsToInt(ldexp(vec4(1.1754944e-38, -1.1754944e-38, 3.40282347e38, -3.40282347e38), ivec4(125, 125, -128, -128)))) {
+		bad_constant_folding();
+	}
+	if (floatBitsToInt(vec4(0.0, -0.0, 0.0, -0.0)) !=
+	    floatBitsToInt(ldexp(vec4(0.0, -0.0, 0.5, -0.5), ivec4(-127)))) {
+		bad_constant_folding();
+	}
+	if (floatBitsToInt(vec4(0.0, -0.0, 0.0, -0.0)) !=
+	    floatBitsToInt(ldexp(vec4(1.1754944e-38, -1.1754944e-38, 3.40282347e38, -3.40282347e38), ivec4(-1, -1, -255, -255)))) {
+		bad_constant_folding();
+	}
+}
+
+[vertex data]
+vertex/float/2
+-1.0 -1.0
+ 1.0 -1.0
+ 1.0  1.0
+-1.0  1.0
+
+[test]
+draw arrays GL_TRIANGLE_FAN 0 4
+probe all rgba 0.0 1.0 0.0 1.0
-- 
1.8.3.2



More information about the Piglit mailing list