diff mbox

[1/2] gen_builtin_test.py : add version 100 support

Message ID 1360098000-21267-1-git-send-email-tom.gall@linaro.org
State New
Headers show

Commit Message

Tom Gall Feb. 5, 2013, 8:59 p.m. UTC
Adds support to emit builtin-functions-100.vert
largely based on the 110 version.
- Don't use gl_Vertex.
- Create misc_parameter_100 which adds cross.

Signed-off-by: Tom Gall <tom.gall@linaro.org>
---
 tests/glslparsertest/glsl2/gen_builtin_test.py |   66 +++++++++++++++++++++++-
 1 file changed, 65 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/tests/glslparsertest/glsl2/gen_builtin_test.py b/tests/glslparsertest/glsl2/gen_builtin_test.py
index e1e05e3..a4ca72f 100755
--- a/tests/glslparsertest/glsl2/gen_builtin_test.py
+++ b/tests/glslparsertest/glsl2/gen_builtin_test.py
@@ -1,5 +1,17 @@ 
 #!/usr/bin/env python
 
+misc_parameter_100 = [
+    [ "genType", "mod", "genType", "float" ],
+    [ "genType", "min", "genType", "float" ],
+    [ "genType", "max", "genType", "float" ],
+    [ "genType", "clamp", "genType", "float", "float" ],
+    [ "genType", "mix", "genType", "genType", "float" ],
+    [ "genType", "step", "float", "genType" ],
+    [ "genType", "smoothstep", "float", "float", "genType" ],
+    [ "genType", "refract", "genType", "genType", "float" ],
+    [ "vec3", "cross", "vec3", "vec3" ],
+    ]
+
 one_parameter_110 = [
     "radians",
     "degrees",
@@ -117,6 +129,55 @@  def emit_matrixCompMult(f, matTypes):
         f.write("  t_%s = matrixCompMult(u_%s, u_%s);\n" % (mat, mat, mat))
 
 
+def emit_100_tests(f):
+    f.write("/* PASS */\n#version 100\n\n")
+    f.write("uniform float u_float;\n")
+
+    for s in ["vec", "ivec", "bvec", "mat"]:
+        for i in [2, 3, 4]:
+            f.write("uniform %s%d u_%s%d;\n" % (s, i, s, i))
+
+    f.write("""\nvoid main()
+{
+  gl_Position = vec4(0.0);
+
+  float t_float = float(0.0);
+  bool t_bool = false;\n""")
+
+    for i in [2, 3, 4]:
+        f.write("  vec%d  t_vec%d  = vec%d (0.0);\n" % (i, i, i))
+        f.write("  bvec%d t_bvec%d = bvec%d(0.0);\n" % (i, i, i))
+        f.write("  mat%d  t_mat%d  = mat%d (0.0);\n" % (i, i, i))
+
+    f.write("\n")
+
+    for name in one_parameter_110:
+        for t in genType:
+            f.write("  t_%s += %s(u_%s);\n" % (t, name, t))
+
+    f.write("\n")
+
+    for name in two_parameter_110:
+        for t in genType:
+            f.write("  t_%s += %s(u_%s, -u_%s);\n" % (t, name, t, t))
+
+    f.write("\n")
+
+    for name in three_parameter_110:
+        for t in genType:
+            f.write("  t_%s += %s(u_%s, -u_%s, 11.7 * u_%s);\n" %
+                    (t, name, t, t, t))
+
+    f.write("\n")
+
+    emit_pattern_call(f, misc_parameter_100, genType)
+    emit_pattern_call(f, vec_parameter_110, vecType)
+    emit_pattern_call(f, bvec_parameter_110, bvecType)
+    emit_matrixCompMult(f, ["mat2", "mat3", "mat4"])
+
+    f.write("}\n")
+
+
 def emit_110_tests(f):
     f.write("/* PASS */\n#version 110\n\n")
     f.write("uniform float u_float;\n")
@@ -248,6 +309,10 @@  def emit_120_tests(f):
     f.write("}\n")
 
 
+f = open("builtin-functions-100.vert", "w")
+emit_100_tests(f)
+f.close()
+
 f = open("builtin-functions-110.vert", "w")
 emit_110_tests(f)
 f.close()
@@ -259,4 +324,3 @@  f.close()
 f = open("builtin-functions-120.vert", "w")
 emit_120_tests(f)
 f.close()
-