* Kristian Høgsberg (krh@bitplanet.net)
*/
+#include <stdbool.h>
+
#include "glapi.h"
#include "glxclient.h"
+#include "indirect.h"
+#include "util/debug.h"
+
+#ifndef GLX_USE_APPLEGL
extern struct _glapi_table *__glXNewIndirectAPI(void);
}
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);
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) {
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;
indirect_unbind_context(struct glx_context *gc, struct glx_context *new)
{
Display *dpy = gc->psc->dpy;
- int opcode = __glXSetupForCommand(dpy);
if (gc == new)
return;
- /* We are either switching to no context, away from a indirect
+ /* We are either switching to no context, away from an indirect
* context to a direct context or from one dpy to another and have
* 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;
}
}
}
static const struct glx_context_vtable indirect_context_vtable = {
- indirect_destroy_context,
- indirect_bind_context,
- indirect_unbind_context,
- indirect_wait_gl,
- indirect_wait_x,
- indirect_use_x_font,
- indirect_bind_tex_image,
- indirect_release_tex_image,
- NULL, /* get_proc_address */
+ .destroy = indirect_destroy_context,
+ .bind = indirect_bind_context,
+ .unbind = indirect_unbind_context,
+ .wait_gl = indirect_wait_gl,
+ .wait_x = indirect_wait_x,
+ .use_x_font = indirect_use_x_font,
+ .bind_tex_image = indirect_bind_tex_image,
+ .release_tex_image = indirect_release_tex_image,
+ .get_proc_address = NULL,
};
/**
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
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;
return indirect_create_context(base, config_base, shareList, renderType);
}
-struct glx_screen_vtable indirect_screen_vtable = {
- indirect_create_context,
- indirect_create_context_attribs
+static const struct glx_screen_vtable indirect_screen_vtable = {
+ .create_context = indirect_create_context,
+ .create_context_attribs = indirect_create_context_attribs,
+ .query_renderer_integer = NULL,
+ .query_renderer_string = NULL,
};
_X_HIDDEN struct glx_screen *
return psc;
}
+
+#endif