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 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
44 static const char *const vs_source
=
46 "void main() { gl_Position = vec4(0.0); }\n";
49 static const char *const tcs_source_template
=
51 "#extension GL_ARB_tessellation_shader: require\n"
52 "layout(vertices = %d) out;\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"
58 static char *tcs_source
;
61 static const char *const tes_source
=
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
;
70 test_tcs_params(const int vertices
)
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
,
81 glGetProgramiv(prog
, GL_TESS_CONTROL_OUTPUT_VERTICES
, &v
);
83 fprintf(stderr
, "GL_TESS_CONTROL_OUTPUT_VERTICES "
84 "is %d, expected %d for program \n%s\n",
85 v
, vertices
, tcs_source
);
94 piglit_init(int argc
, char **argv
)
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
;
113 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
115 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);