framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_pipeline_statistics_query / pipestat_help.c
bloba8c5f9e2a92f411b30e766467f6c57a8f0ff216a
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 pipestat_help.c
26 * Helper library for the pipeline statistics tests
29 #include <stdint.h>
30 #include <inttypes.h>
31 #include "piglit-util-gl.h"
32 #include "pipestat_help.h"
34 void
35 do_query_init(struct query *queries, const int count)
37 int i;
39 /* Some of the token require more than just having the extension, but
40 * all require at least having the extension.
42 piglit_require_extension("GL_ARB_pipeline_statistics_query");
44 for (i = 0; i < count; i++) {
45 GLint bits;
46 glGetQueryiv(queries[i].query, GL_QUERY_COUNTER_BITS, &bits);
47 if (bits == 0) {
48 printf("%s is unsupported.\n",
49 piglit_get_gl_enum_name(queries[i].query));
50 piglit_report_result(PIGLIT_SKIP);
55 for (i = 0; i < count; i++) {
56 glGenQueries(1, &queries[i].obj);
57 if (glGetError() != GL_NO_ERROR)
58 piglit_report_result(PIGLIT_FAIL);
62 enum piglit_result
63 do_query_func(const struct query *queries, const int count,
64 void (*draw)(void))
66 const float green[] = {0, 1, 0, 0};
67 int i;
69 glClearColor(1.0, 0.0, 0.0, 0.0);
70 glClear(GL_COLOR_BUFFER_BIT);
71 if (piglit_get_gl_version() <= 30)
72 glColor4fv(green);
74 for (i = 0; i < count; i++)
75 begin_query(&queries[i]);
77 draw();
79 for (i = 0; i < count; i++)
80 end_query(&queries[i]);
82 for (i = 0; i < count; i++) {
83 const struct query *q = &queries[i];
84 GLuint64 max = q->max != 0 ? q->max : q->min;
85 GLuint64 params;
87 glGetQueryObjectui64v(queries[i].obj, GL_QUERY_RESULT, &params);
88 if (q->min > params || max < params) {
89 fprintf(stderr,
90 "%s value was invalid.\n Expected: %" PRIu64 " - %" PRIu64 "\n Observed: %" PRIu64 "\n",
91 piglit_get_gl_enum_name(q->query),
92 q->min, max, params);
93 piglit_report_result(PIGLIT_FAIL);
97 return PIGLIT_PASS;
100 static void
101 default_draw(void)
103 piglit_draw_rect(-1, -1, 2, 2);
106 enum piglit_result
107 do_query(const struct query *queries, const int count)
109 return do_query_func(queries, count, default_draw);