3 # Copyright © 2012, 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.
27 from templates
import template_dir
28 from modules
import utils
30 TEMPLATES
= template_dir(os
.path
.basename(os
.path
.splitext(__file__
)[0]))
33 "++t": "preincrement",
34 "--t": "predecrement",
35 "t++": "postincrement",
36 "t--": "postdecrement",
40 def generate(dirname
, type_name
, op
, usage
, shader_target
):
41 """Generate glsl parser tests."""
42 if type_name
.endswith('2'):
43 var_as_vec4
= 'vec4(t.xyxy)'
45 elif type_name
.endswith('3'):
46 var_as_vec4
= 'vec4(t.xyzx)'
48 elif type_name
.endswith('4'):
49 var_as_vec4
= 'vec4(t)'
52 var_as_vec4
= 'vec4(t)'
55 if shader_target
== 'vert':
62 filename
= os
.path
.join(
64 '{0}-{1}-non-lvalue-for-{2}.{3}'.format(
65 _NAMES
[op
], type_name
, usage
, shader_target
))
68 with
open(filename
, 'w') as f
:
69 f
.write(TEMPLATES
.get_template(
70 '{0}.glsl_parser_test.mako'.format(usage
)).render_unicode(
74 components
=components
,
75 var_as_vec4
=var_as_vec4
,
80 type_name
= ['float', 'vec2', 'vec3', 'vec4', 'int', 'ivec2', 'ivec3',
82 op
= ["++t", "--t", "t++", "t--"]
83 usage
= ['assignment', 'out-parameter']
84 shader_target
= ['vert', 'frag']
86 for t
, o
, u
, s
in itertools
.product(type_name
, op
, usage
, shader_target
):
91 dirname
= os
.path
.join('spec', 'glsl-1.10', 'compiler', 'expressions')
92 utils
.safe_makedirs(dirname
)
94 for args
in all_tests():
95 generate(dirname
, *args
)
98 if __name__
== '__main__':