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.c
26 * This test verifies that the vertex shader related tokens of
27 * ARB_pipeline_statistics_query() work as expected. OpenGL 4.4 Specification,
30 * Section 11.1.3 as quoted below makes it sound like we can't actually
31 * reliably count on any of these values. Consider that information when
32 * investigating failures.
35 * When BeginQuery is called with a target of VERTICES_SUBMITTED_ARB, the
36 * submitted vertices count maintained by the GL is set to zero. When a
37 * vertices submitted query is active, the submitted vertices count is
38 * incremented every time a vertex is transferred to the GL (see sections
39 * 10.3.4, and 10.5). In case of primitive types with adjacency information
40 * (see sections 10.1.11 through 10.1.14) only the vertices belonging to the
41 * main primitive are counted but not the adjacent vertices. In case of line
42 * loop primitives implementations are allowed to count the first vertex
43 * twice for the purposes of VERTICES_SUBMITTED_ARB queries. Additionally,
44 * vertices corresponding to incomplete primitives may or may not be
47 * When BeginQuery is called with a target of PRIMITIVES_SUBMITTED_ARB, the
48 * submitted primitives count maintained by the GL is set to zero. When a
49 * primitives submitted query is active, the submitted primitives count is
50 * incremented every time a point, line, triangle, or patch primitive is
51 * transferred to the GL (see sections 10.1, 10.3.5, and 10.5). Restarting a
52 * primitive topology using the primitive restart index has no effect on the
53 * issued primitives count. Incomplete primitives may or may not be counted.
55 * 11.1.3 (the chicken clause)
56 * Implementations are allowed to skip the execution of certain shader
57 * invocations, and to execute additional shader invocations for any shader
58 * type during programmable vertex processing due to implementation dependent
59 * reasons, including the execution of shader invocations that don't have an
60 * active program object present for the particular shader stage, as long as
61 * the results of rendering otherwise remain unchanged.
64 #include "piglit-util-gl.h"
65 #include "pipestat_help.h"
67 PIGLIT_GL_TEST_CONFIG_BEGIN
68 config
.supports_gl_compat_version
= 30;
69 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
70 PIGLIT_GL_TEST_CONFIG_END
72 static const char *vs_src
=
77 " gl_Position = gl_Vertex; \n"
80 static struct query queries
[] = {
82 .query
= GL_PRIMITIVES_SUBMITTED_ARB
,
85 .query
= GL_VERTICES_SUBMITTED_ARB
,
88 .query
= GL_VERTEX_SHADER_INVOCATIONS_ARB
,
92 /* Use DISPLAY for debug */
96 enum piglit_result ret
= do_query(queries
, ARRAY_SIZE(queries
));
98 piglit_present_results();
104 piglit_init(int argc
, char *argv
[])
108 piglit_require_gl_version(11);
109 piglit_require_GLSL();
112 glEnable(GL_RASTERIZER_DISCARD
);
114 do_query_init(queries
, ARRAY_SIZE(queries
));
116 /* Emit a very simply vertex shader just to make sure we actually go
117 * through the part of the pipeline we're trying to test. */
118 vs
= piglit_compile_shader_text(GL_VERTEX_SHADER
, vs_src
);
119 prog
= glCreateProgram();
120 glAttachShader(prog
, vs
);
123 if (!piglit_link_check_status(prog
)) {
124 glDeleteProgram(prog
);
125 piglit_report_result(PIGLIT_FAIL
);