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.
27 from templates
import template_file
28 from modules
import utils
30 TEMPLATE
= template_file(os
.path
.basename(os
.path
.splitext(__file__
)[0]),
31 'template.glsl_parser_test.mako')
33 SAMPLER_TYPE_TO_COORD_TYPE
= {
35 'isampler1D': 'float',
36 'usampler1D': 'float',
46 'samplerCube': 'vec3',
47 'isamplerCube': 'vec3',
48 'usamplerCube': 'vec3',
50 'sampler1DArray': 'float',
51 'isampler1DArray': 'float',
52 'usampler1DArray': 'float',
54 'sampler2DArray': 'vec2',
55 'isampler2DArray': 'vec2',
56 'usampler2DArray': 'vec2',
58 'samplerCubeArray': 'vec3',
59 'isamplerCubeArray': 'vec3',
60 'usamplerCubeArray': 'vec3',
62 'sampler1DShadow': 'float',
63 'sampler2DShadow': 'vec2',
64 'samplerCubeShadow': 'vec3',
65 'sampler1DArrayShadow': 'float',
66 'sampler2DArrayShadow': 'vec2',
67 'samplerCubeArrayShadow': 'vec3',
71 'ARB_texture_query_lod': {
73 'extensions': 'GL_ARB_texture_query_lod'
84 for api
, requirement
in REQUIREMENTS
.items():
85 lod
= 'Lod' if api
== 'glsl-4.00' else 'LOD'
86 dirname
= os
.path
.join("spec", api
.lower(), "compiler",
88 utils
.safe_makedirs(dirname
)
90 for sampler_type
, coord_type
in SAMPLER_TYPE_TO_COORD_TYPE
.items():
91 requirements
= [requirement
['extensions']] if requirement
['extensions'] else []
93 # samplerCubeArray types are part GLSL 4.00
94 # or GL_ARB_texture_cube_map_array.
95 if api
== "ARB_texture_query_lod" and sampler_type
in [
96 'samplerCubeArray', 'isamplerCubeArray',
97 'usamplerCubeArray', 'samplerCubeArrayShadow']:
98 requirements
.append('GL_ARB_texture_cube_map_array')
100 for execution_stage
in ("vs", "fs"):
101 file_extension
= 'frag' if execution_stage
== 'fs' else 'vert'
102 filename
= os
.path
.join(
104 "textureQuery{0}-{1}.{2}".format(lod
, sampler_type
,
108 with
open(filename
, "w") as f
:
109 f
.write(TEMPLATE
.render_unicode(
110 version
=requirement
['version'],
111 extensions
=requirements
,
112 execution_stage
=execution_stage
,
113 sampler_type
=sampler_type
,
114 coord_type
=coord_type
,
118 if __name__
== '__main__':