fix the spelling in whole piglit
[piglit.git] / generated_tests / gen_texture_lod_tests.py
blob8b5b6e720edba81f3f2d141c0953020320e95a33
1 # coding=utf-8
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
20 # SOFTWARE.
22 """ Generate spec/ARB_shader_texture_lod tests """
24 import os
25 import collections
27 from templates import template_dir
28 from modules import utils
30 TEMPLATES = template_dir(os.path.basename(os.path.splitext(__file__)[0]))
32 Parameters = collections.namedtuple(
33 'Parameters', ['coord', 'grad', 'dimensions', 'mode'])
36 LOD_TESTS = [
37 Parameters('float', 'float', '1D', 'texture1D'),
38 Parameters('vec2', 'float', '1D', 'texture1DProj'),
39 Parameters('vec4', 'float', '1D', 'texture1DProj'),
40 Parameters('vec3', 'float', '1DShadow', 'shadow1D'),
41 Parameters('vec4', 'float', '1DShadow', 'shadow1DProj'),
42 Parameters('vec2', 'vec2', '2D', 'texture2D'),
43 Parameters('vec3', 'vec2', '2D', 'texture2DProj'),
44 Parameters('vec4', 'vec2', '2D', 'texture2DProj'),
45 Parameters('vec3', 'vec2', '2DShadow', 'shadow2D'),
46 Parameters('vec4', 'vec2', '2DShadow', 'shadow2DProj'),
47 Parameters('vec3', 'vec3', '3D', 'texture3D'),
48 Parameters('vec4', 'vec3', '3D', 'texture3DProj'),
49 Parameters('vec3', 'vec3', 'Cube', 'textureCube')
52 GRAD_TESTS = LOD_TESTS + [
53 Parameters('vec2', 'vec2', '2DRect', 'texture2DRect'),
54 Parameters('vec3', 'vec2', '2DRect', 'texture2DRectProj'),
55 Parameters('vec3', 'vec2', '2DRectShadow', 'shadow2DRect'),
56 Parameters('vec4', 'vec2', '2DRectShadow', 'shadow2DRectProj')
60 def get_extensions(mode):
61 """ If this test uses GL_ARB_texture_rectangle add it
63 GL_ARB_texture_rectangle is an odd extension, it is on by default, so don't
64 generate a #extension in the shader, just in the config block.
66 """
67 if 'Rect' in mode:
68 return 'GL_ARB_shader_texture_lod GL_ARB_texture_rectangle'
69 return 'GL_ARB_shader_texture_lod'
72 def main():
73 """ Main function
75 Writes tests to generated_tests/spec/arb_shader_texture_lod/ directory
77 """
78 dirname = 'spec/arb_shader_texture_lod/compiler'
79 utils.safe_makedirs(dirname)
81 for params in LOD_TESTS:
82 name = os.path.join(
83 dirname,
84 "tex_lod-{mode}-{dimensions}-{coord}.frag".format(
85 mode=params.mode,
86 dimensions=params.dimensions,
87 coord=params.coord))
88 print(name)
89 with open(name, 'w+') as f:
90 f.write(TEMPLATES.get_template(
91 'frag_lod.glsl_parser_test.mako').render_unicode(param=params))
93 for params in GRAD_TESTS:
94 # Generate fragment shader test
95 name = os.path.join(
96 dirname,
97 "tex_grad-{mode}-{dimensions}-{coord}".format(
98 mode=params.mode,
99 dimensions=params.dimensions,
100 coord=params.coord))
102 for stage in ['frag', 'vert']:
103 print('{0}.{1}'.format(name, stage))
104 with open('{0}.{1}'.format(name, stage), 'w+') as f:
105 f.write(TEMPLATES.get_template(
106 'tex_grad.{0}.mako'.format(stage)).render_unicode(
107 param=params,
108 extensions=get_extensions(params.mode)))
111 if __name__ == '__main__':
112 main()