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_frag.c
26 * This test verifies that the fragment shader 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. One again we get the
29 * beloved, "can't rely on values clause." For the most part this makes senes
30 * since implementations can very well process too many vertices - but the
31 * clause also allows too few. The former case is accounted for within this code.
33 * 15.2 (Another chicken clause)
34 * Implementations are allowed to skip the execution of certain fragment
35 * shader invocations, and to execute additional fragment shader invocations
36 * during programmable fragment processing due to implementation dependent
37 * reasons, including the execution of fragment shader invocations when there
38 * isn't an active program object present for the fragment shader stage, as
39 * long as the results of rendering otherwise remain unchanged.
42 * When BeginQuery is called with a target of FRAGMENT_SHADER_INVOCATIONS_ARB,
43 * the fragment shader invocations count maintained by the GL is set to zero.
44 * When a fragment shader invocations query is active, the counter is
45 * incremented every time the fragment shader is invoked (see section 15.2).
46 * The result of fragment shader queries may be implementation dependent due
47 * to reasons described in section 15.2.
50 #include "piglit-util-gl.h"
51 #include "pipestat_help.h"
53 PIGLIT_GL_TEST_CONFIG_BEGIN
54 config
.supports_gl_compat_version
= 30;
55 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
56 config
.window_width
= TEST_WIDTH
;
57 config
.window_height
= TEST_HEIGHT
;
58 PIGLIT_GL_TEST_CONFIG_END
60 static const char *vs_src
=
65 " gl_Position = gl_Vertex; \n"
68 static const char *fs_src
=
73 " gl_FragColor = vec4(0, 1, 0, 1); \n"
76 static struct query queries
[] = {
78 .query
= GL_FRAGMENT_SHADER_INVOCATIONS_ARB
,
79 .min
= TEST_WIDTH
* TEST_HEIGHT
,
80 .max
= TEST_WIDTH
* TEST_HEIGHT
* 3 / 2},
82 * Intel hardware has some very unpredictable results for fragment
83 * shader invocations. After a day of head scratching, I've given up.
84 * Generating a real min, or max is not possible. The spec allows this.
85 * This will also help variance across vendors.
92 enum piglit_result ret
= do_query(queries
, ARRAY_SIZE(queries
));
94 piglit_present_results();
100 piglit_init(int argc
, char *argv
[])
104 piglit_require_gl_version(11);
105 piglit_require_GLSL();
107 do_query_init(queries
, ARRAY_SIZE(queries
));
109 prog
= piglit_build_simple_program(vs_src
, fs_src
);