ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_tessellation_shader / get-tes-params.c
blobca37da4880231621e6ea6e1d54a57f06a7d0aa10
1 /*
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
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 DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * \file get-tes-params.c
27 * Test tessellation evaluation shader layout getters.
30 #include "piglit-util-gl.h"
32 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config.supports_gl_compat_version = 32;
35 config.supports_gl_core_version = 32;
36 config.khr_no_error_support = PIGLIT_NO_ERRORS;
38 PIGLIT_GL_TEST_CONFIG_END
41 unsigned int prog;
44 static const char *const vs_source =
45 "#version 150\n"
46 "void main() { gl_Position = vec4(0.0); }\n";
49 static const struct {
50 GLenum prim_mode;
51 GLenum vertex_spacing;
52 GLenum ordering;
53 GLenum point_mode;
54 const char *source;
55 } tes_params[] = {
56 {GL_QUADS, GL_EQUAL, GL_CCW, GL_FALSE,
57 "#version 150\n"
58 "#extension GL_ARB_tessellation_shader: require\n"
59 "layout(quads) in;\n"
60 "void main() { gl_Position = vec4(0.0); }\n"},
62 {GL_TRIANGLES, GL_EQUAL, GL_CCW, GL_FALSE,
63 "#version 150\n"
64 "#extension GL_ARB_tessellation_shader: require\n"
65 "layout(triangles) in;\n"
66 "void main() { gl_Position = vec4(0.0); }\n"},
68 {GL_ISOLINES, GL_EQUAL, GL_CCW, GL_FALSE,
69 "#version 150\n"
70 "#extension GL_ARB_tessellation_shader: require\n"
71 "layout(isolines) in;\n"
72 "void main() { gl_Position = vec4(0.0); }\n"},
74 {GL_QUADS, GL_FRACTIONAL_ODD, GL_CCW, GL_FALSE,
75 "#version 150\n"
76 "#extension GL_ARB_tessellation_shader: require\n"
77 "layout(quads, fractional_odd_spacing) in;\n"
78 "void main() { gl_Position = vec4(0.0); }\n"},
80 {GL_QUADS, GL_FRACTIONAL_EVEN, GL_CCW, GL_FALSE,
81 "#version 150\n"
82 "#extension GL_ARB_tessellation_shader: require\n"
83 "layout(quads, fractional_even_spacing) in;\n"
84 "void main() { gl_Position = vec4(0.0); }\n"},
86 {GL_QUADS, GL_EQUAL, GL_CW, GL_FALSE,
87 "#version 150\n"
88 "#extension GL_ARB_tessellation_shader: require\n"
89 "layout(quads, cw) in;\n"
90 "void main() { gl_Position = vec4(0.0); }\n"},
92 {GL_QUADS, GL_EQUAL, GL_CCW, GL_TRUE,
93 "#version 150\n"
94 "#extension GL_ARB_tessellation_shader: require\n"
95 "layout(quads, point_mode) in;\n"
96 "void main() { gl_Position = vec4(0.0); }\n"},
100 static bool
101 test_param(GLenum pname, GLenum expected_value, const char *const source)
103 int v;
105 glGetProgramiv(prog, pname, &v);
106 if (v == expected_value)
107 return true;
109 fprintf(stderr, "%s is %s, expected %s for program \n%s\n",
110 piglit_get_gl_enum_name(pname),
111 piglit_get_gl_enum_name(v),
112 piglit_get_gl_enum_name(expected_value), source);
113 return false;
117 static bool
118 test_tes_params(void)
120 bool pass = true;
121 int i;
123 for (i = 0; i < ARRAY_SIZE(tes_params); ++i) {
124 prog = piglit_build_simple_program_multiple_shaders(
125 GL_VERTEX_SHADER, vs_source,
126 GL_TESS_EVALUATION_SHADER, tes_params[i].source,
129 pass = test_param(GL_TESS_GEN_MODE,
130 tes_params[i].prim_mode,
131 tes_params[i].source) && pass;
132 pass = test_param(GL_TESS_GEN_SPACING,
133 tes_params[i].vertex_spacing,
134 tes_params[i].source) && pass;
135 pass = test_param(GL_TESS_GEN_VERTEX_ORDER,
136 tes_params[i].ordering,
137 tes_params[i].source) && pass;
138 pass = test_param(GL_TESS_GEN_POINT_MODE,
139 tes_params[i].point_mode,
140 tes_params[i].source) && pass;
142 glDeleteProgram(prog);
144 return pass;
148 void
149 piglit_init(int argc, char **argv)
151 bool pass = true;
153 piglit_require_extension("GL_ARB_tessellation_shader");
155 pass = test_tes_params() && pass;
157 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
159 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
163 enum piglit_result
164 piglit_display(void)
166 return PIGLIT_PASS;