diff options
-rw-r--r-- | src/mapi/glapi/gen/gl_apitemp.py | 8 | ||||
-rw-r--r-- | src/mesa/main/context.c | 13 | ||||
-rw-r--r-- | src/mesa/main/dlist.c | 28 | ||||
-rw-r--r-- | src/mesa/main/glthread.c | 7 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 21 | ||||
-rw-r--r-- | src/mesa/main/robustness.c | 4 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 8 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_api.c | 14 |
8 files changed, 69 insertions, 34 deletions
diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py index e1b94f50256..a8e5d814555 100644 --- a/src/mapi/glapi/gen/gl_apitemp.py +++ b/src/mapi/glapi/gen/gl_apitemp.py @@ -133,11 +133,11 @@ class PrintGlOffsets(gl_XML.gl_print_base): * #define KEYWORD1 * #define KEYWORD2 * #define NAME(func) gl##func - * #define DISPATCH(func, args, msg) \\ - * struct _glapi_table *dispatch = CurrentDispatch; \\ + * #define DISPATCH(func, args, msg) \\ + * struct _glapi_table *dispatch = CurrentClientDispatch; \\ * (*dispatch->func) args - * #define RETURN DISPATCH(func, args, msg) \\ - * struct _glapi_table *dispatch = CurrentDispatch; \\ + * #define RETURN DISPATCH(func, args, msg) \\ + * struct _glapi_table *dispatch = CurrentClientDispatch; \\ * return (*dispatch->func) args * */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 95a337b14bc..4b654de4582 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1213,7 +1213,7 @@ _mesa_initialize_context(struct gl_context *ctx, if (!ctx->OutsideBeginEnd) goto fail; ctx->Exec = ctx->OutsideBeginEnd; - ctx->CurrentDispatch = ctx->OutsideBeginEnd; + ctx->CurrentClientDispatch = ctx->CurrentServerDispatch = ctx->OutsideBeginEnd; ctx->FragmentProgram._MaintainTexEnvProgram = (getenv("MESA_TEX_PROG") != NULL); @@ -1342,6 +1342,7 @@ _mesa_free_context_data( struct gl_context *ctx ) free(ctx->OutsideBeginEnd); free(ctx->Save); free(ctx->ContextLost); + free(ctx->MarshalExec); /* Shared context state (display lists, textures, etc) */ _mesa_reference_shared_state(ctx, &ctx->Shared, NULL); @@ -1666,7 +1667,7 @@ _mesa_make_current( struct gl_context *newCtx, } } else { - _glapi_set_dispatch(newCtx->CurrentDispatch); + _glapi_set_dispatch(newCtx->CurrentClientDispatch); if (drawBuffer && readBuffer) { assert(_mesa_is_winsys_fbo(drawBuffer)); @@ -1768,19 +1769,19 @@ _mesa_get_current_context( void ) /** * Get context's current API dispatch table. * - * It'll either be the immediate-mode execute dispatcher or the display list - * compile dispatcher. + * It'll either be the immediate-mode execute dispatcher, the display list + * compile dispatcher, or the thread marshalling dispatcher. * * \param ctx GL context. * * \return pointer to dispatch_table. * - * Simply returns __struct gl_contextRec::CurrentDispatch. + * Simply returns __struct gl_contextRec::CurrentClientDispatch. */ struct _glapi_table * _mesa_get_dispatch(struct gl_context *ctx) { - return ctx->CurrentDispatch; + return ctx->CurrentClientDispatch; } /*@}*/ diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index 2976f62a591..7e440549e5b 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -9340,8 +9340,11 @@ _mesa_NewList(GLuint name, GLenum mode) vbo_save_NewList(ctx, name, mode); - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); + ctx->CurrentServerDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentServerDispatch); + if (ctx->MarshalExec == NULL) { + ctx->CurrentClientDispatch = ctx->CurrentServerDispatch; + } } @@ -9396,8 +9399,11 @@ _mesa_EndList(void) ctx->ExecuteFlag = GL_TRUE; ctx->CompileFlag = GL_FALSE; - ctx->CurrentDispatch = ctx->Exec; - _glapi_set_dispatch(ctx->CurrentDispatch); + ctx->CurrentServerDispatch = ctx->Exec; + _glapi_set_dispatch(ctx->CurrentServerDispatch); + if (ctx->MarshalExec == NULL) { + ctx->CurrentClientDispatch = ctx->CurrentServerDispatch; + } } @@ -9432,8 +9438,11 @@ _mesa_CallList(GLuint list) /* also restore API function pointers to point to "save" versions */ if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); + ctx->CurrentServerDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentServerDispatch); + if (ctx->MarshalExec == NULL) { + ctx->CurrentClientDispatch = ctx->CurrentServerDispatch; + } } } @@ -9555,8 +9564,11 @@ _mesa_CallLists(GLsizei n, GLenum type, const GLvoid * lists) /* also restore API function pointers to point to "save" versions */ if (save_compile_flag) { - ctx->CurrentDispatch = ctx->Save; - _glapi_set_dispatch(ctx->CurrentDispatch); + ctx->CurrentServerDispatch = ctx->Save; + _glapi_set_dispatch(ctx->CurrentServerDispatch); + if (ctx->MarshalExec == NULL) { + ctx->CurrentClientDispatch = ctx->CurrentServerDispatch; + } } } diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c index 76eb0cf7dac..8877a695f0c 100644 --- a/src/mesa/main/glthread.c +++ b/src/mesa/main/glthread.c @@ -54,6 +54,8 @@ glthread_allocate_batch(struct gl_context *ctx) static void glthread_unmarshal_batch(struct gl_context *ctx, struct glthread_batch *batch) { + _glapi_set_dispatch(ctx->CurrentServerDispatch); + free(batch->buffer); free(batch); } @@ -156,6 +158,10 @@ _mesa_glthread_destroy(struct gl_context *ctx) free(glthread); ctx->GLThread = NULL; + + /* Remove ourselves from the dispatch table. */ + ctx->CurrentClientDispatch = ctx->CurrentServerDispatch; + _glapi_set_dispatch(ctx->CurrentClientDispatch); } void @@ -183,6 +189,7 @@ _mesa_glthread_flush_batch(struct gl_context *ctx) */ if (false) { glthread_unmarshal_batch(ctx, batch); + _glapi_set_dispatch(ctx->CurrentClientDispatch); return; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 187f2d1bd68..7e970843d5c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4405,6 +4405,7 @@ struct gl_context /** \name API function pointer tables */ /*@{*/ gl_api API; + /** * The current dispatch table for non-displaylist-saving execution, either * BeginEnd or OutsideBeginEnd @@ -4427,10 +4428,24 @@ struct gl_context */ struct _glapi_table *ContextLost; /** - * Tracks the current dispatch table out of the 4 above, so that it can be - * re-set on glXMakeCurrent(). + * Dispatch table used to marshal API calls from the client program to a + * separate server thread. NULL if API calls are not being marshalled to + * another thread. + */ + struct _glapi_table *MarshalExec; + /** + * Dispatch table currently in use for fielding API calls from the client + * program. If API calls are being marshalled to another thread, this == + * MarshalExec. Otherwise it == CurrentServerDispatch. */ - struct _glapi_table *CurrentDispatch; + struct _glapi_table *CurrentClientDispatch; + + /** + * Dispatch table currently in use for performing API calls. == Save or + * Exec. + */ + struct _glapi_table *CurrentServerDispatch; + /*@}*/ struct glthread_state *GLThread; diff --git a/src/mesa/main/robustness.c b/src/mesa/main/robustness.c index f54d9f3eb1e..47402a29304 100644 --- a/src/mesa/main/robustness.c +++ b/src/mesa/main/robustness.c @@ -101,8 +101,8 @@ _mesa_set_context_lost_dispatch(struct gl_context *ctx) SET_GetQueryObjectuiv(ctx->ContextLost, _context_lost_GetQueryObjectuiv); } - ctx->CurrentDispatch = ctx->ContextLost; - _glapi_set_dispatch(ctx->CurrentDispatch); + ctx->CurrentServerDispatch = ctx->ContextLost; + _glapi_set_dispatch(ctx->CurrentServerDispatch); } /** diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index c4283551882..92e3f4d1f8a 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1558,7 +1558,7 @@ _mesa_MultiDrawArrays( GLenum mode, const GLint *first, for (i = 0; i < primcount; i++) { if (count[i] > 0) { - CALL_DrawArrays(ctx->CurrentDispatch, (mode, first[i], count[i])); + CALL_DrawArrays(ctx->CurrentClientDispatch, (mode, first[i], count[i])); } } } @@ -1578,7 +1578,7 @@ _mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first, for ( i = 0 ; i < primcount ; i++ ) { if ( count[i] > 0 ) { GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawArrays(ctx->CurrentDispatch, ( m, first[i], count[i] )); + CALL_DrawArrays(ctx->CurrentServerDispatch, ( m, first[i], count[i] )); } } } @@ -1600,8 +1600,8 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count, for ( i = 0 ; i < primcount ; i++ ) { if ( count[i] > 0 ) { GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride)); - CALL_DrawElements(ctx->CurrentDispatch, ( m, count[i], type, - indices[i] )); + CALL_DrawElements(ctx->CurrentServerDispatch, ( m, count[i], type, + indices[i] )); } } } diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index fffff0b3bf0..f08fd4c32c6 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -797,11 +797,11 @@ vbo_exec_Begin(GLenum mode) /* We may have been called from a display list, in which case we should * leave dlist.c's dispatch table in place. */ - if (ctx->CurrentDispatch == ctx->OutsideBeginEnd) { - ctx->CurrentDispatch = ctx->BeginEnd; - _glapi_set_dispatch(ctx->CurrentDispatch); + if (ctx->CurrentClientDispatch == ctx->OutsideBeginEnd) { + ctx->CurrentClientDispatch = ctx->BeginEnd; + _glapi_set_dispatch(ctx->CurrentClientDispatch); } else { - assert(ctx->CurrentDispatch == ctx->Save); + assert(ctx->CurrentClientDispatch == ctx->Save); } } @@ -849,9 +849,9 @@ vbo_exec_End(void) } ctx->Exec = ctx->OutsideBeginEnd; - if (ctx->CurrentDispatch == ctx->BeginEnd) { - ctx->CurrentDispatch = ctx->OutsideBeginEnd; - _glapi_set_dispatch(ctx->CurrentDispatch); + if (ctx->CurrentClientDispatch == ctx->BeginEnd) { + ctx->CurrentClientDispatch = ctx->OutsideBeginEnd; + _glapi_set_dispatch(ctx->CurrentClientDispatch); } if (exec->vtx.prim_count > 0) { |