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