Commit e3531a82 authored by Dylan Baker's avatar Dylan Baker
Browse files

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: default avatarDylan Baker <dylanx.c.baker@intel.com>
parent 65b1fb4f
......@@ -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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment