glsl-1.10: test mesa bug with forward declaration
[piglit.git] / generated_tests / gen_texture_lod_tests.py
blob41707fc4cf12dedb95fcb7d3a44a72d02c3b6350
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
26 import sys
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'])
39 LOD_TESTS = [
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.
69 """
70 if 'Rect' in mode:
71 return 'GL_ARB_shader_texture_lod GL_ARB_texture_rectangle'
72 return 'GL_ARB_shader_texture_lod'
75 def main():
76 """ Main function
78 Writes tests to generated_tests/spec/arb_shader_texture_lod/ directory
80 """
81 dirname = 'spec/arb_shader_texture_lod/compiler'
82 utils.safe_makedirs(dirname)
84 for params in LOD_TESTS:
85 name = os.path.join(
86 dirname,
87 "tex_lod-{mode}-{dimensions}-{coord}.frag".format(
88 mode=params.mode,
89 dimensions=params.dimensions,
90 coord=params.coord))
91 print(name)
92 with open(name, 'w+') as f:
93 try:
94 f.write(TEMPLATES.get_template(
95 'frag_lod.glsl_parser_test.mako').render_unicode(param=params))
96 except:
97 print(exceptions.text_error_template().render(), file=sys.stderr)
98 raise
100 for params in GRAD_TESTS:
101 # Generate fragment shader test
102 name = os.path.join(
103 dirname,
104 "tex_grad-{mode}-{dimensions}-{coord}".format(
105 mode=params.mode,
106 dimensions=params.dimensions,
107 coord=params.coord))
109 for stage in ['frag', 'vert']:
110 print('{0}.{1}'.format(name, stage))
111 with open('{0}.{1}'.format(name, stage), 'w+') as f:
112 try:
113 f.write(TEMPLATES.get_template(
114 'tex_grad.{0}.mako'.format(stage)).render_unicode(
115 param=params,
116 extensions=get_extensions(params.mode)))
117 except:
118 print(exceptions.text_error_template().render(), file=sys.stderr)
119 raise
122 if __name__ == '__main__':
123 main()