summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBartosz Tomczyk <[email protected]>2017-03-30 22:31:09 +0200
committerTimothy Arceri <[email protected]>2017-04-03 10:33:31 +1000
commit8d919ba3846aa5cd9dc85e0bdb98e71292ed9c97 (patch)
treea326be9b3d31c0c10dd91f637003bd287a4c7ade /src
parentdbdd7231c252cbed52a196c86725730c07cd8006 (diff)
mesa/glthread: Call unmarshal_batch directly in glthread_finish
Call it directly when batch queue is empty. This avoids costly thread synchronisation. This commit improves performance of games that have previously regressed with mesa_glthread=true. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/glthread.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 06115b916db..3f07c420d47 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -194,16 +194,12 @@ _mesa_glthread_restore_dispatch(struct gl_context *ctx)
}
}
-void
-_mesa_glthread_flush_batch(struct gl_context *ctx)
+static void
+_mesa_glthread_flush_batch_locked(struct gl_context *ctx)
{
struct glthread_state *glthread = ctx->GLThread;
- struct glthread_batch *batch;
+ struct glthread_batch *batch = glthread->batch;
- if (!glthread)
- return;
-
- batch = glthread->batch;
if (!batch->used)
return;
@@ -223,10 +219,26 @@ _mesa_glthread_flush_batch(struct gl_context *ctx)
return;
}
- pthread_mutex_lock(&glthread->mutex);
*glthread->batch_queue_tail = batch;
glthread->batch_queue_tail = &batch->next;
pthread_cond_broadcast(&glthread->new_work);
+}
+
+void
+_mesa_glthread_flush_batch(struct gl_context *ctx)
+{
+ struct glthread_state *glthread = ctx->GLThread;
+ struct glthread_batch *batch;
+
+ if (!glthread)
+ return;
+
+ batch = glthread->batch;
+ if (!batch->used)
+ return;
+
+ pthread_mutex_lock(&glthread->mutex);
+ _mesa_glthread_flush_batch_locked(ctx);
pthread_mutex_unlock(&glthread->mutex);
}
@@ -252,12 +264,20 @@ _mesa_glthread_finish(struct gl_context *ctx)
if (pthread_self() == glthread->thread)
return;
- _mesa_glthread_flush_batch(ctx);
-
pthread_mutex_lock(&glthread->mutex);
- while (glthread->batch_queue || glthread->busy)
- pthread_cond_wait(&glthread->work_done, &glthread->mutex);
+ if (!(glthread->batch_queue || glthread->busy)) {
+ if (glthread->batch && glthread->batch->used) {
+ struct _glapi_table *dispatch = _glapi_get_dispatch();
+ glthread_unmarshal_batch(ctx, glthread->batch);
+ _glapi_set_dispatch(dispatch);
+ glthread_allocate_batch(ctx);
+ }
+ } else {
+ _mesa_glthread_flush_batch_locked(ctx);
+ while (glthread->batch_queue || glthread->busy)
+ pthread_cond_wait(&glthread->work_done, &glthread->mutex);
+ }
pthread_mutex_unlock(&glthread->mutex);
}