trace/rbug: Use condvar on system that has it for blocking
authorJakob Bornecrantz <jakob@vmware.com>
Fri, 5 Jun 2009 02:01:34 +0000 (03:01 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Fri, 5 Jun 2009 02:01:34 +0000 (03:01 +0100)
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/trace/tr_context.h
src/gallium/drivers/trace/tr_rbug.c

index b04cc2ce5666b27fd64bb7c6dfad5ea768af627e..dd5cca58dd262a22c1cf9b27b3d08ce65501bf6c 100644 (file)
@@ -127,9 +127,13 @@ trace_context_draw_block(struct trace_context *tr_ctx, int flag)
    /* wait for rbug to clear the blocked flag */
    while (tr_ctx->draw_blocked & flag) {
       tr_ctx->draw_blocked |= flag;
+#ifdef PIPE_THREAD_HAVE_CONDVAR
+      pipe_condvar_wait(tr_ctx->draw_cond, tr_ctx->draw_mutex);
+#else
       pipe_mutex_unlock(tr_ctx->draw_mutex);
       /* TODO sleep or use conditional */
       pipe_mutex_lock(tr_ctx->draw_mutex);
+#endif
    }
 
    pipe_mutex_unlock(tr_ctx->draw_mutex);
@@ -1191,6 +1195,7 @@ trace_context_create(struct pipe_screen *_screen,
                                                  rbug_blocker_flags,
                                                  0);
    pipe_mutex_init(tr_ctx->draw_mutex);
+   pipe_condvar_init(tr_ctx->draw_cond);
    pipe_mutex_init(tr_ctx->list_mutex);
    make_empty_list(&tr_ctx->shaders);
 
index 770e975a14a3da029c2485ac131847f0cf53f16e..0c2bf276895efc2fa3ccb059ace49aafd09a3ee5 100644 (file)
@@ -56,6 +56,7 @@ struct trace_context
       struct trace_texture *zsbuf;
    } curr;
 
+   pipe_condvar draw_cond;
    pipe_mutex draw_mutex;
    int draw_blocker;
    int draw_blocked;
index db9de8f3c4fd3f07d799f10f73f8add40cfb5634..e2de10800910a0af9043a399fca7171cf09e1026 100644 (file)
@@ -371,6 +371,10 @@ trace_rbug_context_draw_step(struct trace_rbug *tr_rbug, struct rbug_header *hea
    tr_ctx->draw_blocked &= ~step->step;
    pipe_mutex_unlock(tr_ctx->draw_mutex);
 
+#ifdef PIPE_THREAD_HAVE_CONDVAR
+   pipe_condvar_broadcast(tr_ctx->draw_cond);
+#endif
+
    pipe_mutex_unlock(tr_scr->list_mutex);
 
    return 0;
@@ -397,6 +401,10 @@ trace_rbug_context_draw_unblock(struct trace_rbug *tr_rbug, struct rbug_header *
    tr_ctx->draw_blocker &= ~unblock->unblock;
    pipe_mutex_unlock(tr_ctx->draw_mutex);
 
+#ifdef PIPE_THREAD_HAVE_CONDVAR
+   pipe_condvar_broadcast(tr_ctx->draw_cond);
+#endif
+
    pipe_mutex_unlock(tr_scr->list_mutex);
 
    return 0;