[Mesa-dev] [PATCH 13/25] mesa: Connect the generated GL command marshalling code to the build.

Timothy Arceri tarceri at itsqueeze.com
Tue Mar 7 06:21:25 UTC 2017


From: Eric Anholt <eric at anholt.net>

v2: Rebase on the Begin/End changes, and just disable this feature on
    non-GL-core.
v3: (Timothy Arceri) enable for non-GL-core contexts. Remove
    unrelated safe_mul() hunk. while loop style fix.
---
 src/mesa/Makefile.sources |  2 ++
 src/mesa/main/glthread.c  | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index b2d0783..134d5e9 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -125,20 +125,22 @@ MAIN_FILES = \
 	main/histogram.h \
 	main/image.c \
 	main/image.h \
 	main/imports.c \
 	main/imports.h \
 	main/light.c \
 	main/light.h \
 	main/lines.c \
 	main/lines.h \
 	main/macros.h \
+	main/marshal_generated.c \
+	main/marshal_generated.h \
 	main/matrix.c \
 	main/matrix.h \
 	main/mipmap.c \
 	main/mipmap.h \
 	main/mm.c \
 	main/mm.h \
 	main/mtypes.h \
 	main/multisample.c \
 	main/multisample.h \
 	main/objectlabel.c \
diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c
index 8877a69..c4d1031 100644
--- a/src/mesa/main/glthread.c
+++ b/src/mesa/main/glthread.c
@@ -47,22 +47,29 @@ glthread_allocate_batch(struct gl_context *ctx)
    /* TODO: handle memory allocation failure. */
    glthread->batch = calloc(1, sizeof(*glthread->batch));
    if (!glthread->batch)
       return;
    glthread->batch->buffer = malloc(MARSHAL_MAX_CMD_SIZE);
 }
 
 static void
 glthread_unmarshal_batch(struct gl_context *ctx, struct glthread_batch *batch)
 {
+   size_t pos = 0;
+
    _glapi_set_dispatch(ctx->CurrentServerDispatch);
 
+   while (pos < batch->used)
+      pos += _mesa_unmarshal_dispatch_cmd(ctx, &batch->buffer[pos]);
+
+   assert(pos == batch->used);
+
    free(batch->buffer);
    free(batch);
 }
 
 static void *
 glthread_worker(void *data)
 {
    struct gl_context *ctx = data;
    struct glthread_state *glthread = ctx->GLThread;
 
@@ -105,20 +112,28 @@ glthread_worker(void *data)
 }
 
 void
 _mesa_glthread_init(struct gl_context *ctx)
 {
    struct glthread_state *glthread = calloc(1, sizeof(*glthread));
 
    if (!glthread)
       return;
 
+   ctx->MarshalExec = _mesa_create_marshal_table(ctx);
+   if (!ctx->MarshalExec) {
+      free(glthread);
+      return;
+   }
+
+   ctx->CurrentClientDispatch = ctx->MarshalExec;
+
    pthread_mutex_init(&glthread->mutex, NULL);
    pthread_cond_init(&glthread->new_work, NULL);
    pthread_cond_init(&glthread->work_done, NULL);
 
    glthread->batch_queue_tail = &glthread->batch_queue;
    ctx->GLThread = glthread;
 
    glthread_allocate_batch(ctx);
 
    pthread_create(&glthread->thread, NULL, glthread_worker, ctx);
-- 
2.9.3



More information about the mesa-dev mailing list