X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fglx%2Findirect_glx.c;h=f370daf8bb6074111e8ad5ce03cc8bd16c2da0bc;hb=36e0d2f39b0264e393fd4edab7c87d3e0d5454a4;hp=1991f70251b311b20424ffc4f066067be59b2dc1;hpb=60a27ad122128145d28be37e9c0b0bc86a8e5181;p=mesa.git diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index 1991f70251b..f370daf8bb6 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -30,8 +30,12 @@ * Kristian Høgsberg (krh@bitplanet.net) */ +#include + #include "glapi.h" #include "glxclient.h" +#include "indirect.h" +#include "util/debug.h" #ifndef GLX_USE_APPLEGL @@ -58,13 +62,13 @@ indirect_destroy_context(struct glx_context *gc) } static Bool -SendMakeCurrentRequest(Display * dpy, CARD8 opcode, - GLXContextID gc_id, GLXContextTag gc_tag, - GLXDrawable draw, GLXDrawable read, - GLXContextTag *out_tag) +SendMakeCurrentRequest(Display * dpy, GLXContextID gc_id, + GLXContextTag gc_tag, GLXDrawable draw, + GLXDrawable read, GLXContextTag *out_tag) { xGLXMakeCurrentReply reply; Bool ret; + int opcode = __glXSetupForCommand(dpy); LockDisplay(dpy); @@ -131,9 +135,7 @@ indirect_bind_context(struct glx_context *gc, struct glx_context *old, GLXDrawable draw, GLXDrawable read) { GLXContextTag tag; - __GLXattribute *state; Display *dpy = gc->psc->dpy; - int opcode = __glXSetupForCommand(dpy); Bool sent; if (old != &dummyContext && !old->isDirect && old->psc->dpy == dpy) { @@ -143,18 +145,29 @@ indirect_bind_context(struct glx_context *gc, struct glx_context *old, tag = 0; } - sent = SendMakeCurrentRequest(dpy, opcode, gc->xid, tag, draw, read, + sent = SendMakeCurrentRequest(dpy, gc->xid, tag, draw, read, &gc->currentContextTag); - if (!IndirectAPI) - IndirectAPI = __glXNewIndirectAPI(); - _glapi_set_dispatch(IndirectAPI); - - state = gc->client_state_private; - if (state->array_state == NULL) { - glGetString(GL_EXTENSIONS); - glGetString(GL_VERSION); - __glXInitVertexArrayState(gc); + if (sent) { + if (!IndirectAPI) + IndirectAPI = __glXNewIndirectAPI(); + _glapi_set_dispatch(IndirectAPI); + + /* The indirect vertex array state must to be initialised after we + * have setup the context, as it needs to query server attributes. + * + * At the point this is called gc->currentDpy is not initialized + * nor is the thread's current context actually set. Hence the + * cleverness before the GetString calls. + */ + __GLXattribute *state = gc->client_state_private; + if (state && state->array_state == NULL) { + gc->currentDpy = gc->psc->dpy; + __glXSetCurrentContext(gc); + __indirect_glGetString(GL_EXTENSIONS); + __indirect_glGetString(GL_VERSION); + __glXInitVertexArrayState(gc); + } } return !sent; @@ -164,7 +177,6 @@ static void indirect_unbind_context(struct glx_context *gc, struct glx_context *new) { Display *dpy = gc->psc->dpy; - int opcode = __glXSetupForCommand(dpy); if (gc == new) return; @@ -174,8 +186,8 @@ indirect_unbind_context(struct glx_context *gc, struct glx_context *new) * to send a request to the dpy to unbind the previous context. */ if (!new || new->isDirect || new->psc->dpy != dpy) { - SendMakeCurrentRequest(dpy, opcode, None, - gc->currentContextTag, None, None, NULL); + SendMakeCurrentRequest(dpy, None, gc->currentContextTag, None, None, + NULL); gc->currentContextTag = 0; } } @@ -379,7 +391,7 @@ indirect_create_context(struct glx_screen *psc, return NULL; } gc->client_state_private = state; - state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL); + state->NoDrawArraysProtocol = env_var_as_boolean("LIBGL_NO_DRAWARRAYS", false); /* ** Create a temporary buffer to hold GLX rendering commands. The size @@ -405,10 +417,6 @@ indirect_create_context(struct glx_screen *psc, gc->attributes.stackPointer = &gc->attributes.stack[0]; - /* - ** PERFORMANCE NOTE: A mode dependent fill image can speed things up. - */ - gc->fillImage = __glFillImage; gc->pc = gc->buf; gc->bufEnd = gc->buf + bufSize; gc->isDirect = GL_FALSE;