arb_copy_image: test copying of different mipmap levels of a texture
[piglit.git] / generated_tests / gen_non-lvalue_tests.py
blobf0b733a21f8f3ad9d3c1f8f701b5e48f9fcba93f
1 # coding=utf-8
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
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 import os
25 import itertools
27 from templates import template_dir
28 from modules import utils
30 TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
32 _NAMES = {
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)'
44 components = '.xy'
45 elif type_name.endswith('3'):
46 var_as_vec4 = 'vec4(t.xyzx)'
47 components = '.xyz'
48 elif type_name.endswith('4'):
49 var_as_vec4 = 'vec4(t)'
50 components = ''
51 else:
52 var_as_vec4 = 'vec4(t)'
53 components = '.x'
55 if shader_target == 'vert':
56 dest = "gl_Position"
57 mode = 'attribute'
58 else:
59 mode = 'varying'
60 dest = "gl_FragColor"
62 filename = os.path.join(
63 dirname,
64 '{0}-{1}-non-lvalue-for-{2}.{3}'.format(
65 _NAMES[op], type_name, usage, shader_target))
67 print(filename)
68 with open(filename, 'w') as f:
69 f.write(TEMPLATES.get_template(
70 '{0}.glsl_parser_test.mako'.format(usage)).render_unicode(
71 type_name=type_name,
72 mode=mode,
73 dest=dest,
74 components=components,
75 var_as_vec4=var_as_vec4,
76 op=op))
79 def all_tests():
80 type_name = ['float', 'vec2', 'vec3', 'vec4', 'int', 'ivec2', 'ivec3',
81 'ivec4']
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):
87 yield t, o, u, s
90 def main():
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__':
99 main()