2 * Copyright © 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 DEALINGS
25 * \file invalid-primitive.c
27 * From the ARB_tessellation_shader spec (Errors section):
29 * "The error INVALID_OPERATION is generated by Begin (or vertex array
30 * commands that implicitly call Begin) if the active program contains a
31 * tessellation control or evaluation shader and the primitive mode is not
34 * The error INVALID_OPERATION is generated by Begin (or vertex array
35 * commands that implicitly call Begin) if the primitive mode is PATCHES if
38 * * the active program contains no tessellation evaluation shader, or
39 * * no program is active."
41 * Test for all those errors except without active program.
44 #include "piglit-util-gl.h"
46 PIGLIT_GL_TEST_CONFIG_BEGIN
48 config
.supports_gl_compat_version
= 32;
49 config
.supports_gl_core_version
= 32;
50 config
.khr_no_error_support
= PIGLIT_HAS_ERRORS
;
52 PIGLIT_GL_TEST_CONFIG_END
55 static const char *const vs_source
=
57 "void main() { gl_Position = vec4(0.0); }\n";
59 static const char *const tcs_source
=
61 "#extension GL_ARB_tessellation_shader: require\n"
62 "layout(vertices = 3) out;\n"
63 "void main() { gl_out[gl_InvocationID].gl_Position = vec4(0.0); }\n";
65 static const char *const tes_source
=
67 "#extension GL_ARB_tessellation_shader: require\n"
68 "layout(triangles) in;\n"
69 "void main() { gl_Position = vec4(0.0); }\n";
71 static const char *const fs_source
=
73 "void main() { gl_FragColor = vec4(0.0); }\n";
77 piglit_init(int argc
, char **argv
)
81 unsigned int vao
, tess_prog
, normal_prog
;
82 static const GLenum primitive
[] = {
91 GL_LINE_STRIP_ADJACENCY
,
92 GL_TRIANGLES_ADJACENCY
,
93 GL_TRIANGLE_STRIP_ADJACENCY
,
96 piglit_require_extension("GL_ARB_tessellation_shader");
98 glGenVertexArrays(1, &vao
);
99 glBindVertexArray(vao
);
101 tess_prog
= piglit_build_simple_program_multiple_shaders(
102 GL_VERTEX_SHADER
, vs_source
,
103 GL_TESS_CONTROL_SHADER
, tcs_source
,
104 GL_TESS_EVALUATION_SHADER
, tes_source
,
105 GL_FRAGMENT_SHADER
, fs_source
,
107 normal_prog
= piglit_build_simple_program_multiple_shaders(
108 GL_VERTEX_SHADER
, vs_source
,
109 GL_FRAGMENT_SHADER
, fs_source
,
112 for (i
= 0; i
< ARRAY_SIZE(primitive
); ++i
) {
113 glUseProgram(tess_prog
);
114 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
115 glDrawArrays(primitive
[i
], 0, 12);
116 pass
= piglit_check_gl_error(GL_INVALID_OPERATION
) && pass
;
119 /* NV_gpu_shader5 allows drawing patches without tessellation
122 if (!piglit_is_extension_supported("GL_NV_gpu_shader5")) {
123 glUseProgram(normal_prog
);
124 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
125 glDrawArrays(GL_PATCHES
, 0, 12);
126 pass
= piglit_check_gl_error(GL_INVALID_OPERATION
) && pass
;
130 glDeleteProgram(tess_prog
);
131 glDeleteProgram(normal_prog
);
132 glBindVertexArray(0);
133 glDeleteVertexArrays(1, &vao
);
135 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
137 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);