framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_gpu_shader5 / compiler / invocations_count_too_large.c
blob9c6c643fcd991385f7f80622e9c2436b54209b65
1 /*
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
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
26 * Test that exceeding the implementation's maximum invocations
27 * value (GL_MAX_GEOMETRY_SHADER_INVOCATIONS) results in a compile
28 * error.
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
34 * compile.
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
48 enum piglit_result
49 piglit_display(void)
51 /* UNREACHED */
52 return PIGLIT_FAIL;
56 static const char *gs_template =
57 "#version 150\n"
58 "#extension GL_ARB_gpu_shader5: enable\n"
59 "\n"
60 "layout(points, invocations = %d) in;\n"
61 "\n"
62 "void main()\n"
63 "{\n"
64 "}\n";
67 static bool
68 test_invocations_size(GLint size, bool expect_ok)
70 char *shader_text;
71 GLint shader;
72 GLint 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");
85 return false;
87 if (ok)
88 printf("Successful compile.\n");
89 else
90 printf("Compile error.\n");
91 return ok == expect_ok;
95 void
96 piglit_init(int argc, char **argv)
98 GLint max_invocations;
99 int i;
100 bool pass = true;
102 piglit_require_extension("GL_ARB_gpu_shader5");
104 glGetIntegerv(GL_MAX_GEOMETRY_SHADER_INVOCATIONS,
105 &max_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);