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
28 def do_test(requirements
, packing
):
29 path
= os
.path
.join("spec", "arb_uniform_buffer_object", "execution")
33 except OSError as exc
:
34 if exc
.errno
== errno
.EEXIST
and os
.path
.isdir(path
):
40 basename
= random_ubo
.generate_file_name(requirements
, packing
)
41 fullname
= os
.path
.join(path
, basename
)
43 file = open(fullname
, "w")
45 fields
, required_layouts
= random_ubo
.generate_ubo(
47 random_ubo
.ALL130_TYPES
)
49 layouts
= random_ubo
.generate_layouts(
52 # Due to bugs in the NVIDIA closed-source driver, do not randomly
53 # generate layout(row_major) on structures. Several tests will,
54 # however, do this explicitly.
57 blocks
= random_ubo
.generate_block_list(
64 file.write(random_ubo
.emit_shader_test(
68 ["GL_ARB_uniform_buffer_object","GL_ARB_arrays_of_arrays"]))
72 all_packing
= [random_ubo
.std140_packing_rules(),
73 random_ubo
.shared_packing_rules()]
77 # Generate a test for each matrix type that:
79 # - Explicitly declares one as row-major and another as column-major.
81 # - Embeds the matrix in a structure without a layout.
83 # - Embeds the matrix in a structure with a row-major layout.
85 # - Embeds the matrix in a structure with a column-major layout.
87 # - Each of the above in an array
89 for m
in ["mat2x2", "mat2x3", "mat2x4",
90 "mat3x2", "mat3x3", "mat3x4",
91 "mat4x2", "mat4x3", "mat4x4"]:
92 all_requirements
.append([["row_major", m
], ["column_major", m
]])
93 all_requirements
.append([["#column_major", "struct", m
]])
94 all_requirements
.append([["row_major", "struct", m
]])
95 all_requirements
.append([["column_major", "struct", m
]])
97 all_requirements
.append([["row_major", "array", m
],
98 ["column_major", "array", m
]])
99 all_requirements
.append([["#column_major", "struct", "array", m
]])
100 all_requirements
.append([["row_major", "struct", "array", m
]])
101 all_requirements
.append([["column_major", "struct", "array", m
]])
103 all_requirements
.append([["#column_major", "array", "struct", m
]])
104 all_requirements
.append([["row_major", "array", "struct", m
]])
105 all_requirements
.append([["column_major", "array", "struct", m
]])
107 all_requirements
.append([["#column_major", "array", "struct", "array", m
]])
108 all_requirements
.append([["row_major", "array", "struct", "array", m
]])
109 all_requirements
.append([["column_major", "array", "struct", "array", m
]])
111 # Also add some struct-nesting tests.
113 all_requirements
.append([["struct", "struct"]])
114 all_requirements
.append([["struct", "struct", "struct"]])
115 all_requirements
.append([["struct", "array", "struct"]])
116 all_requirements
.append([["array", "struct", "struct"]])
117 all_requirements
.append([["array", "struct", "array", "struct"]])
119 all_requirements
.append([["struct", "array", "array", "struct"]])
120 all_requirements
.append([["struct", "array", "array", "array", "struct"]])
121 all_requirements
.append([["array", "array", "struct", "array"]])
122 all_requirements
.append([["struct", "array", "array", "array"]])
124 for p
in all_packing
:
125 for r
in all_requirements
: