2 * Copyright © 2009 Intel Corporation
3 * Copyright © 2010 Mathias Fröhlich
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * Ian Romanick <ian.d.romanick@intel.com>
26 * Mathias Fröhlich <m.froehlich@web.de>
31 * Simple test for GL_EXT_timer_query.
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config
.supports_gl_compat_version
= 10;
40 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
| PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_DEPTH
;
42 PIGLIT_GL_TEST_CONFIG_END
44 static GLuint timer_query
;
47 piglit_init(int argc
, char **argv
)
51 piglit_require_extension("GL_EXT_timer_query");
53 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
55 /* It is legal for a driver to support the query API but not have
56 * any query bits. I wonder how many applications actually check for
59 (*glGetQueryivARB
)(GL_TIME_ELAPSED
, GL_QUERY_COUNTER_BITS
, &query_bits
);
60 if (query_bits
== 0) {
61 piglit_report_result(PIGLIT_SKIP
);
64 (*glGenQueriesARB
)(1, &timer_query
);
75 glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
78 (*glBeginQueryARB
)(GL_TIME_ELAPSED_EXT
, timer_query
);
81 glColor3ub(0xff, 0xff, 0xff);
85 glVertex3f(piglit_width
, 0, 0);
86 glVertex3f(piglit_width
, piglit_height
, 0);
87 glVertex3f(0, piglit_height
, 0);
91 (*glEndQueryARB
)(GL_TIME_ELAPSED_EXT
);
93 /* In this case poll until available */
95 (*glGetQueryObjectivARB
)(timer_query
, GL_QUERY_RESULT_AVAILABLE
, &available
);
98 (*glGetQueryObjectivARB
)(timer_query
, GL_QUERY_RESULT
, &nsecs
);
99 (*glGetQueryObjecti64vEXT
)(timer_query
, GL_QUERY_RESULT
, &nsecs64
);
100 (*glGetQueryObjectui64vEXT
)(timer_query
, GL_QUERY_RESULT
, &nsecs64u
);
102 if ((nsecs
& 0xffffffff) != (nsecs64
& 0xffffffff)) {
103 printf("timer_query: 32 and 64-bit results differ!\n");
107 if ((nsecs
& 0xffffffff) != (nsecs64u
& 0xffffffff)) {
108 printf("timer_query: 32 and 64-bit unsigned results differ!\n");
112 /*printf("nsecs = %d %ld\n", nsecs, (long int) nsecs64);*/
114 piglit_present_results();