2 # Copyright (c) 2014 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 """ Generate spec/ARB_shader_texture_lod tests """
28 from mako
import exceptions
30 from templates
import template_dir
31 from modules
import utils
33 TEMPLATES
= template_dir(os
.path
.basename(os
.path
.splitext(__file__
)[0]))
35 Parameters
= collections
.namedtuple(
36 'Parameters', ['coord', 'grad', 'dimensions', 'mode'])
40 Parameters('float', 'float', '1D', 'texture1D'),
41 Parameters('vec2', 'float', '1D', 'texture1DProj'),
42 Parameters('vec4', 'float', '1D', 'texture1DProj'),
43 Parameters('vec3', 'float', '1DShadow', 'shadow1D'),
44 Parameters('vec4', 'float', '1DShadow', 'shadow1DProj'),
45 Parameters('vec2', 'vec2', '2D', 'texture2D'),
46 Parameters('vec3', 'vec2', '2D', 'texture2DProj'),
47 Parameters('vec4', 'vec2', '2D', 'texture2DProj'),
48 Parameters('vec3', 'vec2', '2DShadow', 'shadow2D'),
49 Parameters('vec4', 'vec2', '2DShadow', 'shadow2DProj'),
50 Parameters('vec3', 'vec3', '3D', 'texture3D'),
51 Parameters('vec4', 'vec3', '3D', 'texture3DProj'),
52 Parameters('vec3', 'vec3', 'Cube', 'textureCube')
55 GRAD_TESTS
= LOD_TESTS
+ [
56 Parameters('vec2', 'vec2', '2DRect', 'texture2DRect'),
57 Parameters('vec3', 'vec2', '2DRect', 'texture2DRectProj'),
58 Parameters('vec3', 'vec2', '2DRectShadow', 'shadow2DRect'),
59 Parameters('vec4', 'vec2', '2DRectShadow', 'shadow2DRectProj')
63 def get_extensions(mode
):
64 """ If this test uses GL_ARB_texture_rectangle add it
66 GL_ARB_texture_rectangle is an odd extension, it is on by default, so don't
67 generate a #extension in the shader, just in the config block.
71 return 'GL_ARB_shader_texture_lod GL_ARB_texture_rectangle'
72 return 'GL_ARB_shader_texture_lod'
78 Writes tests to generated_tests/spec/arb_shader_texture_lod/ directory
81 dirname
= 'spec/arb_shader_texture_lod/compiler'
82 utils
.safe_makedirs(dirname
)
84 for params
in LOD_TESTS
:
87 "tex_lod-{mode}-{dimensions}-{coord}.frag".format(
89 dimensions
=params
.dimensions
,
92 with
open(name
, 'w+') as f
:
94 f
.write(TEMPLATES
.get_template(
95 'frag_lod.glsl_parser_test.mako').render_unicode(param
=params
))
97 print(exceptions
.text_error_template().render(), file=sys
.stderr
)
100 for params
in GRAD_TESTS
:
101 # Generate fragment shader test
104 "tex_grad-{mode}-{dimensions}-{coord}".format(
106 dimensions
=params
.dimensions
,
109 for stage
in ['frag', 'vert']:
110 print('{0}.{1}'.format(name
, stage
))
111 with
open('{0}.{1}'.format(name
, stage
), 'w+') as f
:
113 f
.write(TEMPLATES
.get_template(
114 'tex_grad.{0}.mako'.format(stage
)).render_unicode(
116 extensions
=get_extensions(params
.mode
)))
118 print(exceptions
.text_error_template().render(), file=sys
.stderr
)
122 if __name__
== '__main__':