glsl: test loop unroll with uint overflow
[piglit.git] / tests / spec / arb_uniform_buffer_object / getactiveuniformsiv-uniform-matrix-stride.c
blobe7d8df83139ac35ef9d3ba176a26bafc309eb442
1 /*
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
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 getactiveuniformsiv-uniform-matrix-stride.c
26 * Tests that (std140 layout) uniform matrix strides are reported
27 * correctly through the API.
29 * Because std140 lays matrices out like arrays, and array elements
30 * get rounded up to the size of a vec4, MATRIX_STRIDE is either 16 or
31 * a non-matrix value.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config.supports_gl_compat_version = 10;
39 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
40 config.khr_no_error_support = PIGLIT_NO_ERRORS;
42 PIGLIT_GL_TEST_CONFIG_END
44 static const char fs_source[] =
45 "#extension GL_ARB_uniform_buffer_object : require\n"
46 "\n"
47 "layout(std140) uniform ub {\n"
48 " vec4 v4;\n"
49 " mat4 m4;\n"
50 " mat3 m3;\n"
51 " mat2 m2;\n"
52 " mat4 m4a[2];\n"
53 "};\n"
54 "uniform vec4 default_v4;\n"
55 "uniform mat4 default_m4;\n"
56 "\n"
57 "void main()\n"
58 "{\n"
59 " gl_FragColor = v4 + default_v4 + default_m4[0] + m4[0] + vec4(m3[0], 0.) + vec4(m2[0], 0., 0.) + m4a[0][0];\n"
60 "}\n";
62 void
63 piglit_init(int argc, char **argv)
65 bool pass = true;
66 GLuint prog;
67 const char *uniform_names[] = {
68 "v4",
69 "m4",
70 "m3",
71 "m2",
72 "m4a[0]",
73 "default_v4",
74 "default_m4",
76 int expected_strides[] = {
78 16,
79 16,
80 16,
81 16,
82 -1,
83 -1,
85 GLint strides[ARRAY_SIZE(uniform_names)];
86 GLuint uniform_indices[ARRAY_SIZE(uniform_names)];
87 int i;
89 piglit_require_extension("GL_ARB_uniform_buffer_object");
91 prog = piglit_build_simple_program(NULL, fs_source);
93 glGetUniformIndices(prog, ARRAY_SIZE(uniform_names), uniform_names,
94 uniform_indices);
95 glGetActiveUniformsiv(prog, ARRAY_SIZE(uniform_names), uniform_indices,
96 GL_UNIFORM_MATRIX_STRIDE, strides);
97 for (i = 0; i < ARRAY_SIZE(uniform_names); i++) {
98 printf("Uniform \"%s\": stride %d, expected %d",
99 uniform_names[i],
100 strides[i],
101 expected_strides[i]);
103 if (strides[i] != expected_strides[i]) {
104 printf(" FAIL");
105 pass = false;
108 printf("\n");
111 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
114 enum piglit_result piglit_display(void)
116 /* UNREACHED */
117 return PIGLIT_FAIL;