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 pipestat_help.c
26 * Helper library for the pipeline statistics tests
31 #include "piglit-util-gl.h"
32 #include "pipestat_help.h"
35 do_query_init(struct query
*queries
, const int count
)
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
++) {
46 glGetQueryiv(queries
[i
].query
, GL_QUERY_COUNTER_BITS
, &bits
);
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
);
63 do_query_func(const struct query
*queries
, const int count
,
66 const float green
[] = {0, 1, 0, 0};
69 glClearColor(1.0, 0.0, 0.0, 0.0);
70 glClear(GL_COLOR_BUFFER_BIT
);
71 if (piglit_get_gl_version() <= 30)
74 for (i
= 0; i
< count
; i
++)
75 begin_query(&queries
[i
]);
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
;
87 glGetQueryObjectui64v(queries
[i
].obj
, GL_QUERY_RESULT
, ¶ms
);
88 if (q
->min
> params
|| max
< params
) {
90 "%s value was invalid.\n Expected: %" PRIu64
" - %" PRIu64
"\n Observed: %" PRIu64
"\n",
91 piglit_get_gl_enum_name(q
->query
),
93 piglit_report_result(PIGLIT_FAIL
);
103 piglit_draw_rect(-1, -1, 2, 2);
107 do_query(const struct query
*queries
, const int count
)
109 return do_query_func(queries
, count
, default_draw
);