diff --git a/src/mapi/glapi/gen/gl_API.dtd b/src/mapi/glapi/gen/gl_API.dtd index 3d1801ad2b5..714120b1db3 100644 --- a/src/mapi/glapi/gen/gl_API.dtd +++ b/src/mapi/glapi/gen/gl_API.dtd @@ -42,6 +42,7 @@ marshal NMTOKEN #IMPLIED marshal_sync CDATA #IMPLIED> marshal_count CDATA #IMPLIED> + marshal_call_before CDATA #IMPLIED> marshal_call_after CDATA #IMPLIED> - + diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index 3488000840e..cafe0870037 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -655,6 +655,7 @@ class gl_function( gl_item ): assert not alias or not element.get('marshal') assert not alias or not element.get('marshal_count') assert not alias or not element.get('marshal_sync') + assert not alias or not element.get('marshal_call_before') assert not alias or not element.get('marshal_call_after') if name in static_data.functions: diff --git a/src/mapi/glapi/gen/gl_marshal.py b/src/mapi/glapi/gen/gl_marshal.py index 39b5aa2015a..72f62a61df6 100644 --- a/src/mapi/glapi/gen/gl_marshal.py +++ b/src/mapi/glapi/gen/gl_marshal.py @@ -97,6 +97,8 @@ class PrintCode(gl_XML.gl_print_base): out('{') with indent(): out('GET_CURRENT_CONTEXT(ctx);') + if func.marshal_call_before: + out(func.marshal_call_before); out('_mesa_glthread_finish_before(ctx, "{0}");'.format(func.name)) self.print_sync_call(func) out('}') @@ -317,6 +319,9 @@ class PrintCode(gl_XML.gl_print_base): out('{') with indent(): out('GET_CURRENT_CONTEXT(ctx);') + if func.marshal_call_before: + out(func.marshal_call_before); + if not func.marshal_sync: for p in func.variable_params: out('int {0}_size = {1};'.format(p.name, p.size_string(marshal = 1))) diff --git a/src/mapi/glapi/gen/marshal_XML.py b/src/mapi/glapi/gen/marshal_XML.py index d1c0bca7938..7323b9d5e75 100644 --- a/src/mapi/glapi/gen/marshal_XML.py +++ b/src/mapi/glapi/gen/marshal_XML.py @@ -58,6 +58,7 @@ class marshal_function(gl_XML.gl_function): # Store the "marshal" attribute, if present. self.marshal = element.get('marshal') self.marshal_sync = element.get('marshal_sync') + self.marshal_call_before = element.get('marshal_call_before') self.marshal_call_after = element.get('marshal_call_after') def marshal_flavor(self): diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index 6388baeaf61..cf10bf9be33 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -227,6 +227,9 @@ struct glthread_state struct glthread_attrib_node AttribStack[MAX_ATTRIB_STACK_DEPTH]; int AttribStackDepth; int MatrixStackDepth[M_NUM_MATRIX_STACKS]; + + /** Enable states. */ + bool CullFace; }; void _mesa_glthread_init(struct gl_context *ctx); diff --git a/src/mesa/main/glthread_marshal.h b/src/mesa/main/glthread_marshal.h index b7f5cc91a10..03700dbdd95 100644 --- a/src/mesa/main/glthread_marshal.h +++ b/src/mesa/main/glthread_marshal.h @@ -442,11 +442,18 @@ _mesa_glthread_Enable(struct gl_context *ctx, GLenum cap) if (ctx->GLThread.ListMode == GL_COMPILE) return; - if (cap == GL_PRIMITIVE_RESTART || - cap == GL_PRIMITIVE_RESTART_FIXED_INDEX) + switch (cap) { + case GL_PRIMITIVE_RESTART: + case GL_PRIMITIVE_RESTART_FIXED_INDEX: _mesa_glthread_set_prim_restart(ctx, cap, true); - else if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) + break; + case GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB: _mesa_glthread_disable(ctx, "Enable(DEBUG_OUTPUT_SYNCHRONOUS)"); + break; + case GL_CULL_FACE: + ctx->GLThread.CullFace = true; + break; + } } static inline void @@ -455,9 +462,35 @@ _mesa_glthread_Disable(struct gl_context *ctx, GLenum cap) if (ctx->GLThread.ListMode == GL_COMPILE) return; - if (cap == GL_PRIMITIVE_RESTART || - cap == GL_PRIMITIVE_RESTART_FIXED_INDEX) + switch (cap) { + case GL_PRIMITIVE_RESTART: + case GL_PRIMITIVE_RESTART_FIXED_INDEX: _mesa_glthread_set_prim_restart(ctx, cap, false); + break; + case GL_CULL_FACE: + ctx->GLThread.CullFace = false; + break; + } +} + +static inline int +_mesa_glthread_IsEnabled(struct gl_context *ctx, GLenum cap) +{ + switch (cap) { + case GL_CULL_FACE: + return ctx->GLThread.CullFace; + case GL_VERTEX_ARRAY: + return !!(ctx->GLThread.CurrentVAO->UserEnabled & VERT_BIT_POS); + case GL_NORMAL_ARRAY: + return !!(ctx->GLThread.CurrentVAO->UserEnabled & VERT_BIT_NORMAL); + case GL_COLOR_ARRAY: + return !!(ctx->GLThread.CurrentVAO->UserEnabled & VERT_BIT_COLOR0); + case GL_TEXTURE_COORD_ARRAY: + return !!(ctx->GLThread.CurrentVAO->UserEnabled & + (1 << VERT_ATTRIB_TEX(ctx->GLThread.ClientActiveTexture))); + default: + return -1; /* sync and call _mesa_IsEnabled. */ + } } static inline void