arb_copy_image: test copying of different mipmap levels of a texture
[piglit.git] / generated_tests / gen_shader_intel_conservative_rasterization.py
blob5a3a5e9794e4bc7edd048d5eddc5055b496895b0
1 # coding=utf-8
3 # Copyright (C) 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 DEALINGS
22 # IN THE SOFTWARE.
24 """Generate a set of tests to verify that layout qualifiers introduced
25 by INTEL_conservative_rasterization are properly parsed.
27 This also verifies the interaction with ARB_post_depth_coverage.
29 This program outputs, to stdout, the name of each file it generates.
31 """
33 import os.path
34 from textwrap import dedent
36 from mako.template import Template
38 from modules import utils
40 def gen_header(status, gl_api, shader_stage):
41 """
42 Generate a GLSL program header.
44 Generate header code for INTEL_conservative_rasterization GLSL parser
45 tests that are expected to give status as result.
46 """
48 if shader_stage != 'frag':
49 status = 'fail'
50 print("%s - %s" % (shader_stage, status))
52 if gl_api == "gles":
53 glsl_version = ("3.20 es", "320 es")
54 else:
55 glsl_version = ("4.20", "420")
57 return dedent("""
59 * [config]
60 * expect_result: {0}
61 * glsl_version: {1}
62 * require_extensions: GL_INTEL_conservative_rasterization
63 * [end config]
65 #version {2}
66 #extension GL_INTEL_conservative_rasterization : enable
67 """.format(status, glsl_version[0], glsl_version[1]))
70 def gen(name, src, tests):
71 """
72 Expand a source template for the provided list of test definitions.
74 Generate a GLSL parser test for each of the elements of the
75 'tests' iterable, each of them should be a dictionary of
76 definitions that will be used as environment to render the source
77 template.
79 The file name of each test will be the concatenation of the 'name'
80 argument with the 'name' item from the respective test dictionary.
81 """
82 template = Template(dedent(src))
84 for t in product([{'name': name}], tests):
85 filename = os.path.join('spec',
86 'intel_conservative_rasterization',
87 'compiler',
88 '{0}.{1}.{2}'.format(t['name'],
89 t['gl_api'],
90 t['shader_stage']))
91 print(filename)
93 dirname = os.path.dirname(filename)
94 utils.safe_makedirs(dirname)
96 with open(filename, 'w') as f:
97 f.write(template.render(header=gen_header, **t))
100 shader_stages = [
101 {'shader_stage': 'frag'},
102 {'shader_stage': 'vert'}
106 gl_apis = [
107 {'gl_api': 'gl'},
108 {'gl_api': 'gles'}
112 def product(ps, *qss):
114 Generate the cartesian product of a number of lists of dictionaries.
116 Each generated element will be the union of some combination of
117 elements from the iterable arguments. The resulting value of each
118 'name' item will be the concatenation of names of the respective
119 element combination separated with dashes.
121 for q in (product(*qss) if qss else [{}]):
122 for p in ps:
123 r = dict(p, **q)
124 r['name'] = '-'.join(s['name'] for s in (p, q) if s.get('name'))
125 yield r
128 def main():
129 """Main function."""
133 # Test inner_coverage layout qualifier.
135 gen('inner_coverage', """
136 ${header('pass', gl_api, shader_stage)}
138 layout(inner_coverage) in;
140 void main()
143 """, product(gl_apis, shader_stages))
146 # Test depth_coverage layout qualifier.
148 gen('post_depth_coverage', """
149 ${header('pass', gl_api, shader_stage)}
151 layout(post_depth_coverage) in;
153 void main()
156 """, product(gl_apis, shader_stages))
159 # Test depth_coverage layout qualifier.
161 gen('inner_post_depth_coverage', """
162 ${header('fail', gl_api, shader_stage)}
164 layout(inner_coverage) in;
165 layout(post_depth_coverage) in;
167 void main()
170 """, product(gl_apis, shader_stages))
172 if __name__ == '__main__':
173 main()