summaryrefslogtreecommitdiff
path: root/generated_tests
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2012-05-16 14:17:00 -0700
committerIan Romanick <ian.d.romanick@intel.com>2012-06-12 12:02:27 -0700
commit59faa6beb09e078498be8a32668c13f8d608ce68 (patch)
tree513d18394ec8ac522f0d4e7161d560cd12545a73 /generated_tests
parent0c778b6014e5d06f4d4eca5d669f9a2773f7fc3b (diff)
glsl-1.20 / glsl-1.30: Add tests for uniforms with initializers modified by GL API
In these tests the uniforms are initialized with one set of values in the shader source, but the values are changed using the GL API. The shaders expect the values set by the GL API. v2: Use '{0}{1}' formatting instead of '{}{}'. The latter is added in Python 2.7, but piglit only requires Python 2.6. This was pointed out by Jordan Justen. v3: Clean up the generation of the if-statement based on feedback from Paul Berry. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Paul Berry <stereotype441@gmail.com>
Diffstat (limited to 'generated_tests')
-rw-r--r--generated_tests/CMakeLists.txt2
-rw-r--r--generated_tests/gen_uniform_initializer_tests.py1
-rw-r--r--generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template37
-rw-r--r--generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template41
4 files changed, 81 insertions, 0 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index f9e07a1fc..e371ff8b4 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -40,6 +40,8 @@ piglit_make_generated_tests(
uniform-initializer-templates/vs-initializer.template
uniform-initializer-templates/fs-initializer-from-const.template
uniform-initializer-templates/vs-initializer-from-const.template
+ uniform-initializer-templates/fs-initializer-set-by-API.template
+ uniform-initializer-templates/vs-initializer-set-by-API.template
uniform-initializer-templates/fs-initializer-set-by-other-stage.template
uniform-initializer-templates/vs-initializer-set-by-other-stage.template
)
diff --git a/generated_tests/gen_uniform_initializer_tests.py b/generated_tests/gen_uniform_initializer_tests.py
index 9d5b639e8..e307fbfad 100644
--- a/generated_tests/gen_uniform_initializer_tests.py
+++ b/generated_tests/gen_uniform_initializer_tests.py
@@ -172,6 +172,7 @@ random_numbers = (0.78685, 0.89828, 0.36590, 0.92504, 0.48998, 0.27989,
all_templates = ("",
"-from-const",
+ "-set-by-API",
"-set-by-other-stage",
)
diff --git a/generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template b/generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template
new file mode 100644
index 000000000..30fa21358
--- /dev/null
+++ b/generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template
@@ -0,0 +1,37 @@
+<%!
+def constructor(type, values):
+ return "{0}({1})".format(type, ", ".join(values))
+
+%>[require]
+GLSL >= ${"{0}.{1}".format(major, minor)}
+
+[vertex shader]
+#version ${"{0}{1}".format(major, minor)}
+
+void main()
+{
+ gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version ${"{0}{1}".format(major, minor)}
+
+% for (type, name, value) in type_list:
+uniform ${type} ${name} = ${value};
+% endfor
+
+void main()
+{
+ if (${"\n && ".join('{0} == {1}'.format(type_list[i][1], constructor(type_list[i][0], api_types[i][2])) for i in range(1, len(type_list) - 1))}) {
+ gl_FragColor = vec4(0, 1, 0, 1);
+ } else {
+ gl_FragColor = vec4(1, 0, 0, 1);
+ }
+}
+
+[test]
+% for (api_type, name, values) in api_types:
+uniform ${api_type} ${name} ${" ".join(values)}
+% endfor
+draw rect -1 -1 2 2
+probe all rgb 0 1 0
diff --git a/generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template b/generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template
new file mode 100644
index 000000000..1e6de735d
--- /dev/null
+++ b/generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template
@@ -0,0 +1,41 @@
+<%!
+def constructor(type, values):
+ return "{0}({1})".format(type, ", ".join(values))
+
+%>[require]
+GLSL >= ${"{0}.{1}".format(major, minor)}
+
+[vertex shader]
+#version ${"{0}{1}".format(major, minor)}
+varying vec4 color;
+
+% for (type, name, value) in type_list:
+uniform ${type} ${name} = ${value};
+% endfor
+
+void main()
+{
+ if (${"\n && ".join('{0} == {1}'.format(type_list[i][1], constructor(type_list[i][0], api_types[i][2])) for i in range(1, len(type_list) - 1))}) {
+ color = vec4(0, 1, 0, 1);
+ } else {
+ color = vec4(1, 0, 0, 1);
+ }
+
+ gl_Position = gl_Vertex;
+}
+
+[fragment shader]
+#version ${"{0}{1}".format(major, minor)}
+varying vec4 color;
+
+void main()
+{
+ gl_FragColor = color;
+}
+
+[test]
+% for (api_type, name, values) in api_types:
+uniform ${api_type} ${name} ${" ".join(values)}
+% endfor
+draw rect -1 -1 2 2
+probe all rgb 0 1 0