ext_gpu_shader4: add compiler tests for everything
[piglit.git] / generated_tests / gen_inout_fp64.py
blob844f2a9c47a06078bd742f511c41e0222280968e
1 # coding=utf-8
3 # Copyright © 2016 Intel Corporation
5 # Permission is hereby granted, free of charge, to any person obtaining a
6 # copy of this software and associated documentation files (the "Software"),
7 # to deal in the Software without restriction, including without limitation
8 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 # and/or sell copies of the Software, and to permit persons to whom the
10 # Software is furnished to do so, subject to the following conditions:
12 # The above copyright notice and this permission notice (including the next
13 # paragraph) shall be included in all copies or substantial portions of the
14 # Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 # DEALINGS IN THE SOFTWARE.
24 """Generate in/out fp64 tests."""
26 from __future__ import print_function, division, absolute_import
27 import argparse
28 import os
29 import itertools
31 from templates import template_dir
32 from modules import utils
34 TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
36 def get_dir_name(ver, test_type):
37 """Returns the directory name to save tests given a GLSL version."""
39 assert isinstance(ver, str)
40 assert isinstance(test_type, str)
41 if ver == '150':
42 feature_dir = 'arb_gpu_shader_fp64'
43 else:
44 feature_dir = 'glsl-' + ver[0] + '.' + ver[1:]
46 return os.path.join('spec', feature_dir, test_type,
47 'inout')
50 def generate_compilation_tests(type_name, shader, ver, names_only):
51 """Generate in/out GLSL compilation tests."""
53 assert isinstance(type_name, str)
54 assert shader in ('vert', 'frag')
55 assert isinstance(ver, str)
56 assert isinstance(names_only, bool)
58 filename = os.path.join(
59 get_dir_name(ver, 'compiler'),
60 '{0}-{1}put-{2}.{3}'.format('fs' if shader == 'frag' else 'vs',
61 'out' if shader == 'frag' else 'in',
62 type_name, shader))
64 print(filename)
66 if not names_only:
67 with open(filename, 'w') as test_file:
68 test_file.write(TEMPLATES.get_template(
69 'template.{0}.mako'.format(shader)).render_unicode(
70 glsl_version='{}.{}'.format(ver[0], ver[1:]),
71 glsl_version_int=ver,
72 type_name=type_name,
73 extra_params=',0.0' if type_name in ['dvec2', 'dvec3'] else ''))
76 def generate_execution_tests(type_name, ver, names_only):
77 """Generate in/out shader runner tests."""
79 assert isinstance(type_name, str)
80 assert isinstance(ver, str)
81 assert isinstance(names_only, bool)
83 filename = os.path.join(
84 get_dir_name(ver, 'execution'),
85 'vs-out-fs-in-{0}.shader_test'.format(type_name))
87 print(filename)
89 if not names_only:
90 with open(filename, 'w') as test_file:
91 test_file.write(TEMPLATES.get_template(
92 'template.shader_test.mako').render_unicode(
93 glsl_version='{}.{}'.format(ver[0], ver[1:]),
94 glsl_version_int=ver,
95 type_name=type_name))
98 def all_compilation_tests(names_only):
99 """Creates all the combinations for in/out compilation tests."""
101 assert isinstance(names_only, bool)
102 type_names = ['double', 'dvec2', 'dvec3', 'dvec4',
103 'dmat2', 'dmat2x3', 'dmat2x4',
104 'dmat3x2', 'dmat3', 'dmat3x4',
105 'dmat4x2', 'dmat4x3', 'dmat4']
106 shaders = ['frag', 'vert']
107 glsl_ver = ['150', '400']
108 if not names_only:
109 for ver in glsl_ver:
110 utils.safe_makedirs(get_dir_name(ver, 'compiler'))
112 for t_name, shader, ver in itertools.product(type_names, shaders, glsl_ver):
113 yield t_name, shader, ver, names_only
116 def all_execution_tests(names_only):
117 """Creates all the combinations for in/out shader runner tests."""
119 assert isinstance(names_only, bool)
120 type_names = ['double', 'dvec2', 'dvec3', 'dvec4']
121 glsl_ver = ['150', '400']
122 if not names_only:
123 for ver in glsl_ver:
124 utils.safe_makedirs(get_dir_name(ver, 'execution'))
126 for t_name, ver in itertools.product(type_names, glsl_ver):
127 yield t_name, ver, names_only
130 def main():
131 """Main function."""
133 parser = argparse.ArgumentParser(
134 description="Generate in/out tests for fp64")
135 parser.add_argument(
136 '--names-only',
137 dest='names_only',
138 action='store_true',
139 default=False,
140 help="Don't output files, just generate a list of filenames to stdout")
141 args = parser.parse_args()
143 for test_args in all_compilation_tests(args.names_only):
144 generate_compilation_tests(*test_args)
146 for test_args in all_execution_tests(args.names_only):
147 generate_execution_tests(*test_args)
150 if __name__ == '__main__':
151 main()