fix arb_query_buffer_object-coherency to warn on invalid GS results instead of fail
[piglit.git] / generated_tests / gen_inout_fp64.py
blobd24908c84b00a6562eb28b81579b3503ca4ae0e9
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 compilation tests."""
26 import argparse
27 import os
28 import itertools
29 import sys
31 from mako import exceptions
33 from templates import template_dir
34 from modules import utils
36 TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
38 def get_dir_name(ver, test_type):
39 """Returns the directory name to save tests given a GLSL version."""
41 assert isinstance(ver, str)
42 assert isinstance(test_type, str)
43 if ver == '150':
44 feature_dir = 'arb_gpu_shader_fp64'
45 else:
46 feature_dir = 'glsl-' + ver[0] + '.' + ver[1:]
48 return os.path.join('spec', feature_dir, test_type,
49 'inout')
52 def generate_compilation_tests(type_name, shader, ver, names_only):
53 """Generate in/out GLSL compilation tests."""
55 assert isinstance(type_name, str)
56 assert shader in ('vert', 'frag')
57 assert isinstance(ver, str)
58 assert isinstance(names_only, bool)
60 filename = os.path.join(
61 get_dir_name(ver, 'compiler'),
62 '{0}-{1}put-{2}.{3}'.format('fs' if shader == 'frag' else 'vs',
63 'out' if shader == 'frag' else 'in',
64 type_name, shader))
66 print(filename)
68 if not names_only:
69 with open(filename, 'w') as test_file:
70 try:
71 test_file.write(TEMPLATES.get_template(
72 'template.{0}.mako'.format(shader)).render_unicode(
73 glsl_version='{}.{}'.format(ver[0], ver[1:]),
74 glsl_version_int=ver,
75 type_name=type_name,
76 extra_params=',0.0' if type_name in ['dvec2', 'dvec3'] else ''))
77 except:
78 print(exceptions.text_error_template().render(), file=sys.stderr)
79 raise
82 def all_compilation_tests(names_only):
83 """Creates all the combinations for in/out compilation tests."""
85 assert isinstance(names_only, bool)
86 type_names = ['double', 'dvec2', 'dvec3', 'dvec4',
87 'dmat2', 'dmat2x3', 'dmat2x4',
88 'dmat3x2', 'dmat3', 'dmat3x4',
89 'dmat4x2', 'dmat4x3', 'dmat4']
90 shaders = ['frag', 'vert']
91 glsl_ver = ['150', '400']
92 if not names_only:
93 for ver in glsl_ver:
94 utils.safe_makedirs(get_dir_name(ver, 'compiler'))
96 for t_name, shader, ver in itertools.product(type_names, shaders, glsl_ver):
97 yield t_name, shader, ver, names_only
100 def main():
101 """Main function."""
103 parser = argparse.ArgumentParser(
104 description="Generate in/out compilation tests for fp64")
105 parser.add_argument(
106 '--names-only',
107 dest='names_only',
108 action='store_true',
109 default=False,
110 help="Don't output files, just generate a list of filenames to stdout")
111 args = parser.parse_args()
113 for test_args in all_compilation_tests(args.names_only):
114 generate_compilation_tests(*test_args)
117 if __name__ == '__main__':
118 main()