2 * Copyright © 2013 The Piglit project
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.
27 * Common code for glProgramParameter testing.
30 #include "piglit-util-gl.h"
33 struct primitive_geom_info
{
39 /* Primitive types passed as geometry shader input type and expected error. */
40 static const struct primitive_geom_info primitives_in
[] = {
41 {GL_POINTS
, GL_NO_ERROR
},
43 {GL_LINES
, GL_NO_ERROR
},
44 {GL_LINE_STRIP
, GL_INVALID_VALUE
},
45 {GL_LINE_LOOP
, GL_INVALID_VALUE
},
47 {GL_TRIANGLES
, GL_NO_ERROR
},
48 {GL_TRIANGLE_STRIP
, GL_INVALID_VALUE
},
49 {GL_TRIANGLE_FAN
, GL_INVALID_VALUE
},
51 {GL_LINES_ADJACENCY
, GL_NO_ERROR
},
52 {GL_LINE_STRIP_ADJACENCY
, GL_INVALID_VALUE
},
54 {GL_TRIANGLES_ADJACENCY
, GL_NO_ERROR
},
55 {GL_TRIANGLE_STRIP_ADJACENCY
, GL_INVALID_VALUE
},
57 {GL_QUADS
, GL_INVALID_VALUE
},
58 {GL_QUAD_STRIP
, GL_INVALID_VALUE
},
59 {GL_POLYGON
, GL_INVALID_VALUE
},
63 static const char vs_text
[] =
66 " gl_Position = vec4(0);\n"
69 static const char gs_text
[] =
70 "#extension GL_ARB_geometry_shader4: enable\n"
71 "uniform int vertex_count;\n"
74 " for (int i = 0; i < vertex_count; i++) {\n"
75 " gl_Position = vec4(0.0);\n"
80 static const char fs_text
[] =
83 " gl_FragColor = vec4(1.0);\n"
88 create_shader(const char *const vs_text
, const char *const gs_text
,
89 const char *const fs_text
)
91 const char *const varying
= "var";
92 GLuint vs
, gs
, fs
, prog
;
94 prog
= glCreateProgram();
95 vs
= piglit_compile_shader_text(GL_VERTEX_SHADER
, vs_text
);
96 glAttachShader(prog
, vs
);
98 gs
= piglit_compile_shader_text(GL_GEOMETRY_SHADER
, gs_text
);
99 glAttachShader(prog
, gs
);
102 fs
= piglit_compile_shader_text(GL_FRAGMENT_SHADER
, fs_text
);
103 glAttachShader(prog
, fs
);
106 glTransformFeedbackVaryings(prog
, 1, &varying
,
107 GL_INTERLEAVED_ATTRIBS
);
110 if (!piglit_check_gl_error(GL_NO_ERROR
))
111 piglit_report_result(PIGLIT_FAIL
);