Mesa (master): trace/rbug: Use condvar on system that has it for blocking

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Fri Jun 5 02:02:09 UTC 2009


Module: Mesa
Branch: master
Commit: 61ffba44fd70abefd22366aa296b7afb04c6767a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=61ffba44fd70abefd22366aa296b7afb04c6767a

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Fri Jun  5 03:01:34 2009 +0100

trace/rbug: Use condvar on system that has it for blocking

---

 src/gallium/drivers/trace/tr_context.c |    5 +++++
 src/gallium/drivers/trace/tr_context.h |    1 +
 src/gallium/drivers/trace/tr_rbug.c    |    8 ++++++++
 3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index b04cc2c..dd5cca5 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -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);
 
diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h
index 770e975..0c2bf27 100644
--- a/src/gallium/drivers/trace/tr_context.h
+++ b/src/gallium/drivers/trace/tr_context.h
@@ -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;
diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c
index db9de8f..e2de108 100644
--- a/src/gallium/drivers/trace/tr_rbug.c
+++ b/src/gallium/drivers/trace/tr_rbug.c
@@ -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;




More information about the mesa-commit mailing list