fbo-mrt-alphatest: Actually require MRTs to be available.
[piglit.git] / tests / spec / arb_shading_language_420pack / execution / multiple-layout-qualifiers.c
blobffc0f81e8af12f86134b94595798eb13e3919445
1 /*
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
13 * Software.
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."
32 * For example
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"
55 "\n"
56 "/* Use std140 to avoid needing to ref every single uniform */\n"
57 "layout(std140) uniform;\n"
58 "\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"
62 "};\n"
63 "\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"
67 "};\n"
68 "\n"
69 "uniform c {\n"
70 " layout(column_major) layout(row_major) mat4 a_rm3;\n"
71 " layout(row_major) layout(column_major) mat4 a_cm3;\n"
72 "};\n"
73 "\n"
74 "void main() {\n"
75 " gl_FragColor = (\n"
76 " a_cm1[0] + \n"
77 " a_cm2[0] + \n"
78 " a_cm3[0] + \n"
79 " a_rm1[0] + \n"
80 " a_rm2[0] + \n"
81 " a_rm3[0]);\n"
82 "}\n";
84 static struct {
85 const char *name;
86 bool row_major;
87 } uniforms[] = {
88 { "a_cm1", false },
89 { "a_cm2", false },
90 { "a_rm1", true },
91 { "a_rm2", true },
94 void
95 piglit_init(int argc, char **argv)
97 bool pass = true;
98 unsigned int i;
99 GLuint prog;
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++) {
106 GLuint index;
107 GLint row_major;
109 glGetUniformIndices(prog, 1, &uniforms[i].name, &index);
110 if (index == GL_INVALID_INDEX) {
111 printf("Failed to get index for %s\n",
112 uniforms[i].name);
113 pass = false;
114 continue;
117 glGetActiveUniformsiv(prog, 1, &index, GL_UNIFORM_IS_ROW_MAJOR,
118 &row_major);
120 if (row_major != uniforms[i].row_major) {
121 fprintf(stderr, "Uniform %s should %sbe row major\n",
122 uniforms[i].name,
123 uniforms[i].row_major ? "" : "not ");
124 pass = false;
128 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
131 enum piglit_result piglit_display(void)
133 /* UNREACHED */
134 return PIGLIT_FAIL;