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
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 from __future__
import print_function
, division
, absolute_import
30 from templates
import template_dir
31 from modules
import utils
33 TEMPLATES
= template_dir(os
.path
.basename(os
.path
.splitext(__file__
)[0]))
35 INTERPOLATION_MODES
= [
45 'gl_FrontSecondaryColor',
46 'gl_BackSecondaryColor'
49 VS_VARIABLES_FRONT_ONLY
= [
51 'gl_FrontSecondaryColor',
55 'gl_FrontColor': 'gl_BackColor',
56 'gl_BackColor': 'gl_FrontColor',
57 'gl_FrontSecondaryColor': 'gl_BackSecondaryColor',
58 'gl_BackSecondaryColor': 'gl_FrontSecondaryColor'
61 VS_TO_FS_VARIABLE_MAP
= {
62 'gl_FrontColor': 'gl_Color',
63 'gl_BackColor': 'gl_Color',
64 'gl_FrontSecondaryColor': 'gl_SecondaryColor',
65 'gl_BackSecondaryColor': 'gl_SecondaryColor'
69 def make_fs_vs_tests(fs_mode
, vs_mode
, dirname
):
70 if vs_mode
== fs_mode
:
73 for var
in VS_VARIABLES
:
74 filename
= os
.path
.join(
76 '{0}-{1}-{2}-{3}.shader_test'.format(
77 vs_mode
, var
, fs_mode
,
78 VS_TO_FS_VARIABLE_MAP
[var
]))
81 with
open(filename
, 'w') as f
:
82 f
.write(TEMPLATES
.get_template('vs-fs.shader_test.mako').render_unicode(
86 fs_variable
=VS_TO_FS_VARIABLE_MAP
[var
]))
89 def make_vs_unused_tests(vs_mode
, dirname
):
90 if vs_mode
== 'default':
93 for var
in VS_VARIABLES
:
94 filename
= os
.path
.join(
96 '{0}-{1}-unused-{2}.shader_test'.format(
98 VS_TO_FS_VARIABLE_MAP
[var
]))
101 with
open(filename
, 'w') as f
:
103 TEMPLATES
.get_template('vs-unused.shader_test.mako').render_unicode(
108 def make_fs_unused_tests(fs_mode
, vs_mode
, dirname
):
109 if fs_mode
== 'default':
112 for var
in VS_VARIABLES_FRONT_ONLY
:
113 filename
= os
.path
.join(
115 'unused-{0}-{1}-{2}.shader_test'.format(
117 VS_TO_FS_VARIABLE_MAP
[var
]))
120 with
open(filename
, 'w') as f
:
121 f
.write(TEMPLATES
.get_template('fs-unused.shader_test.mako').render_unicode(
125 fs_variable
=VS_TO_FS_VARIABLE_MAP
[var
]))
128 def make_vs_fs_unused_tests(fs_mode
, vs_mode
, dirname
):
129 if vs_mode
== fs_mode
:
132 for var
in VS_VARIABLES
:
133 filename
= os
.path
.join(
135 'unused-{0}-{1}-unused-{2}-{3}.shader_test'.format(
136 vs_mode
, var
, fs_mode
,
137 VS_TO_FS_VARIABLE_MAP
[var
]))
140 with
open(filename
, 'w') as f
:
141 f
.write(TEMPLATES
.get_template(
142 'fs-vs-unused.shader_test.mako').render_unicode(
146 fs_variable
=VS_TO_FS_VARIABLE_MAP
[var
]))
149 def make_vs_fs_flip_tests(fs_mode
, vs_mode
, dirname
):
150 if vs_mode
== fs_mode
:
153 for this_side
in VS_VARIABLES
:
154 other_side
= OTHER_SIDE_MAP
[this_side
]
155 filename
= os
.path
.join(
157 '{0}-{1}-{2}-{3}.shader_test'.format(
158 vs_mode
, this_side
, fs_mode
, other_side
))
161 with
open(filename
, 'w') as f
:
162 f
.write(TEMPLATES
.get_template(
163 'vs-fs-flip.shader_test.mako').render_unicode(
165 this_side_variable
=this_side
,
166 other_side_variable
=other_side
,
168 fs_variable
=VS_TO_FS_VARIABLE_MAP
[this_side
]))
173 dirname
= os
.path
.join('spec', 'glsl-1.30', 'linker',
174 'interpolation-qualifiers')
175 utils
.safe_makedirs(dirname
)
177 for fs_mode
, vs_mode
in itertools
.product(INTERPOLATION_MODES
, repeat
=2):
178 make_fs_vs_tests(fs_mode
, vs_mode
, dirname
)
179 make_vs_unused_tests(vs_mode
, dirname
)
180 make_fs_unused_tests(fs_mode
, vs_mode
, dirname
)
181 make_vs_fs_unused_tests(fs_mode
, vs_mode
, dirname
)
182 make_vs_fs_flip_tests(fs_mode
, vs_mode
, dirname
)
185 if __name__
== '__main__':