summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2012-06-26 23:40:26 +0200
committerMarek Olšák <maraeo@gmail.com>2012-07-02 19:41:14 +0200
commitf4999a9a9d6f67cc750775ba3ea02855aa8dca1d (patch)
tree3c80e182a045c24b7791da1a01ffe7f07a1b1a23
parentf37e40809f2914106f1d43c939b10b35daba7d67 (diff)
time-elapsed: test GL_TIMESTAMP query
FYI, this test randomly fails when run in parallel with other tests regardless of the query type.
-rw-r--r--tests/all.tests4
-rw-r--r--tests/spec/ext_timer_query/time-elapsed.c44
2 files changed, 38 insertions, 10 deletions
diff --git a/tests/all.tests b/tests/all.tests
index dbe075677..07b4f49e1 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1650,6 +1650,10 @@ ext_timer_query = Group()
spec['EXT_timer_query'] = ext_timer_query
ext_timer_query['time-elapsed'] = concurrent_test('ext_timer_query-time-elapsed')
+arb_timer_query = Group()
+spec['ARB_timer_query'] = arb_timer_query
+arb_timer_query['query GL_TIMESTAMP'] = concurrent_test('ext_timer_query-time-elapsed timestamp')
+
ext_transform_feedback = Group()
spec['EXT_transform_feedback'] = ext_transform_feedback
for mode in ['interleaved_ok_base', 'interleaved_ok_range',
diff --git a/tests/spec/ext_timer_query/time-elapsed.c b/tests/spec/ext_timer_query/time-elapsed.c
index 09be416e1..ce27ce0fa 100644
--- a/tests/spec/ext_timer_query/time-elapsed.c
+++ b/tests/spec/ext_timer_query/time-elapsed.c
@@ -26,8 +26,7 @@
/**
* @file time-elapsed.c
*
- * Tests that conditional rendering appropriately affects commands
- * inside of display lists.
+ * Test TIME_ELAPSED and TIMESTAMP queries.
*/
#include <sys/time.h>
@@ -37,6 +36,11 @@ PIGLIT_GL_TEST_MAIN(
128 /*window_height*/,
GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA)
+enum {
+ TIME_ELAPSED,
+ TIMESTAMP
+} test = TIME_ELAPSED;
+
static float
get_time(void)
{
@@ -60,18 +64,26 @@ get_time(void)
}
static float
-draw(GLuint q, int iters)
+draw(GLuint *q, int iters)
{
float start_time, end_time;
int i;
start_time = get_time();
- glBeginQuery(GL_TIME_ELAPSED, q);
+ if (test == TIMESTAMP) {
+ glQueryCounter(q[0], GL_TIMESTAMP);
+ } else {
+ glBeginQuery(GL_TIME_ELAPSED, q[0]);
+ }
for (i = 0; i < iters; i++) {
piglit_draw_rect(-1, -1, 2, 2);
}
- glEndQuery(GL_TIME_ELAPSED);
+ if (test == TIMESTAMP) {
+ glQueryCounter(q[1], GL_TIMESTAMP);
+ } else {
+ glEndQuery(GL_TIME_ELAPSED);
+ }
/* This glFinish() is important, since this is used in a
* timing loop.
@@ -84,11 +96,18 @@ draw(GLuint q, int iters)
}
static float
-get_gpu_time(GLuint q)
+get_gpu_time(GLuint *q)
{
GLint64EXT elapsed;
- glGetQueryObjecti64vEXT(q, GL_QUERY_RESULT, &elapsed);
+ if (test == TIMESTAMP) {
+ GLint64 start, end;
+ glGetQueryObjecti64vEXT(q[0], GL_QUERY_RESULT, &start);
+ glGetQueryObjecti64vEXT(q[1], GL_QUERY_RESULT, &end);
+ elapsed = end - start;
+ } else {
+ glGetQueryObjecti64vEXT(q[0], GL_QUERY_RESULT, &elapsed);
+ }
return elapsed / 1000.0 / 1000.0 / 1000.0;
}
@@ -98,7 +117,7 @@ piglit_display(void)
{
bool pass = true;
float green[4] = {0.0, 1.0, 0.0, 0.0};
- GLuint q;
+ GLuint q[2];
int iters;
int num_results = 5;
float cpu_time[num_results];
@@ -111,7 +130,7 @@ piglit_display(void)
int i;
glColor4f(0.0, 1.0, 0.0, 0.0);
- glGenQueries(1, &q);
+ glGenQueries(2, q);
/* Prime the drawing pipe before we start measuring time,
* since the first draw call is likely to be slower than all
@@ -238,7 +257,7 @@ retry:
piglit_present_results();
- glDeleteQueries(1, &q);
+ glDeleteQueries(2, q);
return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
@@ -252,4 +271,9 @@ piglit_init(int argc, char **argv)
}
piglit_require_extension("GL_EXT_timer_query");
+
+ if (argc == 2 && strcmp(argv[1], "timestamp") == 0) {
+ piglit_require_extension("GL_ARB_timer_query");
+ test = TIMESTAMP;
+ }
}