2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
26 * From the GL_ARB_uniform_buffer_object spec:
28 * "The row_major qualifier overrides only the column_major
29 * qualifier; other qualifiers are inherited. It only affects the
30 * layout of matrices. Elements within a matrix row will be
31 * contiguous in memory.
33 * The column_major qualifier overrides only the row_major
34 * qualifier; other qualifiers are inherited. It only affects the
35 * layout of matrices. Elements within a matrix column will be
36 * contiguous in memory.
38 * When multiple arguments are listed in a layout declaration,
39 * the affect will be the same as if they were declared one at a
40 * time, in order from left to right, each in turn inheriting
41 * from and overriding the result from the previous
46 * layout(row_major, column_major)
48 * results in the qualification being column_major."
51 #include "piglit-util-gl.h"
53 PIGLIT_GL_TEST_CONFIG_BEGIN
55 config
.supports_gl_compat_version
= 10;
56 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
57 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
59 PIGLIT_GL_TEST_CONFIG_END
61 static const char *source
=
62 "#extension GL_ARB_uniform_buffer_object : enable\n"
64 "/* Use std140 to avoid needing to ref every single uniform */\n"
65 "layout(std140) uniform;\n"
67 "layout(column_major) uniform a {\n"
69 " layout(column_major) mat4 a_cm2;\n"
70 " layout(row_major) mat4 a_rm1;\n"
71 " layout(row_major, column_major) mat4 a_cm3;\n"
72 " vec4 a_non_matrix;\n"
75 "layout(row_major) uniform b {\n"
77 " layout(column_major) mat4 b_cm1;\n"
78 " layout(row_major) mat4 b_rm2;\n"
79 " vec4 b_non_matrix;\n"
84 " layout(column_major) mat4 c_cm2;\n"
85 " layout(row_major) mat4 c_rm1;\n"
86 " vec4 c_non_matrix;\n"
89 "/* Set the default layout to row_major. Spam in some block layout\n"
90 " * qualifiers to make sure they don't accidentally clear row_major.\n"
92 "layout(row_major, std140) uniform;\n"
93 "layout(std140) uniform;\n"
95 "layout(column_major) uniform d {\n"
97 " layout(column_major) mat4 d_cm2;\n"
98 " layout(row_major) mat4 d_rm1;\n"
99 " vec4 d_non_matrix;\n"
102 "layout(row_major) uniform e {\n"
104 " layout(column_major) mat4 e_cm1;\n"
105 " layout(row_major) mat4 e_rm2;\n"
106 " vec4 e_non_matrix;\n"
109 "layout(std140) uniform f {\n"
111 " layout(column_major) mat4 f_cm1;\n"
112 " layout(row_major) mat4 f_rm2;\n"
113 " vec4 f_non_matrix;\n"
116 "uniform mat4 non_ubo_mat;\n"
117 "uniform vec4 non_mat;\n"
120 " gl_FragColor = (\n"
121 " non_ubo_mat[0] + \n"
154 { "a_non_matrix", false },
160 { "b_non_matrix", false },
165 { "c_non_matrix", false },
170 { "d_non_matrix", false },
175 { "e_non_matrix", false },
180 { "f_non_matrix", false },
185 { "non_ubo_mat", false },
186 { "non_mat", false },
190 piglit_init(int argc
, char **argv
)
196 piglit_require_extension("GL_ARB_uniform_buffer_object");
197 prog
= piglit_build_simple_program(NULL
, source
);
199 for (i
= 0; i
< ARRAY_SIZE(uniforms
); i
++) {
203 glGetUniformIndices(prog
, 1, &uniforms
[i
].name
, &index
);
204 if (index
== GL_INVALID_INDEX
) {
205 printf("Failed to get index for %s\n",
211 glGetActiveUniformsiv(prog
, 1, &index
, GL_UNIFORM_IS_ROW_MAJOR
,
214 if (row_major
!= uniforms
[i
].row_major
) {
215 fprintf(stderr
, "Uniform %s should %sbe row major\n",
217 uniforms
[i
].row_major
? "" : "not ");
222 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);
225 enum piglit_result
piglit_display(void)