2 * Copyright © 2013 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.
24 /** @file multiple-layout-qualifiers.c
26 * From the GL_ARB_shading_language_420pack spec:
28 * "More than one layout qualifier may appear in a single declaration. If
29 * the same layout-qualifier-name occurs in multiple layout qualifiers for
30 * the same declaration, the last one overrides the former ones."
34 * layout(column_major) layout(row_major)
36 * results in the qualification being row_major."
39 #include "piglit-util-gl.h"
41 PIGLIT_GL_TEST_CONFIG_BEGIN
43 config
.supports_gl_compat_version
= 10;
45 config
.window_width
= 10;
46 config
.window_height
= 10;
47 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
48 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
50 PIGLIT_GL_TEST_CONFIG_END
52 static const char *source
=
53 "#extension GL_ARB_shading_language_420pack: enable\n"
54 "#extension GL_ARB_uniform_buffer_object : enable\n"
56 "/* Use std140 to avoid needing to ref every single uniform */\n"
57 "layout(std140) uniform;\n"
59 "layout(column_major) uniform a {\n"
60 " layout(column_major) layout(row_major) mat4 a_rm1;\n"
61 " layout(row_major) layout(column_major) mat4 a_cm1;\n"
64 "layout(row_major) uniform b {\n"
65 " layout(column_major) layout(row_major) mat4 a_rm2;\n"
66 " layout(row_major) layout(column_major) mat4 a_cm2;\n"
70 " layout(column_major) layout(row_major) mat4 a_rm3;\n"
71 " layout(row_major) layout(column_major) mat4 a_cm3;\n"
95 piglit_init(int argc
, char **argv
)
101 piglit_require_extension("GL_ARB_shading_language_420pack");
102 piglit_require_extension("GL_ARB_uniform_buffer_object");
103 prog
= piglit_build_simple_program(NULL
, source
);
105 for (i
= 0; i
< ARRAY_SIZE(uniforms
); i
++) {
109 glGetUniformIndices(prog
, 1, &uniforms
[i
].name
, &index
);
110 if (index
== GL_INVALID_INDEX
) {
111 printf("Failed to get index for %s\n",
117 glGetActiveUniformsiv(prog
, 1, &index
, GL_UNIFORM_IS_ROW_MAJOR
,
120 if (row_major
!= uniforms
[i
].row_major
) {
121 fprintf(stderr
, "Uniform %s should %sbe row major\n",
123 uniforms
[i
].row_major
? "" : "not ");
128 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);
131 enum piglit_result
piglit_display(void)