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
24 /** \file pipeline_stats_vert_adj.c
26 * This test verifies that the vertex shader related tokens of
27 * ARB_pipeline_statistics_query() work as expected. Much of this was derived
28 * from ignore-adjacent-vertices.c
31 * In case of primitive types with adjacency information (see sections 10.1.11
32 * through 10.1.14) only the vertices belonging to the main primitive are
33 * counted but not the adjacent vertices. In case of line loop primitives
34 * implementations are allowed to count the first vertex twice for the
35 * purposes of VERTICES_SUBMITTED_ARB queries. Additionally, vertices
36 * corresponding to incomplete primitives may or may not be counted.
38 * I read this as: the only definite thing we can test across implementation is
39 * discarding adjacent vertices.
42 #include "piglit-util-gl.h"
43 #include "pipestat_help.h"
45 PIGLIT_GL_TEST_CONFIG_BEGIN
46 /* I believe the adjacency tokens require 3.2 GS */
47 config
.supports_gl_compat_version
= 32;
48 config
.supports_gl_core_version
= 32;
49 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
50 PIGLIT_GL_TEST_CONFIG_END
52 static const char *vs_src
=
55 "in vec4 piglit_vertex; \n"
58 " gl_Position = piglit_vertex;\n"
61 static const char *fs_src
=
66 " gl_FragColor = vec4(0, 1, 0, 1); \n"
69 static struct query queries
[] = {
71 .query
= GL_PRIMITIVES_SUBMITTED_ARB
,
72 .min
= 1}, /* Going to emit a line */
74 .query
= GL_VERTICES_SUBMITTED_ARB
,
76 .max
= 4}, /*(26) Should VERTICES_SUBMITTED_ARB count adjacent
77 vertices in case of primitives with adjacency? */
79 .query
= GL_VERTEX_SHADER_INVOCATIONS_ARB
,
87 /* 4 components, 2 verts for a line, and 1 vert for adjacency per vertex
88 * that makes up the line. The values really don't matter for this.
90 static const float vertex_data
[] = {
91 0.0f
, 0.0f
, 0.0f
, 1.0f
, /* Adjacent vert */
92 0.2f
, 0.5f
, 0.0f
, 1.0f
, /* Vert 0 */
93 0.8f
, 0.5f
, 0.0f
, 1.0f
, /* Vert 1 */
94 1.0f
, 0.0f
, 0.0f
, 1.0f
/* Adjacent vert */
97 glBufferData(GL_ARRAY_BUFFER
, sizeof(vertex_data
), vertex_data
, GL_STREAM_DRAW
);
98 glDrawArrays(GL_LINES_ADJACENCY
, 0, 4);
100 piglit_present_results();
107 return do_query_func(queries
, ARRAY_SIZE(queries
), draw
);
111 piglit_init(int argc
, char *argv
[])
113 GLuint prog
, array
, buf
;
115 glGenVertexArrays(1, &array
);
116 glBindVertexArray(array
);
117 glGenBuffers(1, &buf
);
118 glBindBuffer(GL_ARRAY_BUFFER
, buf
);
120 prog
= piglit_build_simple_program(vs_src
, fs_src
);
122 glVertexAttribPointer(0, /* index */
125 GL_FALSE
, /* normalized */
128 glEnableVertexAttribArray(0);
131 glEnable(GL_RASTERIZER_DISCARD
);
134 do_query_init(queries
, ARRAY_SIZE(queries
));
136 if (!piglit_link_check_status(prog
)) {
137 glDeleteProgram(prog
);
138 piglit_report_result(PIGLIT_FAIL
);