From 59faa6beb09e078498be8a32668c13f8d608ce68 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 16 May 2012 14:17:00 -0700 Subject: 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 Reviewed-by: Paul Berry --- generated_tests/CMakeLists.txt | 2 ++ generated_tests/gen_uniform_initializer_tests.py | 1 + .../fs-initializer-set-by-API.template | 37 +++++++++++++++++++ .../vs-initializer-set-by-API.template | 41 ++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 generated_tests/uniform-initializer-templates/fs-initializer-set-by-API.template create mode 100644 generated_tests/uniform-initializer-templates/vs-initializer-set-by-API.template (limited to 'generated_tests') 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 -- cgit v1.2.3