diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2012-05-16 14:11:38 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2012-06-12 12:02:27 -0700 |
commit | df48061fcb6555a8ae1cce70a09401e686f92d85 (patch) | |
tree | 5d9552df581c6a032f08151e4bdc66b89779d4ba /generated_tests | |
parent | c8d9f38d5d41d1b1e49fdb9f3d6bb8e6a27d54e5 (diff) |
glsl-1.20 / glsl-1.30: Add tests for uniforms with initializers from a constant
These tests are similar to the previous tests except the uniforms are
initialized using a variable declared as const. Since any
compile-time constant expression can be used to initialize a uniform,
this should also work.
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')
4 files changed, 75 insertions, 0 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt index 84d648bb1..33be413e0 100644 --- a/generated_tests/CMakeLists.txt +++ b/generated_tests/CMakeLists.txt @@ -38,6 +38,8 @@ piglit_make_generated_tests( gen_uniform_initializer_tests.py uniform-initializer-templates/fs-initializer.template uniform-initializer-templates/vs-initializer.template + uniform-initializer-templates/fs-initializer-from-const.template + uniform-initializer-templates/vs-initializer-from-const.template ) # Add a "gen-tests" target that can be used to generate all the diff --git a/generated_tests/gen_uniform_initializer_tests.py b/generated_tests/gen_uniform_initializer_tests.py index ed6e33993..174bae209 100644 --- a/generated_tests/gen_uniform_initializer_tests.py +++ b/generated_tests/gen_uniform_initializer_tests.py @@ -171,6 +171,7 @@ random_numbers = (0.78685, 0.89828, 0.36590, 0.92504, 0.48998, 0.27989, 0.72414, 0.88036, 0.54498, 0.32668, 0.02967, 0.12643) all_templates = ("", + "-from-const", ) bool_types = [("bool", 1), ("bvec2", 2), ("bvec3", 3), ("bvec4", 4)] diff --git a/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template b/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template new file mode 100644 index 000000000..77cf3c4d3 --- /dev/null +++ b/generated_tests/uniform-initializer-templates/fs-initializer-from-const.template @@ -0,0 +1,34 @@ +[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: +const ${type} c${name} = ${value}; +% endfor + +% for (type, name, value) in type_list: +uniform ${type} ${name} = c${name}; +% endfor + +void main() +{ + if (${"\n && ".join('{0} == {1}'.format(name, value) for type, name, value in type_list)}) { + gl_FragColor = vec4(0, 1, 0, 1); + } else { + gl_FragColor = vec4(1, 0, 0, 1); + } +} + +[test] +draw rect -1 -1 2 2 +probe all rgb 0 1 0 diff --git a/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template b/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template new file mode 100644 index 000000000..a33ac645a --- /dev/null +++ b/generated_tests/uniform-initializer-templates/vs-initializer-from-const.template @@ -0,0 +1,38 @@ +[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: +const ${type} c${name} = ${value}; +% endfor + +% for (type, name, value) in type_list: +uniform ${type} ${name} = c${name}; +% endfor + +void main() +{ + if (${"\n && ".join('{0} == {1}'.format(name, value) for type, name, value in type_list)}) { + color = vec4(0, 1, 0, 1); + } else { + color = vec4(1, 0, 0, 1); + } + + gl_Position = gl_Vertex; +} + +[fragment shader] +#version ${"{}{}".format(major, minor)} +varying vec4 color; + +void main() +{ + gl_FragColor = color; +} + +[test] +draw rect -1 -1 2 2 +probe all rgb 0 1 0 |