2 * Copyright © 2013 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 * Test that built-in vertex input variables are enumerated by GetActiveAttrib()
27 * This is not explicitly stated in any specs before 4.3 core but it seems to
28 * be clarified in later specs
30 * From GL 4.3 core spec, section 11.1.1 (Vertex Attributes):
31 * "For GetActiveAttrib, all active vertex shader input variables are
32 * enumerated, including the special built-in inputs gl_VertexID and
35 * From GL 4.3 core spec, section F.5 (Change Log for Released Specifications):
36 * "Specify in section 11.1.1 that special built-in inputs and outputs such as
37 * gl_VertexID should be enumerated in the PROGRAM_INPUT and PROGRAM_OUTPUT
38 * interfaces, as well as the legacy function GetActiveAttrib. Add spec
39 * language counting the built-ins gl_VertexID and gl_InstanceID against the
40 * active attribute limit (Bug 9201)."
43 #include "piglit-util-gl.h"
45 PIGLIT_GL_TEST_CONFIG_BEGIN
47 config
.supports_gl_compat_version
= 31;
48 config
.supports_gl_core_version
= 31;
50 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
;
51 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
53 PIGLIT_GL_TEST_CONFIG_END
55 static const char *vstext
=
57 "in vec4 piglit_vertex;\n"
58 "flat out int instID;\n"
59 "flat out int vertID;\n"
61 " gl_Position = piglit_vertex;\n"
62 " instID = gl_InstanceID;\n"
63 " vertID = gl_VertexID;\n"
66 static const char *fstext
=
68 "flat in int instID;\n"
69 "flat in int vertID;\n"
72 " color = vec4(instID + vertID);\n"
78 check_that_attrib_is_active(const char *attrib_name
)
87 glGetProgramiv(prog
, GL_ACTIVE_ATTRIBUTES
, &numAttribs
);
88 for (i
= 0; i
< numAttribs
; i
++) {
89 glGetActiveAttrib(prog
, i
, sizeof(name
), &length
, &size
,
91 if (strcmp(name
, attrib_name
) == 0) {
92 return piglit_check_gl_error(GL_NO_ERROR
);
96 printf("%s was not counted as active.\n", attrib_name
);
97 return piglit_check_gl_error(GL_NO_ERROR
) && false;
101 piglit_init(int argc
, char **argv
)
105 prog
= piglit_build_simple_program(vstext
, fstext
);
108 if (!piglit_link_check_status(prog
)) {
109 glDeleteProgram(prog
);
110 piglit_report_result(PIGLIT_FAIL
);
113 pass
= check_that_attrib_is_active("piglit_vertex") && pass
;
115 pass
= check_that_attrib_is_active("gl_InstanceID") && pass
;
117 pass
= check_that_attrib_is_active("gl_VertexID") && pass
;
119 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);