fix the spelling in whole piglit
[piglit.git] / generated_tests / random_ubo-arb_uniform_buffer_object.py
blob0341c6bfc8132680069f6afbced78f3f71a095ad
1 #!/usr/bin/env python3
2 # coding=utf-8
4 # Copyright (c) 2014 Intel Corporation
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 # SOFTWARE.
24 import os
25 import errno
26 import random
27 import random_ubo
29 def do_test(requirements, packing, seed=0):
30 random.seed(seed, version=2)
31 path = os.path.join("spec", "arb_uniform_buffer_object", "execution")
33 try:
34 os.makedirs(path)
35 except OSError as exc:
36 if exc.errno == errno.EEXIST and os.path.isdir(path):
37 pass
38 else:
39 raise
40 pass
42 basename = random_ubo.generate_file_name(requirements, packing)
43 fullname = os.path.join(path, basename)
45 file = open(fullname, "w")
47 fields, required_layouts = random_ubo.generate_ubo(
48 requirements,
49 random_ubo.ALL130_TYPES)
51 layouts = random_ubo.generate_layouts(
52 fields,
53 required_layouts,
54 # Due to bugs in the NVIDIA closed-source driver, do not randomly
55 # generate layout(row_major) on structures. Several tests will,
56 # however, do this explicitly.
57 False)
59 blocks = random_ubo.generate_block_list(
60 130,
61 packing,
62 fields,
63 layouts)
65 print(basename)
66 file.write(random_ubo.emit_shader_test(
67 blocks,
68 packing,
69 130,
70 ["GL_ARB_uniform_buffer_object","GL_ARB_arrays_of_arrays"]))
72 file.close()
74 all_packing = [random_ubo.std140_packing_rules(),
75 random_ubo.shared_packing_rules()]
77 all_requirements = []
79 # Generate a test for each matrix type that:
81 # - Explicitly declares one as row-major and another as column-major.
83 # - Embeds the matrix in a structure without a layout.
85 # - Embeds the matrix in a structure with a row-major layout.
87 # - Embeds the matrix in a structure with a column-major layout.
89 # - Each of the above in an array
91 for m in ["mat2x2", "mat2x3", "mat2x4",
92 "mat3x2", "mat3x3", "mat3x4",
93 "mat4x2", "mat4x3", "mat4x4"]:
94 all_requirements.append([["row_major", m], ["column_major", m]])
95 all_requirements.append([["#column_major", "struct", m]])
96 all_requirements.append([["row_major", "struct", m]])
97 all_requirements.append([["column_major", "struct", m]])
99 all_requirements.append([["row_major", "array", m],
100 ["column_major", "array", m]])
101 all_requirements.append([["#column_major", "struct", "array", m]])
102 all_requirements.append([["row_major", "struct", "array", m]])
103 all_requirements.append([["column_major", "struct", "array", m]])
105 all_requirements.append([["#column_major", "array", "struct", m]])
106 all_requirements.append([["row_major", "array", "struct", m]])
107 all_requirements.append([["column_major", "array", "struct", m]])
109 all_requirements.append([["#column_major", "array", "struct", "array", m]])
110 all_requirements.append([["row_major", "array", "struct", "array", m]])
111 all_requirements.append([["column_major", "array", "struct", "array", m]])
113 # Also add some struct-nesting tests.
115 all_requirements.append([["struct", "struct"]])
116 all_requirements.append([["struct", "struct", "struct"]])
117 all_requirements.append([["struct", "array", "struct"]])
118 all_requirements.append([["array", "struct", "struct"]])
119 all_requirements.append([["array", "struct", "array", "struct"]])
121 all_requirements.append([["struct", "array", "array", "struct"]])
122 all_requirements.append([["struct", "array", "array", "array", "struct"]])
123 all_requirements.append([["array", "array", "struct", "array"]])
124 all_requirements.append([["struct", "array", "array", "array"]])
126 for p in all_packing:
127 for r in all_requirements:
128 do_test(r, p)