2 * Copyright (c) 2014 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 * Test that exceeding the implementation's maximum invocations
27 * value (GL_MAX_GEOMETRY_SHADER_INVOCATIONS) results in a compile
30 * From the ARB_gpu_shader5 specification:
32 * If a shader specifies an invocation count greater than
33 * the implementation-dependent maximum, it will fail to
38 #include "piglit-util-gl.h"
40 PIGLIT_GL_TEST_CONFIG_BEGIN
42 config
.supports_gl_compat_version
= 32;
43 config
.supports_gl_core_version
= 32;
45 PIGLIT_GL_TEST_CONFIG_END
56 static const char *gs_template
=
58 "#extension GL_ARB_gpu_shader5: enable\n"
60 "layout(points, invocations = %d) in;\n"
68 test_invocations_size(GLint size
, bool expect_ok
)
74 printf("Invocation count of %d should %s: ", size
,
75 expect_ok
? "compile successfully" : "produce a compile error");
77 (void)!asprintf(&shader_text
, gs_template
, size
);
78 shader
= glCreateShader(GL_GEOMETRY_SHADER
);
79 glShaderSource(shader
, 1, (const GLchar
**) &shader_text
, NULL
);
80 glCompileShader(shader
);
81 glGetShaderiv(shader
, GL_COMPILE_STATUS
, &ok
);
82 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
83 /* Details of the error have already been printed. */
84 printf("GL Error occurred.\n");
88 printf("Successful compile.\n");
90 printf("Compile error.\n");
91 return ok
== expect_ok
;
96 piglit_init(int argc
, char **argv
)
98 GLint max_invocations
;
102 piglit_require_extension("GL_ARB_gpu_shader5");
104 glGetIntegerv(GL_MAX_GEOMETRY_SHADER_INVOCATIONS
,
107 if (!piglit_check_gl_error(GL_NO_ERROR
))
108 piglit_report_result(PIGLIT_FAIL
);
110 for (i
= 1; i
<= max_invocations
; i
++) {
111 /* Test that this size is allowed. */
112 pass
= test_invocations_size(i
, true) && pass
;
115 /* Test that a count 1 above the max causes a compilation failure. */
116 pass
= test_invocations_size(max_invocations
+ 1, false) && pass
;
118 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);