1 /*
2  * Copyright © 2013 The Piglit project
3  *
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:
10  *
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.
14  *
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.
22  */
23 
24 /**
25  * \file output-type.c
26  *
27  * Test required errors for wrong GL_GEOMETRY_OUTPUT_TYPE parameters.
28  *
29  * From the ARB_geometry_shader4 spec (section Errors):
30  * "The error INVALID_VALUE is generated by ProgramParameteriARB if <pname> is
31  * GEOMETRY_OUTPUT_TYPE_ARB and <value> is not one of POINTS, LINE_STRIP or
32  * TRIANGLE_STRIP."
33  */
34 
35 #include "common.h"
36 
37 
38 /* Primitive types passed as geometry shader output type and expected error. */
39 static const struct primitive_geom_info primitives_out[] = {
40 	{GL_POINTS, GL_NO_ERROR},
41 
42 	{GL_LINES, GL_INVALID_VALUE},
43 	{GL_LINE_STRIP, GL_NO_ERROR},
44 	{GL_LINE_LOOP, GL_INVALID_VALUE},
45 
46 	{GL_TRIANGLES, GL_INVALID_VALUE},
47 	{GL_TRIANGLE_STRIP, GL_NO_ERROR},
48 	{GL_TRIANGLE_FAN, GL_INVALID_VALUE},
49 
50 	{GL_LINES_ADJACENCY, GL_INVALID_VALUE},
51 	{GL_LINE_STRIP_ADJACENCY, GL_INVALID_VALUE},
52 
53 	{GL_TRIANGLES_ADJACENCY, GL_INVALID_VALUE},
54 	{GL_TRIANGLE_STRIP_ADJACENCY, GL_INVALID_VALUE},
55 
56 	{GL_QUADS, GL_INVALID_VALUE},
57 	{GL_QUAD_STRIP, GL_INVALID_VALUE},
58 	{GL_POLYGON, GL_INVALID_VALUE},
59 };
60 
61 
62 PIGLIT_GL_TEST_CONFIG_BEGIN
63 	config.supports_gl_compat_version = 20;
64 	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
65 PIGLIT_GL_TEST_CONFIG_END
66 
67 
68 void
piglit_init(int argc,char ** argv)69 piglit_init(int argc, char **argv)
70 {
71 	bool pass = true;
72 	GLuint prog;
73 	int i;
74 
75 	piglit_require_extension("GL_ARB_geometry_shader4");
76 
77 	/* Create shader. */
78 	prog = create_shader(vs_text, gs_text, fs_text);
79 
80 	for (i = 0; i < ARRAY_SIZE(primitives_out); i++) {
81 		const struct primitive_geom_info p = primitives_out[i];
82 		printf("Testing %s.\n", piglit_get_prim_name(p.type));
83 		glProgramParameteri(prog, GL_GEOMETRY_OUTPUT_TYPE_ARB, p.type);
84 		pass = piglit_check_gl_error(p.error) && pass;
85 	}
86 
87 	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
88 }
89 
90 
91 enum piglit_result
piglit_display(void)92 piglit_display(void)
93 {
94 	/* Should never be reached */
95 	return PIGLIT_FAIL;
96 }
97