ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_tessellation_shader / get-tcs-params.c
blob223d309b0368c36d0c73fa43d380cfe8f60b38c8
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-tcs-params.c
27 * Test tessellation control 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 char *const tcs_source_template =
50 "#version 150\n"
51 "#extension GL_ARB_tessellation_shader: require\n"
52 "layout(vertices = %d) out;\n"
53 "void main() {\n"
54 " gl_out[gl_InvocationID].gl_Position = vec4(0.0);\n"
55 " gl_TessLevelOuter = float[4](1.0, 1.0, 1.0, 1.0);\n"
56 " gl_TessLevelInner = float[2](1.0, 1.0);\n"
57 "}\n";
58 static char *tcs_source;
61 static const char *const tes_source =
62 "#version 150\n"
63 "#extension GL_ARB_tessellation_shader: require\n"
64 "layout(triangles) in;\n"
65 "void main() { gl_Position = vec4(0.0); }\n";
66 static char *tcs_source;
69 static bool
70 test_tcs_params(const int vertices)
72 int v;
74 sprintf(tcs_source, tcs_source_template, vertices);
75 prog = piglit_build_simple_program_multiple_shaders(
76 GL_VERTEX_SHADER, vs_source,
77 GL_TESS_CONTROL_SHADER, tcs_source,
78 GL_TESS_EVALUATION_SHADER, tes_source,
79 0);
81 glGetProgramiv(prog, GL_TESS_CONTROL_OUTPUT_VERTICES, &v);
82 if (v != vertices) {
83 fprintf(stderr, "GL_TESS_CONTROL_OUTPUT_VERTICES "
84 "is %d, expected %d for program \n%s\n",
85 v, vertices, tcs_source);
86 return false;
89 return true;
93 void
94 piglit_init(int argc, char **argv)
96 bool pass = true;
97 int i, max_vertices;
98 static const int vertices[] = {1, 2, 3, 4, 8, 16, 32};
100 piglit_require_extension("GL_ARB_tessellation_shader");
102 tcs_source = malloc(strlen(tcs_source_template) + 16);
104 for (i = 0; i < ARRAY_SIZE(vertices); ++i) {
105 pass = test_tcs_params(vertices[i]) && pass;
108 glGetIntegerv(GL_MAX_PATCH_VERTICES, &max_vertices);
109 pass = test_tcs_params(max_vertices) && pass;
111 free(tcs_source);
113 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
115 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
119 enum piglit_result
120 piglit_display(void)
122 return PIGLIT_PASS;