glsl-1.10: test a complex partial unroll scenario
[piglit.git] / generated_tests / interpolation-qualifier-built-in-variable.py
blob2d408c8be7de8690ad532f59dd85081a70e17798
1 # coding=utf-8
3 # Copyright © 2013, 2014 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 interpolation-qualifier tests."""
26 import os
27 import itertools
29 from templates import template_dir
30 from modules import utils
32 TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
34 INTERPOLATION_MODES = [
35 'flat',
36 'noperspective',
37 'smooth',
38 'default'
41 VS_VARIABLES = [
42 'gl_FrontColor',
43 'gl_BackColor',
44 'gl_FrontSecondaryColor',
45 'gl_BackSecondaryColor'
48 VS_VARIABLES_FRONT_ONLY = [
49 'gl_FrontColor',
50 'gl_FrontSecondaryColor',
53 OTHER_SIDE_MAP = {
54 'gl_FrontColor': 'gl_BackColor',
55 'gl_BackColor': 'gl_FrontColor',
56 'gl_FrontSecondaryColor': 'gl_BackSecondaryColor',
57 'gl_BackSecondaryColor': 'gl_FrontSecondaryColor'
60 VS_TO_FS_VARIABLE_MAP = {
61 'gl_FrontColor': 'gl_Color',
62 'gl_BackColor': 'gl_Color',
63 'gl_FrontSecondaryColor': 'gl_SecondaryColor',
64 'gl_BackSecondaryColor': 'gl_SecondaryColor'
68 def make_fs_vs_tests(fs_mode, vs_mode, dirname):
69 if vs_mode == fs_mode:
70 return
72 for var in VS_VARIABLES:
73 filename = os.path.join(
74 dirname,
75 '{0}-{1}-{2}-{3}.shader_test'.format(
76 vs_mode, var, fs_mode,
77 VS_TO_FS_VARIABLE_MAP[var]))
78 print(filename)
80 with open(filename, 'w') as f:
81 f.write(TEMPLATES.get_template('vs-fs.shader_test.mako').render_unicode(
82 vs_mode=vs_mode,
83 vs_variable=var,
84 fs_mode=fs_mode,
85 fs_variable=VS_TO_FS_VARIABLE_MAP[var]))
88 def make_vs_unused_tests(vs_mode, dirname):
89 if vs_mode == 'default':
90 return
92 for var in VS_VARIABLES:
93 filename = os.path.join(
94 dirname,
95 '{0}-{1}-unused-{2}.shader_test'.format(
96 vs_mode, var,
97 VS_TO_FS_VARIABLE_MAP[var]))
98 print(filename)
100 with open(filename, 'w') as f:
101 f.write(
102 TEMPLATES.get_template('vs-unused.shader_test.mako').render_unicode(
103 vs_mode=vs_mode,
104 vs_variable=var))
107 def make_fs_unused_tests(fs_mode, vs_mode, dirname):
108 if fs_mode == 'default':
109 return
111 for var in VS_VARIABLES_FRONT_ONLY:
112 filename = os.path.join(
113 dirname,
114 'unused-{0}-{1}-{2}.shader_test'.format(
115 var, fs_mode,
116 VS_TO_FS_VARIABLE_MAP[var]))
117 print(filename)
119 with open(filename, 'w') as f:
120 f.write(TEMPLATES.get_template('fs-unused.shader_test.mako').render_unicode(
121 vs_mode=vs_mode,
122 vs_variable=var,
123 fs_mode=fs_mode,
124 fs_variable=VS_TO_FS_VARIABLE_MAP[var]))
127 def make_vs_fs_unused_tests(fs_mode, vs_mode, dirname):
128 if vs_mode == fs_mode:
129 return
131 for var in VS_VARIABLES:
132 filename = os.path.join(
133 dirname,
134 'unused-{0}-{1}-unused-{2}-{3}.shader_test'.format(
135 vs_mode, var, fs_mode,
136 VS_TO_FS_VARIABLE_MAP[var]))
137 print(filename)
139 with open(filename, 'w') as f:
140 f.write(TEMPLATES.get_template(
141 'fs-vs-unused.shader_test.mako').render_unicode(
142 vs_mode=vs_mode,
143 vs_variable=var,
144 fs_mode=fs_mode,
145 fs_variable=VS_TO_FS_VARIABLE_MAP[var]))
148 def make_vs_fs_flip_tests(fs_mode, vs_mode, dirname):
149 if vs_mode == fs_mode:
150 return
152 for this_side in VS_VARIABLES:
153 other_side = OTHER_SIDE_MAP[this_side]
154 filename = os.path.join(
155 dirname,
156 '{0}-{1}-{2}-{3}.shader_test'.format(
157 vs_mode, this_side, fs_mode, other_side))
158 print(filename)
160 with open(filename, 'w') as f:
161 f.write(TEMPLATES.get_template(
162 'vs-fs-flip.shader_test.mako').render_unicode(
163 vs_mode=vs_mode,
164 this_side_variable=this_side,
165 other_side_variable=other_side,
166 fs_mode=fs_mode,
167 fs_variable=VS_TO_FS_VARIABLE_MAP[this_side]))
170 def main():
171 """main function."""
172 dirname = os.path.join('spec', 'glsl-1.30', 'linker',
173 'interpolation-qualifiers')
174 utils.safe_makedirs(dirname)
176 for fs_mode, vs_mode in itertools.product(INTERPOLATION_MODES, repeat=2):
177 make_fs_vs_tests(fs_mode, vs_mode, dirname)
178 make_vs_unused_tests(vs_mode, dirname)
179 make_fs_unused_tests(fs_mode, vs_mode, dirname)
180 make_vs_fs_unused_tests(fs_mode, vs_mode, dirname)
181 make_vs_fs_flip_tests(fs_mode, vs_mode, dirname)
184 if __name__ == '__main__':
185 main()