tests: add ext_image_dma_buf_import-tex-modifier
[piglit.git] / generated_tests / gen_texture_query_lod_tests.py
blobbfff9fd3449319b04b85f8a1da73f3176dc95360
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 import os
25 import os.path
26 import sys
28 from mako import exceptions
30 from templates import template_file
31 from modules import utils
33 TEMPLATE = template_file(os.path.basename(os.path.splitext(__file__)[0]),
34 'template.glsl_parser_test.mako')
36 SAMPLER_TYPE_TO_COORD_TYPE = {
37 'sampler1D': 'float',
38 'isampler1D': 'float',
39 'usampler1D': 'float',
41 'sampler2D': 'vec2',
42 'isampler2D': 'vec2',
43 'usampler2D': 'vec2',
45 'sampler3D': 'vec3',
46 'isampler3D': 'vec3',
47 'usampler3D': 'vec3',
49 'samplerCube': 'vec3',
50 'isamplerCube': 'vec3',
51 'usamplerCube': 'vec3',
53 'sampler1DArray': 'float',
54 'isampler1DArray': 'float',
55 'usampler1DArray': 'float',
57 'sampler2DArray': 'vec2',
58 'isampler2DArray': 'vec2',
59 'usampler2DArray': 'vec2',
61 'samplerCubeArray': 'vec3',
62 'isamplerCubeArray': 'vec3',
63 'usamplerCubeArray': 'vec3',
65 'sampler1DShadow': 'float',
66 'sampler2DShadow': 'vec2',
67 'samplerCubeShadow': 'vec3',
68 'sampler1DArrayShadow': 'float',
69 'sampler2DArrayShadow': 'vec2',
70 'samplerCubeArrayShadow': 'vec3',
73 REQUIREMENTS = {
74 'ARB_texture_query_lod': {
75 'version': '1.30',
76 'extensions': 'GL_ARB_texture_query_lod'
78 'glsl-4.00': {
79 'version': '4.00',
80 'extensions': None
85 def main():
86 """Main function."""
87 for api, requirement in REQUIREMENTS.items():
88 lod = 'Lod' if api == 'glsl-4.00' else 'LOD'
89 dirname = os.path.join("spec", api.lower(), "compiler",
90 "built-in-functions")
91 utils.safe_makedirs(dirname)
93 for sampler_type, coord_type in SAMPLER_TYPE_TO_COORD_TYPE.items():
94 requirements = [requirement['extensions']] if requirement['extensions'] else []
96 # samplerCubeArray types are part GLSL 4.00
97 # or GL_ARB_texture_cube_map_array.
98 if api == "ARB_texture_query_lod" and sampler_type in [
99 'samplerCubeArray', 'isamplerCubeArray',
100 'usamplerCubeArray', 'samplerCubeArrayShadow']:
101 requirements.append('GL_ARB_texture_cube_map_array')
103 for execution_stage in ("vs", "fs"):
104 file_extension = 'frag' if execution_stage == 'fs' else 'vert'
105 filename = os.path.join(
106 dirname,
107 "textureQuery{0}-{1}.{2}".format(lod, sampler_type,
108 file_extension))
109 print(filename)
111 with open(filename, "w") as f:
112 try:
113 f.write(TEMPLATE.render_unicode(
114 version=requirement['version'],
115 extensions=requirements,
116 execution_stage=execution_stage,
117 sampler_type=sampler_type,
118 coord_type=coord_type,
119 lod=lod))
120 except:
121 print(exceptions.text_error_template().render(), file=sys.stderr)
122 raise
125 if __name__ == '__main__':
126 main()