ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_pipeline_statistics_query / pipeline_stats_clip.c
blob7e2133210558494d738d52a4e5ce4920214da238
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 /** \file pipeline_stats_clip.c
26 * This test verifies that the clipper related tokens of
27 * ARB_pipeline_statistics_query() work as expected. I believe these values
28 * are safe to use on all hardware but I am not certain.
30 * As with the vertex information, there seems to be a clause which allows
31 * implementations to make non-deterministic values (13.5 quoted below).
33 * 13.5 (the chicken clause)
35 * Implementations are allowed to pass incoming primitives unchanged and to
36 * output multiple primitives for an incoming primitive due to implementation
37 * dependent reasons as long as the results of rendering otherwise remain
38 * unchanged.
40 * 13.5.2
41 * When BeginQuery is called with a target of CLIPPING_INPUT_PRIMITIVES_ARB,
42 * the clipping input primitives count maintained by the GL is set to zero.
43 * When a clipping input primitives query is active, the counter is
44 * incremented every time a primitive reaches the primitive clipping stage
45 * (see section 13.5).
47 * When BeginQuery is called with a target of CLIPPING_OUTPUT_PRIMITIVES_ARB,
48 * the clipping output primitives count maintained by the GL is set to zero.
49 * When a clipping output primitives query is active, the counter is
50 * incremented every time a primitive passes the primitive clipping stage.
51 * The actual number of primitives output by the primitive clipping stage for
52 * a particular input primitive is implementation dependent (see section 13.5)
53 * but must satisfy the following conditions.
55 * (Chicken clause 2)
56 * If RASTERIZER_DISCARD is enabled, implementations are allowed to
57 * discard primitives right after the optional transform feedback state
58 * (see Section 14.1). As a result, if RASTERIZER_DISCARD is enabled,
59 * the clipping input and output primitives count may not be
60 * incremented.
62 * To me, this makes it sound like this is impossible to test RASTERIZER_DISCARD
63 * reliably, so I won't bother.
66 #include "piglit-util-gl.h"
67 #include "pipestat_help.h"
69 PIGLIT_GL_TEST_CONFIG_BEGIN
70 config.supports_gl_compat_version = 30;
71 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
72 PIGLIT_GL_TEST_CONFIG_END
74 static const char *vs_src =
75 "#version 110 \n"
76 " \n"
77 "void main() \n"
78 "{ \n"
79 " gl_Position = gl_Vertex; \n"
80 "} \n";
82 static struct query queries[] = {
84 .query = GL_CLIPPING_INPUT_PRIMITIVES_ARB,
85 .min = NUM_PRIMS},
87 .query = GL_CLIPPING_OUTPUT_PRIMITIVES_ARB,
88 .min = NUM_PRIMS}
91 enum piglit_result
92 piglit_display(void)
94 enum piglit_result ret = do_query(queries, ARRAY_SIZE(queries));
95 #ifdef DISPLAY
96 piglit_present_results();
97 #endif
98 return ret;
101 void
102 piglit_init(int argc, char *argv[])
104 GLuint vs, prog;
106 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
108 piglit_require_gl_version(11);
109 piglit_require_GLSL();
111 do_query_init(queries, ARRAY_SIZE(queries));
113 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_src);
114 prog = glCreateProgram();
115 glAttachShader(prog, vs);
116 glLinkProgram(prog);
118 if (!piglit_link_check_status(prog)) {
119 glDeleteProgram(prog);
120 piglit_report_result(PIGLIT_FAIL);
123 glUseProgram(prog);