diff options
author | Dylan Baker <dylanx.c.baker@intel.com> | 2014-11-11 11:28:57 -0800 |
---|---|---|
committer | Dylan Baker <dylanx.c.baker@intel.com> | 2014-12-01 10:16:34 -0800 |
commit | e3531a82045eb535ca29aee0a651d098cf462329 (patch) | |
tree | 9cd7109a330785ca43edb5253aa81b89a1d56630 /generated_tests | |
parent | 65b1fb4f81b9ff82688270bb9775f3ded793c6b3 (diff) |
interpolation-qualifier...: use if __name__ == '__main__' pattern
By pulling all of the loops into a single function we also get the
advantage of combining some code.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'generated_tests')
-rw-r--r-- | generated_tests/interpolation-qualifier-built-in-variable.py | 212 |
1 files changed, 92 insertions, 120 deletions
diff --git a/generated_tests/interpolation-qualifier-built-in-variable.py b/generated_tests/interpolation-qualifier-built-in-variable.py index 9b0313ad5..efb717153 100644 --- a/generated_tests/interpolation-qualifier-built-in-variable.py +++ b/generated_tests/interpolation-qualifier-built-in-variable.py @@ -62,142 +62,114 @@ vertex_shader_to_fragment_shader_variable_map = { } -for fs_mode in interpolation_modes: - for vs_mode in interpolation_modes: - if vs_mode == fs_mode: - continue - - for var in vertex_shader_variables: - filename = os.path.join( - 'spec', - 'glsl-1.30', - 'linker', - 'interpolation-qualifiers', - '{0}-{1}-{2}-{3}.shader_test'.format( - vs_mode, var, fs_mode, - vertex_shader_to_fragment_shader_variable_map[var])) - print(filename) - - dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) - - with open(filename, 'w') as f: - f.write(TEMPLATES.get_template('vs-fs.shader_test.mako').render( - vs_mode=vs_mode, - vs_variable=var, - fs_mode=fs_mode, - fs_variable=vertex_shader_to_fragment_shader_variable_map[var])) - - -for vs_mode in interpolation_modes: - if vs_mode == 'default': - continue - - for var in vertex_shader_variables: - filename = os.path.join( - 'spec', - 'glsl-1.30', - 'linker', - 'interpolation-qualifiers', - '{0}-{1}-unused-{2}.shader_test'.format(vs_mode, var, - vertex_shader_to_fragment_shader_variable_map[var])) - print(filename) - - dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) - - with open(filename, 'w') as f: - f.write( - TEMPLATES.get_template('vs-unused.shader_test.mako').render( - vs_mode=vs_mode, - vs_variable=var)) - - -for fs_mode in interpolation_modes: - if fs_mode == 'default': - continue - - for var in vertex_shader_variables_front_only: - filename = os.path.join( - 'spec', - 'glsl-1.30', - 'linker', - 'interpolation-qualifiers', - 'unused-{0}-{1}-{2}.shader_test'.format( - var, fs_mode, - vertex_shader_to_fragment_shader_variable_map[var])) - print(filename) - - dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) - - with open(filename, 'w') as f: - f.write(TEMPLATES.get_template('fs-unused.shader_test.mako').render( - vs_mode=vs_mode, - vs_variable=var, - fs_mode=fs_mode, - fs_variable=vertex_shader_to_fragment_shader_variable_map[var])) - +def main(): + """main function.""" + dirname = os.path.join('spec', 'glsl-1.30', 'linker', + 'interpolation-qualifiers') + + if not os.path.exists(dirname): + os.makedirs(dirname) + + for fs_mode in interpolation_modes: + for vs_mode in interpolation_modes: + if vs_mode == fs_mode: + continue + + for var in vertex_shader_variables: + filename = os.path.join( + dirname, + '{0}-{1}-{2}-{3}.shader_test'.format( + vs_mode, var, fs_mode, + vertex_shader_to_fragment_shader_variable_map[var])) + print(filename) + + with open(filename, 'w') as f: + f.write(TEMPLATES.get_template('vs-fs.shader_test.mako').render( + vs_mode=vs_mode, + vs_variable=var, + fs_mode=fs_mode, + fs_variable=vertex_shader_to_fragment_shader_variable_map[var])) -for fs_mode in interpolation_modes: for vs_mode in interpolation_modes: - if vs_mode == fs_mode: + if vs_mode == 'default': continue for var in vertex_shader_variables: filename = os.path.join( - 'spec', - 'glsl-1.30', - 'linker', - 'interpolation-qualifiers', - 'unused-{0}-{1}-unused-{2}-{3}.shader_test'.format( - vs_mode, var, fs_mode, + dirname, + '{0}-{1}-unused-{2}.shader_test'.format(vs_mode, var, vertex_shader_to_fragment_shader_variable_map[var])) print(filename) - dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) - with open(filename, 'w') as f: - f.write(TEMPLATES.get_template( - 'fs-vs-unused.shader_test.mako').render( + f.write( + TEMPLATES.get_template('vs-unused.shader_test.mako').render( vs_mode=vs_mode, - vs_variable=var, - fs_mode=fs_mode, - fs_variable=vertex_shader_to_fragment_shader_variable_map[var])) - + vs_variable=var)) - -for fs_mode in interpolation_modes: - for vs_mode in interpolation_modes: - if vs_mode == fs_mode: + for fs_mode in interpolation_modes: + if fs_mode == 'default': continue - for this_side in vertex_shader_variables: - other_side = other_side_map[this_side] + for var in vertex_shader_variables_front_only: filename = os.path.join( - 'spec', - 'glsl-1.30', - 'linker', - 'interpolation-qualifiers', - '{0}-{1}-{2}-{3}.shader_test'.format( - vs_mode, this_side, fs_mode, other_side)) + dirname, + 'unused-{0}-{1}-{2}.shader_test'.format( + var, fs_mode, + vertex_shader_to_fragment_shader_variable_map[var])) print(filename) - dirname = os.path.dirname(filename) - if not os.path.exists(dirname): - os.makedirs(dirname) - with open(filename, 'w') as f: - f.write(TEMPLATES.get_template( - 'vs-fs-flip.shader_test.mako').render( - vs_mode=vs_mode, - this_side_variable=this_side, - other_side_variable=other_side, - fs_mode=fs_mode, - fs_variable=vertex_shader_to_fragment_shader_variable_map[this_side])) + f.write(TEMPLATES.get_template('fs-unused.shader_test.mako').render( + vs_mode=vs_mode, + vs_variable=var, + fs_mode=fs_mode, + fs_variable=vertex_shader_to_fragment_shader_variable_map[var])) + + for fs_mode in interpolation_modes: + for vs_mode in interpolation_modes: + if vs_mode == fs_mode: + continue + + for var in vertex_shader_variables: + filename = os.path.join( + dirname, + 'unused-{0}-{1}-unused-{2}-{3}.shader_test'.format( + vs_mode, var, fs_mode, + vertex_shader_to_fragment_shader_variable_map[var])) + print(filename) + + with open(filename, 'w') as f: + f.write(TEMPLATES.get_template( + 'fs-vs-unused.shader_test.mako').render( + vs_mode=vs_mode, + vs_variable=var, + fs_mode=fs_mode, + fs_variable=vertex_shader_to_fragment_shader_variable_map[var])) + + for fs_mode in interpolation_modes: + for vs_mode in interpolation_modes: + if vs_mode == fs_mode: + continue + + for this_side in vertex_shader_variables: + other_side = other_side_map[this_side] + filename = os.path.join( + dirname, + '{0}-{1}-{2}-{3}.shader_test'.format( + vs_mode, this_side, fs_mode, other_side)) + print(filename) + + with open(filename, 'w') as f: + f.write(TEMPLATES.get_template( + 'vs-fs-flip.shader_test.mako').render( + vs_mode=vs_mode, + this_side_variable=this_side, + other_side_variable=other_side, + fs_mode=fs_mode, + fs_variable=vertex_shader_to_fragment_shader_variable_map[this_side])) + + +if __name__ == '__main__': + main() |