2 # Copyright (c) 2010, 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 tests for builtin const equality tests """
28 from mako
import exceptions
30 from templates
import template_file
31 from modules
import utils
33 TEMPLATE
= template_file(os
.path
.basename(os
.path
.splitext(__file__
)[0]),
34 'template.shader_test.mako')
41 ["vec3(13.4, -0.9, 12.55)",
42 "vec3(13.4, 12.0, -55.3)",
43 "bvec3(true, false, false)"
45 ["vec4(-2.0, 0.0, 0.123, -1000.5)",
46 "vec4(-2.4, 0.0, 0.456, 12.5)",
47 "bvec4(false, true, false, false)"
55 "bvec3(false, false, false)"
57 ["ivec4(11, 1000, 1, -18)",
58 "ivec4(55, 1000, -21, -17)",
59 "bvec4(false, true, false, false)"
61 ["bvec2(true, false)",
65 ["bvec3(false, true, false)",
66 "bvec3(false, false, true)",
67 "bvec3(true, false, false)"
69 ["bvec4(true, false, false, true)",
70 "bvec4(true, true, false, false)",
71 "bvec4(true, false, true, false)"
78 dirname
= os
.path
.join('spec', 'glsl-1.20', 'execution',
80 utils
.safe_makedirs(dirname
)
82 for test_id
, x
in enumerate(TEST_VECTORS
, start
=2):
86 "glsl-const-builtin-equal-{0:02d}.shader_test".format(test_id
))
90 with
open(name
, 'w') as f
:
92 f
.write(TEMPLATE
.render_unicode(
93 func
='equal', input=x
[0:2], expected
=x
[2]))
95 print(exceptions
.text_error_template().render(), file=sys
.stderr
)
101 "glsl-const-builtin-notEqual-{0:02d}.shader_test".format(test_id
))
103 # When generating the notEqual tests, each of the values in the
104 # expected result vector need to be inverted
105 expected
= re
.sub("true", "FALSE", x
[2])
106 expected
= re
.sub("false", "TRUE", expected
)
107 expected
= expected
.lower()
111 with
open(name
, 'w') as f
:
113 f
.write(TEMPLATE
.render_unicode(
114 func
='notEqual', input=x
[0:2], expected
=expected
))
116 print(exceptions
.text_error_template().render(), file=sys
.stderr
)
120 if __name__
== "__main__":