diff options
author | Dylan Baker <dylanx.c.baker@intel.com> | 2014-11-11 15:08:23 -0800 |
---|---|---|
committer | Dylan Baker <dylanx.c.baker@intel.com> | 2014-11-24 11:53:21 -0800 |
commit | c59995dd5b88743031e3fd34c571a9b80a2ae6b8 (patch) | |
tree | c9ad36986f26454578d9450d200cc0516c5c9814 /generated_tests | |
parent | f1a79036de18981304d7359f6bdc64638eb0634e (diff) |
gen_texture_lod_tests.py: Split templates
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
acked-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'generated_tests')
5 files changed, 94 insertions, 111 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt index 8b62807dc..1ca586e53 100644 --- a/generated_tests/CMakeLists.txt +++ b/generated_tests/CMakeLists.txt @@ -76,7 +76,11 @@ piglit_make_generated_tests( interpolation-qualifier-built-in-variable.py) piglit_make_generated_tests( texture_lod_tests.list - gen_texture_lod_tests.py) + gen_texture_lod_tests.py + templates/gen_texture_lod_tests/tex_grad.vert.mako + templates/gen_texture_lod_tests/tex_grad.frag.mako + templates/gen_texture_lod_tests/frag_lod.glsl_parser_test.mako + ) piglit_make_generated_tests( outerproduct_invalid_params.list gen_outerproduct_invalid_params.py) diff --git a/generated_tests/gen_texture_lod_tests.py b/generated_tests/gen_texture_lod_tests.py index 6101341c5..ebedc61e6 100644 --- a/generated_tests/gen_texture_lod_tests.py +++ b/generated_tests/gen_texture_lod_tests.py @@ -22,9 +22,11 @@ from __future__ import print_function import os -import textwrap import collections -import mako.template + +from templates import template_dir + +TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0])) Parameters = collections.namedtuple( 'Parameters', ['coord', 'grad', 'dimensions', 'mode']) @@ -55,131 +57,55 @@ GRAD_TESTS = LOD_TESTS + [ def get_extensions(mode): - """ If this test uses GL_ARB_texture_rectangle add it""" + """ If this test uses GL_ARB_texture_rectangle add it + + GL_ARB_texture_rectangle is an odd extension, it is on by default, so don't + generate a #extension in the shader, just in the config block. + + """ if 'Rect' in mode: return 'GL_ARB_shader_texture_lod GL_ARB_texture_rectangle' return 'GL_ARB_shader_texture_lod' -def gen_frag_lod_test(parameter, filename): - """ Generate fragment shader LOD tests """ - template = mako.template.Template(textwrap.dedent(""" - /* [config] - * expect_result: pass - * glsl_version: 1.10 - * require_extensions: GL_ARB_shader_texture_lod - * [end config] - */ - #extension GL_ARB_shader_texture_lod: require - - uniform sampler${param.dimensions} s; - varying ${param.coord} coord; - varying float lod; - - void main() - { - gl_FragColor = ${param.mode}Lod(s, coord, lod); - } - """)) - with open(filename, 'w+') as f: - f.write(template.render_unicode(param=parameter)) - - -def gen_frag_grad_test(parameter, filename): - """ Generate fragment shader gradient tests """ - template = mako.template.Template(textwrap.dedent(""" - /* [config] - * expect_result: pass - * glsl_version: 1.10 - * require_extensions: ${extensions} - * [end config] - */ - #extension GL_ARB_shader_texture_lod: require - - uniform sampler${param.dimensions} s; - varying ${param.coord} coord; - varying ${param.grad} dPdx; - varying ${param.grad} dPdy; - - void main() - { - gl_FragColor = ${param.mode}GradARB(s, coord, dPdx, dPdy); - } - """)) - with open(filename, 'w+') as f: - f.write(template.render_unicode( - param=parameter, - extensions=get_extensions(parameter.mode))) - - -def gen_vert_grad_test(parameter, filename): - """ Generate vertex shader gradient tests """ - template = mako.template.Template(textwrap.dedent(""" - /* [config] - * expect_result: pass - * glsl_version: 1.10 - * require_extensions: ${extensions} - * [end config] - */ - #extension GL_ARB_shader_texture_lod: require - - uniform sampler${param.dimensions} s; - attribute vec4 pos; - attribute ${param.coord} coord; - attribute ${param.grad} dPdx; - attribute ${param.grad} dPdy; - varying vec4 color; - - void main() - { - gl_Position = pos; - color = ${param.mode}GradARB(s, coord, dPdx, dPdy); - } - """)) - with open(filename, 'w+') as f: - f.write(template.render_unicode( - param=parameter, - extensions=get_extensions(parameter.mode))) - - def main(): """ Main function Writes tests to generated_tests/spec/arb_shader_texture_lod/ directory """ - try: - os.makedirs('spec/arb_shader_texture_lod/compiler') - except OSError: - pass + dirname = 'spec/arb_shader_texture_lod/compiler' + if not os.path.exists(dirname): + os.makedirs(dirname) for params in LOD_TESTS: - name = ("spec/arb_shader_texture_lod/compiler/" - "tex_lod-{mode}-{dimensions}-{coord}.frag".format( - mode=params.mode, - dimensions=params.dimensions, - coord=params.coord)) + name = os.path.join( + dirname, + "tex_lod-{mode}-{dimensions}-{coord}.frag".format( + mode=params.mode, + dimensions=params.dimensions, + coord=params.coord)) print(name) - gen_frag_lod_test(params, name) + with open(name, 'w+') as f: + f.write(TEMPLATES.get_template( + 'frag_lod.glsl_parser_test.mako').render_unicode(param=params)) for params in GRAD_TESTS: # Generate fragment shader test - name = ("spec/arb_shader_texture_lod/compiler/" - "tex_grad-{mode}-{dimensions}-{coord}.frag".format( - mode=params.mode, - dimensions=params.dimensions, - coord=params.coord)) - print(name) - gen_frag_grad_test(params, name) - - # Generate vertex shader test - name = ("spec/arb_shader_texture_lod/compiler/" - "tex_grad-{mode}-{dimensions}-{coord}.vert".format( - mode=params.mode, - dimensions=params.dimensions, - coord=params.coord)) - print(name) - gen_vert_grad_test(params, name) + name = os.path.join( + dirname, + "tex_grad-{mode}-{dimensions}-{coord}".format( + mode=params.mode, + dimensions=params.dimensions, + coord=params.coord)) + + for stage in ['frag', 'vert']: + print('{}.{}'.format(name, stage)) + with open('{}.{}'.format(name, stage), 'w+') as f: + f.write(TEMPLATES.get_template( + 'tex_grad.{}.mako'.format(stage)).render_unicode( + param=params, + extensions=get_extensions(params.mode))) if __name__ == '__main__': diff --git a/generated_tests/templates/gen_texture_lod_tests/frag_lod.glsl_parser_test.mako b/generated_tests/templates/gen_texture_lod_tests/frag_lod.glsl_parser_test.mako new file mode 100644 index 000000000..3c3df9cc0 --- /dev/null +++ b/generated_tests/templates/gen_texture_lod_tests/frag_lod.glsl_parser_test.mako @@ -0,0 +1,16 @@ +/* [config] + * expect_result: pass + * glsl_version: 1.10 + * require_extensions: GL_ARB_shader_texture_lod + * [end config] + */ +#extension GL_ARB_shader_texture_lod : require + +uniform sampler${param.dimensions} s; +varying ${param.coord} coord; +varying float lod; + +void main() +{ + gl_FragColor = ${param.mode}Lod(s, coord, lod); +} diff --git a/generated_tests/templates/gen_texture_lod_tests/tex_grad.frag.mako b/generated_tests/templates/gen_texture_lod_tests/tex_grad.frag.mako new file mode 100644 index 000000000..d807c835c --- /dev/null +++ b/generated_tests/templates/gen_texture_lod_tests/tex_grad.frag.mako @@ -0,0 +1,17 @@ +/* [config] + * expect_result: pass + * glsl_version: 1.10 + * require_extensions: ${extensions} + * [end config] + */ +#extension GL_ARB_shader_texture_lod : require + +uniform sampler${param.dimensions} s; +varying ${param.coord} coord; +varying ${param.grad} dPdx; +varying ${param.grad} dPdy; + +void main() +{ + gl_FragColor = ${param.mode}GradARB(s, coord, dPdx, dPdy); +} diff --git a/generated_tests/templates/gen_texture_lod_tests/tex_grad.vert.mako b/generated_tests/templates/gen_texture_lod_tests/tex_grad.vert.mako new file mode 100644 index 000000000..7d7aef38e --- /dev/null +++ b/generated_tests/templates/gen_texture_lod_tests/tex_grad.vert.mako @@ -0,0 +1,20 @@ +/* [config] + * expect_result: pass + * glsl_version: 1.10 + * require_extensions: ${extensions} + * [end config] + */ +#extension GL_ARB_shader_texture_lod : require + +uniform sampler${param.dimensions} s; +attribute vec4 pos; +attribute ${param.coord} coord; +attribute ${param.grad} dPdx; +attribute ${param.grad} dPdy; +varying vec4 color; + +void main() +{ + gl_Position = pos; + color = ${param.mode}GradARB(s, coord, dPdx, dPdy); +} |