diff options
author | Dylan Baker <dylanx.c.baker@intel.com> | 2014-11-11 11:58:26 -0800 |
---|---|---|
committer | Dylan Baker <dylanx.c.baker@intel.com> | 2014-11-24 11:46:12 -0800 |
commit | 9ec67b084d327c459f8d05961c7e3eda3901f658 (patch) | |
tree | b24fdeea22a78758358c8d25749e4b5488935298 /generated_tests | |
parent | 08dc03b2af12a762e57eb75c409f227cc998dfb5 (diff) |
gen_shader_bit_encoding_tests.py: split template into separate file
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
acked-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'generated_tests')
-rw-r--r-- | generated_tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | generated_tests/gen_shader_bit_encoding_tests.py | 102 | ||||
-rw-r--r-- | generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako | 87 |
3 files changed, 98 insertions, 95 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt index 6d27b3ec8..8b62807dc 100644 --- a/generated_tests/CMakeLists.txt +++ b/generated_tests/CMakeLists.txt @@ -44,7 +44,9 @@ piglit_make_generated_tests( gen_texture_query_lod_tests.py) piglit_make_generated_tests( shader_bit_encoding_tests.list - gen_shader_bit_encoding_tests.py) + gen_shader_bit_encoding_tests.py + templates/gen_shader_bit_encoding_tests/template.shader_test.mako + ) piglit_make_generated_tests( uniform-initializer_tests.list gen_uniform_initializer_tests.py diff --git a/generated_tests/gen_shader_bit_encoding_tests.py b/generated_tests/gen_shader_bit_encoding_tests.py index 6f8755d83..84b939076 100644 --- a/generated_tests/gen_shader_bit_encoding_tests.py +++ b/generated_tests/gen_shader_bit_encoding_tests.py @@ -1,6 +1,6 @@ # coding=utf-8 # -# Copyright © 2013 Intel Corporation +# Copyright © 2013, 2014 Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -23,9 +23,12 @@ import struct import os -import os.path -from mako.template import Template -from textwrap import dedent + +from templates import template_file + +TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]), + 'template.shader_test.mako') + def floatBitsToInt(f): return struct.unpack('i', struct.pack('f', f))[0] @@ -123,95 +126,6 @@ requirements = { } } -template = Template(dedent("""\ - [require] - GLSL >= ${version} - % for extension in extensions: - ${extension} - % endfor - - [vertex shader] - % if execution_stage == 'vs': - % for extension in extensions: - #extension ${extension}: enable - % endfor - - uniform ${input_type} given; - uniform ${output_type} expected; - out vec4 color; - % endif - - in vec4 vertex; - - void main() { - gl_Position = vertex; - - % if execution_stage == 'vs': - color = vec4(0.0, 1.0, 0.0, 1.0); - - if (expected.x != ${func}(${in_modifier_func}(given.x))) - color.r = 1.0; - if (expected.xy != ${func}(${in_modifier_func}(given.xy))) - color.r = 1.0; - if (expected.xyz != ${func}(${in_modifier_func}(given.xyz))) - color.r = 1.0; - if (expected != ${func}(${in_modifier_func}(given))) - color.r = 1.0; - % endif - } - - [fragment shader] - % if execution_stage == 'fs': - % for extension in extensions: - #extension ${extension}: enable - % endfor - - uniform ${input_type} given; - uniform ${output_type} expected; - % else: - in vec4 color; - % endif - - out vec4 frag_color; - - void main() { - % if execution_stage == 'fs': - frag_color = vec4(0.0, 1.0, 0.0, 1.0); - - if (expected.x != ${func}(${in_modifier_func}(given.x))) - frag_color.r = 1.0; - if (expected.xy != ${func}(${in_modifier_func}(given.xy))) - frag_color.r = 1.0; - if (expected.xyz != ${func}(${in_modifier_func}(given.xyz))) - frag_color.r = 1.0; - if (expected != ${func}(${in_modifier_func}(given))) - frag_color.r = 1.0; - % else: - frag_color = color; - % endif - } - - [vertex data] - vertex/float/2 - -1.0 -1.0 - 1.0 -1.0 - 1.0 1.0 - -1.0 1.0 - - [test] - % for name, data in sorted(test_data.iteritems()): - % if name == '-0.0' and in_modifier_func != '' and func == 'intBitsToFloat': - # ${in_modifier_func}(INT_MIN) doesn't fit in a 32-bit int. Cannot test. - % else: - # ${name} - uniform ${input_type} given ${' '.join(str(in_func(d)) for d in data)} - uniform ${output_type} expected ${' '.join(str(out_func(modifier_func(in_func(d)))) for d in data)} - draw arrays GL_TRIANGLE_FAN 0 4 - probe all rgba 0.0 1.0 0.0 1.0 - % endif - - % endfor -""")) for api, requirement in requirements.iteritems(): version = requirement['version'] @@ -251,7 +165,7 @@ for api, requirement in requirements.iteritems(): in_modifier_func = '-abs' f = open(filename, 'w') - f.write(template.render(version=version, + f.write(TEMPLATE.render(version=version, extensions=extensions, execution_stage=execution_stage, func=func, diff --git a/generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako b/generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako new file mode 100644 index 000000000..83eb5679c --- /dev/null +++ b/generated_tests/templates/gen_shader_bit_encoding_tests/template.shader_test.mako @@ -0,0 +1,87 @@ +[require] +GLSL >= ${version} +% for extension in extensions: +${extension} +% endfor + +[vertex shader] +% if execution_stage == 'vs': +% for extension in extensions: +#extension ${extension}: enable +% endfor + +uniform ${input_type} given; +uniform ${output_type} expected; +out vec4 color; +% endif + +in vec4 vertex; + +void main() { + gl_Position = vertex; + + % if execution_stage == 'vs': + color = vec4(0.0, 1.0, 0.0, 1.0); + + if (expected.x != ${func}(${in_modifier_func}(given.x))) + color.r = 1.0; + if (expected.xy != ${func}(${in_modifier_func}(given.xy))) + color.r = 1.0; + if (expected.xyz != ${func}(${in_modifier_func}(given.xyz))) + color.r = 1.0; + if (expected != ${func}(${in_modifier_func}(given))) + color.r = 1.0; + % endif +} + +[fragment shader] +% if execution_stage == 'fs': +% for extension in extensions: +#extension ${extension}: enable +% endfor + +uniform ${input_type} given; +uniform ${output_type} expected; +% else: +in vec4 color; +% endif + +out vec4 frag_color; + +void main() { + % if execution_stage == 'fs': + frag_color = vec4(0.0, 1.0, 0.0, 1.0); + + if (expected.x != ${func}(${in_modifier_func}(given.x))) + frag_color.r = 1.0; + if (expected.xy != ${func}(${in_modifier_func}(given.xy))) + frag_color.r = 1.0; + if (expected.xyz != ${func}(${in_modifier_func}(given.xyz))) + frag_color.r = 1.0; + if (expected != ${func}(${in_modifier_func}(given))) + frag_color.r = 1.0; + % else: + frag_color = color; + % endif +} + +[vertex data] +vertex/float/2 +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 + +[test] +% for name, data in sorted(test_data.iteritems()): +% if name == '-0.0' and in_modifier_func != '' and func == 'intBitsToFloat': +# ${in_modifier_func}(INT_MIN) doesn't fit in a 32-bit int. Cannot test. +% else: +# ${name} +uniform ${input_type} given ${' '.join(str(in_func(d)) for d in data)} +uniform ${output_type} expected ${' '.join(str(out_func(modifier_func(in_func(d)))) for d in data)} +draw arrays GL_TRIANGLE_FAN 0 4 +probe all rgba 0.0 1.0 0.0 1.0 +% endif + +% endfor |