[PATCH xserver 2/4] glx: Use vnd layer for dispatch (v3)
Adam Jackson
ajax at redhat.com
Fri Feb 2 19:15:15 UTC 2018
The big change here is MakeCurrent and context tag tracking. We now
delegate context tags entirely to the vnd layer, and simply store a
pointer to the context state as the tag data. If a context is deleted
while it's current, we allocate a fake ID for the context and move the
context state there, so the tag data still points to a real context. As
a result we can stop trying so hard to detach the client from contexts
at disconnect time and just let resource destruction handle it.
Since vnd handles all the MakeCurrent protocol now, our request handlers
for it can just be return BadImplementation. We also remove a bunch of
LEGAL_NEW_RESOURCE, because now by the time we're called vnd has already
allocated its tracking resource on that XID.
v2: Update to match v2 of the vnd import, and remove more redundant work
like request length checks.
v3: Add/remove the XID map from the vendor private thunk, not the
backend. (Kyle Brenneman)
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
configure.ac | 2 +-
glx/createcontext.c | 2 -
glx/glxcmds.c | 212 +++++--------------------
glx/glxcmdsswap.c | 98 +-----------
glx/glxext.c | 348 +++++++++++++++++++++++++++++------------
glx/glxext.h | 4 +
glx/glxscreens.h | 1 +
glx/glxserver.h | 5 -
glx/xfont.c | 2 -
hw/kdrive/ephyr/ephyr.c | 2 +-
hw/kdrive/ephyr/meson.build | 1 +
hw/kdrive/src/kdrive.c | 3 +
hw/vfb/InitOutput.c | 2 +
hw/vfb/meson.build | 3 +-
hw/xfree86/Makefile.am | 5 +
hw/xfree86/common/xf86Init.c | 2 +-
hw/xfree86/dixmods/glxmodule.c | 1 +
hw/xfree86/meson.build | 1 +
hw/xquartz/darwin.c | 4 +-
hw/xwayland/Makefile.am | 1 +
hw/xwayland/meson.build | 1 +
hw/xwayland/xwayland.c | 2 +
include/glx_extinit.h | 5 +-
23 files changed, 328 insertions(+), 379 deletions(-)
diff --git a/configure.ac b/configure.ac
index 180334d99..451d11c47 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1295,7 +1295,7 @@ if test "x$GLX" = xyes; then
PKG_CHECK_MODULES([GL], $GLPROTO $LIBGL)
AC_SUBST(XLIB_CFLAGS)
AC_DEFINE(GLXEXT, 1, [Build GLX extension])
- GLX_LIBS='$(top_builddir)/glx/libglx.la'
+ GLX_LIBS='$(top_builddir)/glx/libglx.la $(top_builddir)/glx/libglxvnd.la'
GLX_SYS_LIBS="$GLX_SYS_LIBS $GL_LIBS"
else
GLX=no
diff --git a/glx/createcontext.c b/glx/createcontext.c
index 76316db67..00c23fcdd 100644
--- a/glx/createcontext.c
+++ b/glx/createcontext.c
@@ -123,8 +123,6 @@ __glXDisp_CreateContextAttribsARB(__GLXclientState * cl, GLbyte * pc)
if (req->length != expected_size)
return BadLength;
- LEGAL_NEW_RESOURCE(req->context, client);
-
/* The GLX_ARB_create_context spec says:
*
* "* If <config> is not a valid GLXFBConfig, GLXBadFBConfig is
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index f4820d8e4..3fd3bf44b 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -47,6 +47,7 @@
#include "indirect_table.h"
#include "indirect_util.h"
#include "protocol-versions.h"
+#include "glxvndabi.h"
static char GLXServerVendorName[] = "SGI";
@@ -135,6 +136,10 @@ _X_HIDDEN int
validGlxContext(ClientPtr client, XID id, int access_mode,
__GLXcontext ** context, int *err)
{
+ /* no ghost contexts */
+ if (id & SERVER_BIT)
+ return FALSE;
+
*err = dixLookupResourceByType((void **) context, id,
__glXContextRes, client, access_mode);
if (*err != Success || (*context)->idExists == GL_FALSE) {
@@ -240,8 +245,6 @@ DoCreateContext(__GLXclientState * cl, GLXContextID gcId,
__GLXcontext *glxc, *shareglxc;
int err;
- LEGAL_NEW_RESOURCE(gcId, client);
-
/*
** Find the display list space that we want to share.
**
@@ -356,14 +359,11 @@ DoCreateContext(__GLXclientState * cl, GLXContextID gcId,
int
__glXDisp_CreateContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
__GLXconfig *config;
__GLXscreen *pGlxScreen;
int err;
- REQUEST_SIZE_MATCH(xGLXCreateContextReq);
-
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
return err;
if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err))
@@ -376,14 +376,11 @@ __glXDisp_CreateContext(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_CreateNewContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
__GLXconfig *config;
__GLXscreen *pGlxScreen;
int err;
- REQUEST_SIZE_MATCH(xGLXCreateNewContextReq);
-
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
return err;
if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
@@ -417,62 +414,32 @@ __glXDisp_CreateContextWithConfigSGIX(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_DestroyContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
__GLXcontext *glxc;
int err;
- REQUEST_SIZE_MATCH(xGLXDestroyContextReq);
-
if (!validGlxContext(cl->client, req->context, DixDestroyAccess,
&glxc, &err))
return err;
glxc->idExists = GL_FALSE;
- if (!glxc->currentClient)
- FreeResourceByType(req->context, __glXContextRes, FALSE);
+ if (glxc->currentClient) {
+ XID ghost = FakeClientID(glxc->currentClient->index);
+
+ if (!AddResource(ghost, __glXContextRes, glxc))
+ return BadAlloc;
+ ChangeResourceValue(glxc->id, __glXContextRes, NULL);
+ }
+
+ FreeResourceByType(req->context, __glXContextRes, FALSE);
return Success;
}
-/*
- * This will return "deleted" contexts, ie, where idExists is GL_FALSE.
- * Contrast validGlxContext, which will not. We're cheating here and
- * using the XID as the context tag, which is fine as long as we defer
- * actually destroying the context until it's no longer referenced, and
- * block clients from trying to MakeCurrent on contexts that are on the
- * way to destruction. Notice that DoMakeCurrent calls validGlxContext
- * for new contexts but __glXLookupContextByTag for previous contexts.
- */
__GLXcontext *
__glXLookupContextByTag(__GLXclientState * cl, GLXContextTag tag)
{
- __GLXcontext *ret;
-
- if (dixLookupResourceByType((void **) &ret, tag, __glXContextRes,
- cl->client, DixUseAccess) == Success)
- return ret;
-
- return NULL;
-}
-
-/*****************************************************************************/
-
-static void
-StopUsingContext(__GLXcontext * glxc)
-{
- if (glxc) {
- glxc->currentClient = NULL;
- if (!glxc->idExists) {
- FreeResourceByType(glxc->id, __glXContextRes, FALSE);
- }
- }
-}
-
-static void
-StartUsingContext(__GLXclientState * cl, __GLXcontext * glxc)
-{
- glxc->currentClient = cl->client;
+ return glxServer.getContextTagPrivate(cl->client, tag);
}
static __GLXconfig *
@@ -583,14 +550,12 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client,
** Make an OpenGL context and drawable current.
*/
-static int
-DoMakeCurrent(__GLXclientState * cl,
- GLXDrawable drawId, GLXDrawable readId,
- GLXContextID contextId, GLXContextTag tag)
+int
+xorgGlxMakeCurrent(ClientPtr client, GLXContextTag tag, XID drawId, XID readId,
+ XID contextId, GLXContextTag newContextTag)
{
- ClientPtr client = cl->client;
- xGLXMakeCurrentReply reply;
- __GLXcontext *glxc, *prevglxc;
+ __GLXclientState *cl = glxGetClient(client);
+ __GLXcontext *glxc = NULL, *prevglxc = NULL;
__GLXdrawable *drawPriv = NULL;
__GLXdrawable *readPriv = NULL;
int error;
@@ -603,39 +568,28 @@ DoMakeCurrent(__GLXclientState * cl,
if ((drawId == None) != (readId == None))
return BadMatch;
- /*
- ** Lookup old context. If we have one, it must be in a usable state.
- */
+ /* Look up old context. If we have one, it must be in a usable state. */
if (tag != 0) {
- prevglxc = __glXLookupContextByTag(cl, tag);
- if (!prevglxc) {
- /*
- ** Tag for previous context is invalid.
- */
+ prevglxc = glxServer.getContextTagPrivate(client, tag);
+ if (!prevglxc)
return __glXError(GLXBadContextTag);
- }
+
if (prevglxc->renderMode != GL_RENDER) {
/* Oops. Not in render mode render. */
client->errorValue = prevglxc->id;
return __glXError(GLXBadContextState);
}
}
- else {
- prevglxc = 0;
- }
- /*
- ** Lookup new context. It must not be current for someone else.
- */
+ /* Look up new context. It must not be current for someone else. */
if (contextId != None) {
int status;
if (!validGlxContext(client, contextId, DixUseAccess, &glxc, &error))
return error;
- if ((glxc != prevglxc) && glxc->currentClient) {
- /* Context is current to somebody else */
+
+ if ((glxc != prevglxc) && glxc->currentClient)
return BadAccess;
- }
if (drawId) {
drawPriv = __glXGetDrawable(glxc, drawId, client, &status);
@@ -648,38 +602,25 @@ DoMakeCurrent(__GLXclientState * cl,
if (readPriv == NULL)
return status;
}
- } else {
- /* Switching to no context. Ignore new drawable. */
-
- glxc = 0;
- drawPriv = 0;
- readPriv = 0;
}
if (prevglxc) {
- /*
- ** Flush the previous context if needed.
- */
+ /* Flush the previous context if needed. */
Bool need_flush = !prevglxc->isDirect;
#ifdef GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
if (prevglxc->releaseBehavior == GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB)
need_flush = GL_FALSE;
#endif
if (need_flush) {
- if (__glXForceCurrent(cl, tag, (int *) &error)) {
- glFlush();
- }
- else {
+ if (!__glXForceCurrent(cl, tag, (int *) &error))
return error;
- }
+ glFlush();
}
- /*
- ** Make the previous context not current.
- */
- if (!(*prevglxc->loseCurrent) (prevglxc)) {
+ /* Make the previous context not current. */
+ if (!(*prevglxc->loseCurrent) (prevglxc))
return __glXError(GLXBadContext);
- }
+
lastGLContext = NULL;
if (!prevglxc->isDirect) {
prevglxc->drawPriv = NULL;
@@ -687,8 +628,7 @@ DoMakeCurrent(__GLXclientState * cl,
}
}
- if ((glxc != 0) && !glxc->isDirect) {
-
+ if (glxc && !glxc->isDirect) {
glxc->drawPriv = drawPriv;
glxc->readPriv = readPriv;
@@ -702,66 +642,35 @@ DoMakeCurrent(__GLXclientState * cl,
}
glxc->currentClient = client;
+ glxServer.setContextTagPrivate(client, newContextTag, glxc);
}
- StopUsingContext(prevglxc);
-
- reply = (xGLXMakeCurrentReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .contextTag = 0
- };
-
- if (glxc) {
- StartUsingContext(cl, glxc);
- reply.contextTag = glxc->id;
+ if (prevglxc) {
+ prevglxc->currentClient = NULL;
+ if (!prevglxc->idExists) {
+ FreeResourceByType(prevglxc->id, __glXContextRes, FALSE);
+ }
}
- if (client->swapped) {
- __GLX_DECLARE_SWAP_VARIABLES;
- __GLX_SWAP_SHORT(&reply.sequenceNumber);
- __GLX_SWAP_INT(&reply.length);
- __GLX_SWAP_INT(&reply.contextTag);
- }
- WriteToClient(client, sz_xGLXMakeCurrentReply, &reply);
return Success;
}
int
__glXDisp_MakeCurrent(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
- xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
-
- REQUEST_SIZE_MATCH(xGLXMakeCurrentReq);
-
- return DoMakeCurrent(cl, req->drawable, req->drawable,
- req->context, req->oldContextTag);
+ return BadImplementation;
}
int
__glXDisp_MakeContextCurrent(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
- xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
-
- REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq);
-
- return DoMakeCurrent(cl, req->drawable, req->readdrawable,
- req->context, req->oldContextTag);
+ return BadImplementation;
}
int
__glXDisp_MakeCurrentReadSGI(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
- xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
-
- REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq);
-
- return DoMakeCurrent(cl, req->drawable, req->readable,
- req->context, req->oldContextTag);
+ return BadImplementation;
}
int
@@ -773,8 +682,6 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc)
__GLXcontext *glxc;
int err;
- REQUEST_SIZE_MATCH(xGLXIsDirectReq);
-
if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
return err;
@@ -838,14 +745,11 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_WaitGL(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
GLXContextTag tag;
__GLXcontext *glxc = NULL;
int error;
- REQUEST_SIZE_MATCH(xGLXWaitGLReq);
-
tag = req->contextTag;
if (tag) {
glxc = __glXLookupContextByTag(cl, tag);
@@ -867,14 +771,11 @@ __glXDisp_WaitGL(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_WaitX(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
GLXContextTag tag;
__GLXcontext *glxc = NULL;
int error;
- REQUEST_SIZE_MATCH(xGLXWaitXReq);
-
tag = req->contextTag;
if (tag) {
glxc = __glXLookupContextByTag(cl, tag);
@@ -903,8 +804,6 @@ __glXDisp_CopyContext(__GLXclientState * cl, GLbyte * pc)
__GLXcontext *src, *dst;
int error;
- REQUEST_SIZE_MATCH(xGLXCopyContextReq);
-
source = req->source;
dest = req->dest;
tag = req->contextTag;
@@ -992,8 +891,6 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
__GLX_DECLARE_SWAP_VARIABLES;
__GLX_DECLARE_SWAP_ARRAY_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq);
-
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
return err;
@@ -1213,10 +1110,8 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
int
__glXDisp_GetFBConfigs(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
- REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq);
return DoGetFBConfigs(cl, req->screen);
}
@@ -1287,8 +1182,6 @@ DoCreateGLXPixmap(ClientPtr client, __GLXscreen * pGlxScreen,
DrawablePtr pDraw;
int err;
- LEGAL_NEW_RESOURCE(glxDrawableId, client);
-
err = dixLookupDrawable(&pDraw, drawableId, client, 0, DixAddAccess);
if (err != Success) {
client->errorValue = drawableId;
@@ -1354,14 +1247,11 @@ determineTextureTarget(ClientPtr client, XID glxDrawableID,
int
__glXDisp_CreateGLXPixmap(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
__GLXconfig *config;
__GLXscreen *pGlxScreen;
int err;
- REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq);
-
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
return err;
if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err))
@@ -1442,11 +1332,8 @@ DoDestroyDrawable(__GLXclientState * cl, XID glxdrawable, int type)
int
__glXDisp_DestroyGLXPixmap(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
- REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq);
-
return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP);
}
@@ -1472,8 +1359,6 @@ DoCreatePbuffer(ClientPtr client, int screenNum, XID fbconfigId,
PixmapPtr pPixmap;
int err;
- LEGAL_NEW_RESOURCE(glxDrawableId, client);
-
if (!validGlxScreen(client, screenNum, &pGlxScreen, &err))
return err;
if (!validGlxFBConfig(client, pGlxScreen, fbconfigId, &config, &err))
@@ -1658,8 +1543,6 @@ __glXDisp_CreateWindow(__GLXclientState * cl, GLbyte * pc)
}
REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3);
- LEGAL_NEW_RESOURCE(req->glxwindow, client);
-
if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
return err;
if (!validGlxFBConfig(client, pGlxScreen, req->fbconfig, &config, &err))
@@ -1709,8 +1592,6 @@ __glXDisp_SwapBuffers(__GLXclientState * cl, GLbyte * pc)
__GLXdrawable *pGlxDraw;
int error;
- REQUEST_SIZE_MATCH(xGLXSwapBuffersReq);
-
tag = req->contextTag;
drawId = req->drawable;
if (tag) {
@@ -1813,11 +1694,8 @@ __glXDisp_QueryContextInfoEXT(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_QueryContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;
- REQUEST_SIZE_MATCH(xGLXQueryContextReq);
-
return DoQueryContext(cl, req->context);
}
@@ -2453,8 +2331,6 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
char *buf;
int err;
- REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq);
-
if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
return err;
@@ -2508,8 +2384,6 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
__GLXscreen *pGlxScreen;
int err;
- REQUEST_SIZE_MATCH(xGLXQueryServerStringReq);
-
if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
return err;
diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c
index 10d84062e..7d6674470 100644
--- a/glx/glxcmdsswap.c
+++ b/glx/glxcmdsswap.c
@@ -56,13 +56,10 @@
int
__glXDispSwap_CreateContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXCreateContextReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->visual);
@@ -75,13 +72,10 @@ __glXDispSwap_CreateContext(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_CreateNewContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXCreateNewContextReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->context);
__GLX_SWAP_INT(&req->fbconfig);
@@ -115,13 +109,10 @@ __glXDispSwap_CreateContextWithConfigSGIX(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_DestroyContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXDestroyContextReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->context);
@@ -131,69 +122,28 @@ __glXDispSwap_DestroyContext(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_MakeCurrent(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
- xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- REQUEST_SIZE_MATCH(xGLXMakeCurrentReq);
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->drawable);
- __GLX_SWAP_INT(&req->context);
- __GLX_SWAP_INT(&req->oldContextTag);
-
- return __glXDisp_MakeCurrent(cl, pc);
+ return BadImplementation;
}
int
__glXDispSwap_MakeContextCurrent(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
- xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq);
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->drawable);
- __GLX_SWAP_INT(&req->readdrawable);
- __GLX_SWAP_INT(&req->context);
- __GLX_SWAP_INT(&req->oldContextTag);
-
- return __glXDisp_MakeContextCurrent(cl, pc);
+ return BadImplementation;
}
int
__glXDispSwap_MakeCurrentReadSGI(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
- xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
-
- __GLX_DECLARE_SWAP_VARIABLES;
-
- REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq);
-
- __GLX_SWAP_SHORT(&req->length);
- __GLX_SWAP_INT(&req->drawable);
- __GLX_SWAP_INT(&req->readable);
- __GLX_SWAP_INT(&req->context);
- __GLX_SWAP_INT(&req->oldContextTag);
-
- return __glXDisp_MakeCurrentReadSGI(cl, pc);
+ return BadImplementation;
}
int
__glXDispSwap_IsDirect(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXIsDirectReq *req = (xGLXIsDirectReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXIsDirectReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->context);
@@ -203,13 +153,10 @@ __glXDispSwap_IsDirect(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_QueryVersion(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXQueryVersionReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->majorVersion);
__GLX_SWAP_INT(&req->minorVersion);
@@ -220,13 +167,10 @@ __glXDispSwap_QueryVersion(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_WaitGL(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXWaitGLReq *req = (xGLXWaitGLReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXWaitGLReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -236,13 +180,10 @@ __glXDispSwap_WaitGL(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_WaitX(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXWaitXReq *req = (xGLXWaitXReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXWaitXReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
@@ -252,13 +193,10 @@ __glXDispSwap_WaitX(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_CopyContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXCopyContextReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->source);
__GLX_SWAP_INT(&req->dest);
@@ -270,13 +208,10 @@ __glXDispSwap_CopyContext(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq);
-
__GLX_SWAP_INT(&req->screen);
return __glXDisp_GetVisualConfigs(cl, pc);
}
@@ -284,13 +219,10 @@ __glXDispSwap_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_GetFBConfigs(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq);
-
__GLX_SWAP_INT(&req->screen);
return __glXDisp_GetFBConfigs(cl, pc);
}
@@ -312,13 +244,10 @@ __glXDispSwap_GetFBConfigsSGIX(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_CreateGLXPixmap(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->screen);
__GLX_SWAP_INT(&req->visual);
@@ -380,13 +309,10 @@ __glXDispSwap_CreateGLXPixmapWithConfigSGIX(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_DestroyGLXPixmap(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->glxpixmap);
@@ -412,13 +338,10 @@ __glXDispSwap_DestroyPixmap(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_QueryContext(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXQueryContextReq);
-
__GLX_SWAP_INT(&req->context);
return __glXDisp_QueryContext(cl, pc);
@@ -474,13 +397,10 @@ __glXDispSwap_CreateGLXPbufferSGIX(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_DestroyPbuffer(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq);
-
__GLX_SWAP_INT(&req->pbuffer);
return __glXDisp_DestroyPbuffer(cl, pc);
@@ -604,13 +524,10 @@ __glXDispSwap_DestroyWindow(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_SwapBuffers(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXSwapBuffersReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
__GLX_SWAP_INT(&req->drawable);
@@ -621,13 +538,10 @@ __glXDispSwap_SwapBuffers(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_UseXFont(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXUseXFontReq *req = (xGLXUseXFontReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXUseXFontReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->contextTag);
__GLX_SWAP_INT(&req->font);
@@ -641,13 +555,10 @@ __glXDispSwap_UseXFont(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXQueryExtensionsStringReq *req = (xGLXQueryExtensionsStringReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->screen);
@@ -657,13 +568,10 @@ __glXDispSwap_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
int
__glXDispSwap_QueryServerString(__GLXclientState * cl, GLbyte * pc)
{
- ClientPtr client = cl->client;
xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) pc;
__GLX_DECLARE_SWAP_VARIABLES;
- REQUEST_SIZE_MATCH(xGLXQueryServerStringReq);
-
__GLX_SWAP_SHORT(&req->length);
__GLX_SWAP_INT(&req->screen);
__GLX_SWAP_INT(&req->name);
diff --git a/glx/glxext.c b/glx/glxext.c
index d39fe6d8e..17626dea1 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -46,10 +46,12 @@
#include "glxext.h"
#include "indirect_table.h"
#include "indirect_util.h"
+#include "glxvndabi.h"
/*
** X resources.
*/
+static int glxGeneration;
RESTYPE __glXContextRes;
RESTYPE __glXDrawableRes;
@@ -63,15 +65,6 @@ static DevPrivateKeyRec glxClientPrivateKeyRec;
static int __glXDispatch(ClientPtr);
static GLboolean __glXFreeContext(__GLXcontext * cx);
-/*
-** Called when the extension is reset.
-*/
-static void
-ResetExtension(ExtensionEntry * extEntry)
-{
- lastGLContext = NULL;
-}
-
/*
** Reset state used to keep track of large (multi-request) commands.
*/
@@ -86,16 +79,18 @@ __glXResetLargeCommandStatus(__GLXclientState * cl)
/*
* This procedure is called when the client who created the context goes away
- * OR when glXDestroyContext is called. In either case, all we do is flag that
- * the ID is no longer valid, and (maybe) free the context.
+ * OR when glXDestroyContext is called. If the context is current for a client
+ * the dispatch layer will have moved the context struct to a fake resource ID
+ * and cx here will be NULL. Otherwise we really free the context.
*/
static int
ContextGone(__GLXcontext * cx, XID id)
{
- cx->idExists = GL_FALSE;
- if (!cx->currentClient) {
+ if (!cx)
+ return TRUE;
+
+ if (!cx->currentClient)
__glXFreeContext(cx);
- }
return TRUE;
}
@@ -271,29 +266,14 @@ glxClientCallback(CallbackListPtr *list, void *closure, void *data)
NewClientInfoRec *clientinfo = (NewClientInfoRec *) data;
ClientPtr pClient = clientinfo->client;
__GLXclientState *cl = glxGetClient(pClient);
- __GLXcontext *c, *next;
switch (pClient->clientState) {
- case ClientStateRunning:
- cl->client = pClient;
- break;
-
case ClientStateGone:
- /* detach from all current contexts */
- for (c = glxAllContexts; c; c = next) {
- next = c->next;
- if (c->currentClient == pClient) {
- c->loseCurrent(c);
- lastGLContext = NULL;
- c->currentClient = NULL;
- FreeResourceByType(c->id, __glXContextRes, FALSE);
- }
- }
-
free(cl->returnBuf);
free(cl->largeCmdBuf);
free(cl->GLClientextensions);
- memset(cl, 0, sizeof(*cl));
+ cl->returnBuf = NULL;
+ cl->GLClientextensions = NULL;
break;
default:
@@ -303,7 +283,7 @@ glxClientCallback(CallbackListPtr *list, void *closure, void *data)
/************************************************************************/
-static __GLXprovider *__glXProviderStack;
+static __GLXprovider *__glXProviderStack = &__glXDRISWRastProvider;
void
GlxPushProvider(__GLXprovider * provider)
@@ -346,50 +326,235 @@ GetGLXDrawableBytes(void *value, XID id, ResourceSizePtr size)
}
}
-/*
-** Initialize the GLX extension.
-*/
-void
-GlxExtensionInit(void)
-{
- ExtensionEntry *extEntry;
- ScreenPtr pScreen;
+static void
+xorgGlxCloseExtension(const ExtensionEntry *extEntry)
+{
+ lastGLContext = NULL;
+}
+
+static int
+xorgGlxHandleRequest(ClientPtr client)
+{
+ return __glXDispatch(client);
+}
+
+static ScreenPtr
+screenNumToScreen(int screen)
+{
+ if (screen < 0 || screen >= screenInfo.numScreens)
+ return NULL;
+
+ return screenInfo.screens[screen];
+}
+
+static int
+maybe_swap32(ClientPtr client, int x)
+{
+ return client->swapped ? bswap_32(x) : x;
+}
+
+static GlxServerVendor *
+vendorForScreen(ClientPtr client, int screen)
+{
+ screen = maybe_swap32(client, screen);
+
+ return glxServer.getVendorForScreen(client, screenNumToScreen(screen));
+}
+
+/* this ought to be generated */
+static int
+xorgGlxThunkRequest(ClientPtr client)
+{
+ REQUEST(xGLXVendorPrivateReq);
+ CARD32 vendorCode = maybe_swap32(client, stuff->vendorCode);
+ GlxServerVendor *vendor = NULL;
+ XID resource = 0;
+ int ret;
+
+ switch (vendorCode) {
+ case X_GLXvop_QueryContextInfoEXT: {
+ xGLXQueryContextInfoEXTReq *req = (void *)stuff;
+ if (!(vendor = glxServer.getXIDMap(maybe_swap32(client, req->context))))
+ return __glXError(GLXBadContext);
+ break;
+ }
+
+ case X_GLXvop_GetFBConfigsSGIX: {
+ xGLXGetFBConfigsSGIXReq *req = (void *)stuff;
+ if (!(vendor = vendorForScreen(client, req->screen)))
+ return BadValue;
+ break;
+ }
+
+ case X_GLXvop_CreateContextWithConfigSGIX: {
+ xGLXCreateContextWithConfigSGIXReq *req = (void *)stuff;
+ if (!(vendor = vendorForScreen(client, req->screen)))
+ return BadValue;
+ break;
+ }
+
+ case X_GLXvop_CreateGLXPixmapWithConfigSGIX: {
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req = (void *)stuff;
+ if (!(vendor = vendorForScreen(client, req->screen)))
+ return BadValue;
+ break;
+ }
+
+ case X_GLXvop_CreateGLXPbufferSGIX: {
+ xGLXCreateGLXPbufferSGIXReq *req = (void *)stuff;
+ if (!(vendor = vendorForScreen(client, req->screen)))
+ return BadValue;
+ break;
+ }
+
+ /* same offset for the drawable for these three */
+ case X_GLXvop_DestroyGLXPbufferSGIX:
+ case X_GLXvop_ChangeDrawableAttributesSGIX:
+ case X_GLXvop_GetDrawableAttributesSGIX: {
+ xGLXGetDrawableAttributesSGIXReq *req = (void *)stuff;
+ if (!(vendor = glxServer.getXIDMap(maybe_swap32(client,
+ req->drawable))))
+ return __glXError(GLXBadDrawable);
+ break;
+ }
+
+ /* most things just use the standard context tag */
+ default: {
+ GLXContextTag tag = maybe_swap32(client, stuff->contextTag);
+ vendor = glxServer.getContextTag(client, tag);
+ if (!vendor)
+ return __glXError(GLXBadContextTag);
+ break;
+ }
+ }
+
+ if (!vendor)
+ return BadImplementation;
+
+ /* If we're creating a resource, add the map now */
+ if (vendorCode == X_GLXvop_CreateContextWithConfigSGIX) {
+ xGLXCreateContextWithConfigSGIXReq *req = (void *)stuff;
+ resource = maybe_swap32(client, req->context);
+ } else if (vendorCode == X_GLXvop_CreateGLXPixmapWithConfigSGIX) {
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req = (void *)stuff;
+ resource = maybe_swap32(client, req->glxpixmap);
+ } else if (vendorCode == X_GLXvop_CreateGLXPbufferSGIX) {
+ xGLXCreateGLXPbufferSGIXReq *req = (void *)stuff;
+ resource = maybe_swap32(client, req->pbuffer);
+ }
+
+ if (resource) {
+ LEGAL_NEW_RESOURCE(resource, client);
+ if (!glxServer.addXIDMap(resource, vendor))
+ return BadAlloc;
+ }
+
+ ret = glxServer.forwardRequest(vendor, client);
+
+ if (ret != Success)
+ glxServer.removeXIDMap(resource);
+
+ return ret;
+}
+
+static GlxServerDispatchProc
+xorgGlxGetDispatchAddress(CARD8 minorOpcode, CARD32 vendorCode)
+{
+ /* we don't support any other GLX opcodes */
+ if (minorOpcode != X_GLXVendorPrivate &&
+ minorOpcode != X_GLXVendorPrivateWithReply)
+ return NULL;
+
+ /* we only support some vendor private requests */
+ if (!__glXGetProtocolDecodeFunction(&VendorPriv_dispatch_info, vendorCode,
+ FALSE))
+ return NULL;
+
+ return xorgGlxThunkRequest;
+}
+
+static Bool
+xorgGlxServerPreInit(const ExtensionEntry *extEntry)
+{
+ if (glxGeneration != serverGeneration) {
+ /* Mesa requires at least one True/DirectColor visual */
+ if (!checkScreenVisuals())
+ return FALSE;
+
+ __glXContextRes = CreateNewResourceType((DeleteType) ContextGone,
+ "GLXContext");
+ __glXDrawableRes = CreateNewResourceType((DeleteType) DrawableGone,
+ "GLXDrawable");
+ if (!__glXContextRes || !__glXDrawableRes)
+ return FALSE;
+
+ if (!dixRegisterPrivateKey
+ (&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(__GLXclientState)))
+ return FALSE;
+ if (!AddCallback(&ClientStateCallback, glxClientCallback, 0))
+ return FALSE;
+
+ __glXErrorBase = extEntry->errorBase;
+ __glXEventBase = extEntry->eventBase;
+
+ SetResourceTypeSizeFunc(__glXDrawableRes, GetGLXDrawableBytes);
+#if PRESENT
+ __glXregisterPresentCompleteNotify();
+#endif
+
+ glxGeneration = serverGeneration;
+ }
+
+ return glxGeneration == serverGeneration;
+}
+
+static GlxServerVendor *glvnd_vendor = NULL;
+
+static GlxServerVendor *
+xorgGlxInitGLVNDVendor(void)
+{
+ if (glvnd_vendor == NULL) {
+ GlxServerImports *imports = NULL;
+ imports = glxServer.allocateServerImports();
+
+ if (imports != NULL) {
+ imports->extensionCloseDown = xorgGlxCloseExtension;
+ imports->handleRequest = xorgGlxHandleRequest;
+ imports->getDispatchAddress = xorgGlxGetDispatchAddress;
+ imports->makeCurrent = xorgGlxMakeCurrent;
+ glvnd_vendor = glxServer.createVendor(imports);
+ glxServer.freeServerImports(imports);
+ }
+ }
+ return glvnd_vendor;
+}
+
+static void
+xorgGlxServerInit(CallbackListPtr *pcbl, void *param, void *ext)
+{
+ const ExtensionEntry *extEntry = ext;
int i;
- __GLXprovider *p, **stack;
- Bool glx_provided = FALSE;
- if (serverGeneration == 1) {
- for (stack = &__glXProviderStack; *stack; stack = &(*stack)->next)
- ;
- *stack = &__glXDRISWRastProvider;
- }
-
- /* Mesa requires at least one True/DirectColor visual */
- if (!checkScreenVisuals())
- return;
-
- __glXContextRes = CreateNewResourceType((DeleteType) ContextGone,
- "GLXContext");
- __glXDrawableRes = CreateNewResourceType((DeleteType) DrawableGone,
- "GLXDrawable");
- if (!__glXContextRes || !__glXDrawableRes)
+ if (!xorgGlxServerPreInit(extEntry)) {
return;
+ }
- SetResourceTypeSizeFunc(__glXDrawableRes, GetGLXDrawableBytes);
-
- if (!dixRegisterPrivateKey
- (&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(__GLXclientState)))
- return;
- if (!AddCallback(&ClientStateCallback, glxClientCallback, 0))
+ if (!xorgGlxInitGLVNDVendor()) {
return;
+ }
for (i = 0; i < screenInfo.numScreens; i++) {
- pScreen = screenInfo.screens[i];
+ ScreenPtr pScreen = screenInfo.screens[i];
+ __GLXprovider *p;
+
+ if (glxServer.getVendorForScreen(NULL, pScreen) != NULL) {
+ // There's already a vendor registered.
+ LogMessage(X_INFO, "GLX: Another vendor is already registered for screen %d\n", i);
+ continue;
+ }
for (p = __glXProviderStack; p != NULL; p = p->next) {
- __GLXscreen *glxScreen;
-
- glxScreen = p->screenProbe(pScreen);
+ __GLXscreen *glxScreen = p->screenProbe(pScreen);
if (glxScreen != NULL) {
LogMessage(X_INFO,
"GLX: Initialized %s GL provider for screen %d\n",
@@ -399,33 +564,19 @@ GlxExtensionInit(void)
}
- if (!p)
+ if (p) {
+ glxServer.setScreenVendor(pScreen, glvnd_vendor);
+ } else {
LogMessage(X_INFO,
"GLX: no usable GL providers found for screen %d\n", i);
- else
- glx_provided = TRUE;
+ }
}
+}
- /* don't register extension if GL is not provided on any screen */
- if (!glx_provided)
- return;
-
- /*
- ** Add extension to server extensions.
- */
- extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS,
- __GLX_NUMBER_ERRORS, __glXDispatch,
- __glXDispatch, ResetExtension, StandardMinorOpcode);
- if (!extEntry) {
- FatalError("__glXExtensionInit: AddExtensions failed\n");
- return;
- }
-
- __glXErrorBase = extEntry->errorBase;
- __glXEventBase = extEntry->eventBase;
-#if PRESENT
- __glXregisterPresentCompleteNotify();
-#endif
+Bool
+xorgGlxCreateVendor(void)
+{
+ return AddCallback(glxServer.extensionInitCallback, xorgGlxServerInit, NULL);
}
/************************************************************************/
@@ -500,7 +651,7 @@ glxSuspendClients(void)
int i;
for (i = 1; i < currentMaxClients; i++) {
- if (clients[i] && glxGetClient(clients[i])->inUse)
+ if (glxGetClient(clients[i])->client)
IgnoreClient(clients[i]);
}
@@ -516,7 +667,7 @@ glxResumeClients(void)
glxBlockClients = FALSE;
for (i = 1; i < currentMaxClients; i++) {
- if (clients[i] && glxGetClient(clients[i])->inUse)
+ if (glxGetClient(clients[i])->client)
AttendClient(clients[i]);
}
@@ -553,12 +704,10 @@ __glXDispatch(ClientPtr client)
CARD8 opcode;
__GLXdispatchSingleProcPtr proc;
__GLXclientState *cl;
- int retval;
+ int retval = BadRequest;
opcode = stuff->glxCode;
cl = glxGetClient(client);
- /* Mark it in use so we suspend it on VT switch. */
- cl->inUse = TRUE;
/*
** If we're expecting a glXRenderLarge request, this better be one.
@@ -568,6 +717,9 @@ __glXDispatch(ClientPtr client)
return __glXError(GLXBadLargeRequest);
}
+ if (!cl->client)
+ cl->client = client;
+
/* If we're currently blocking GLX clients, just put this guy to
* sleep, reset the request and return. */
if (glxBlockClients) {
@@ -582,12 +734,8 @@ __glXDispatch(ClientPtr client)
*/
proc = __glXGetProtocolDecodeFunction(&Single_dispatch_info, opcode,
client->swapped);
- if (proc != NULL) {
+ if (proc != NULL)
retval = (*proc) (cl, (GLbyte *) stuff);
- }
- else {
- retval = BadRequest;
- }
return retval;
}
diff --git a/glx/glxext.h b/glx/glxext.h
index cde0e1519..af59165bf 100644
--- a/glx/glxext.h
+++ b/glx/glxext.h
@@ -62,4 +62,8 @@ extern void __glXResetLargeCommandStatus(__GLXclientState *);
extern const char GLServerVersion[];
extern int DoGetString(__GLXclientState * cl, GLbyte * pc, GLboolean need_swap);
+extern int
+xorgGlxMakeCurrent(ClientPtr client, GLXContextTag tag, XID drawId, XID readId,
+ XID contextId, GLXContextTag newContextTag);
+
#endif /* _glxext_h_ */
diff --git a/glx/glxscreens.h b/glx/glxscreens.h
index c6a0c5021..40649f88d 100644
--- a/glx/glxscreens.h
+++ b/glx/glxscreens.h
@@ -36,6 +36,7 @@
*/
#include "extension_string.h"
+#include "glxvndabi.h"
typedef struct __GLXconfig __GLXconfig;
struct __GLXconfig {
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 8a3e6f98b..8ffde2342 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -109,11 +109,6 @@ __glXregisterPresentCompleteNotify(void);
** State kept per client.
*/
struct __GLXclientStateRec {
- /*
- ** Whether this structure is currently being used to support a client.
- */
- Bool inUse;
-
/*
** Buffer for returned data.
*/
diff --git a/glx/xfont.c b/glx/xfont.c
index 83a455d73..bd2fdae52 100644
--- a/glx/xfont.c
+++ b/glx/xfont.c
@@ -152,8 +152,6 @@ __glXDisp_UseXFont(__GLXclientState * cl, GLbyte * pc)
__GLXcontext *cx;
int error;
- REQUEST_SIZE_MATCH(xGLXUseXFontReq);
-
req = (xGLXUseXFontReq *) pc;
cx = __glXForceCurrent(cl, req->contextTag, &error);
if (!cx) {
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index acf389c1d..4f1f19860 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -40,7 +40,7 @@
#include "glamor.h"
#endif
#include "ephyr_glamor_glx.h"
-
+#include "glx_extinit.h"
#include "xkbsrv.h"
extern Bool ephyr_glamor;
diff --git a/hw/kdrive/ephyr/meson.build b/hw/kdrive/ephyr/meson.build
index 615649865..7b9225f26 100644
--- a/hw/kdrive/ephyr/meson.build
+++ b/hw/kdrive/ephyr/meson.build
@@ -56,6 +56,7 @@ executable(
libxserver_xkb_stubs,
libxserver_xi_stubs,
libxserver_glx,
+ libglxvnd,
],
install: true,
)
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 6dbb90856..6e8168323 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -30,6 +30,7 @@
#ifdef RANDR
#include <randrstr.h>
#endif
+#include "glx_extinit.h"
#ifdef XV
#include "kxv.h"
@@ -973,6 +974,8 @@ KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
for (screen = card->screenList; screen; screen = screen->next)
KdAddScreen(pScreenInfo, screen, argc, argv);
+ xorgGlxCreateVendor();
+
#if defined(CONFIG_UDEV) || defined(CONFIG_HAL)
if (SeatId) /* Enable input hot-plugging */
config_pre_init();
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 6d386ee2f..2b7bca5fa 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -1002,6 +1002,8 @@ InitOutput(ScreenInfo * screen_info, int argc, char **argv)
vfbPixmapDepths[32] = TRUE;
}
+ xorgGlxCreateVendor();
+
for (i = 1; i <= 32; i++) {
if (vfbPixmapDepths[i]) {
if (NumFormats >= MAXFORMATS)
diff --git a/hw/vfb/meson.build b/hw/vfb/meson.build
index 89acdfacd..a0771c3a6 100644
--- a/hw/vfb/meson.build
+++ b/hw/vfb/meson.build
@@ -15,7 +15,8 @@ xvfb_server = executable(
libxserver,
libxserver_xkb_stubs,
libxserver_xi_stubs,
- libxserver_glx
+ libxserver_glx,
+ libglxvnd,
],
install: true,
)
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 458720052..57c8b8dd4 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -14,6 +14,10 @@ DRI3_BUILDDIR = $(top_builddir)/dri3
DRI3_LIB = $(DRI3_BUILDDIR)/libdri3.la
endif
+if GLX
+GLXVND_LIB = $(top_builddir)/glx/libglxvnd.la
+endif
+
if GLAMOR_EGL
GLAMOR_EGL_SUBDIR = glamor_egl
endif
@@ -70,6 +74,7 @@ LOCAL_LIBS = \
$(DRI_LIB) \
$(DRI2_LIB) \
$(DRI3_LIB) \
+ $(GLXVND_LIB) \
$(top_builddir)/miext/sync/libsync.la \
$(top_builddir)/mi/libmi.la \
$(top_builddir)/os/libos.la \
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index f9843c719..cdbf80c61 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -78,7 +78,7 @@
#include "xf86InPriv.h"
#include "picturestr.h"
#include "randrstr.h"
-
+#include "glxvndabi.h"
#include "xf86Bus.h"
#ifdef XSERVER_LIBPCIACCESS
#include "xf86VGAarbiter.h"
diff --git a/hw/xfree86/dixmods/glxmodule.c b/hw/xfree86/dixmods/glxmodule.c
index bf7e65911..c3d92fa92 100644
--- a/hw/xfree86/dixmods/glxmodule.c
+++ b/hw/xfree86/dixmods/glxmodule.c
@@ -83,6 +83,7 @@ glxSetup(void *module, void *opts, int *errmaj, int *errmin)
provider = LoaderSymbol("__glXDRI2Provider");
if (provider)
GlxPushProvider(provider);
+ xorgGlxCreateVendor();
LoadExtensionList(GLXExt, ARRAY_SIZE(GLXExt), FALSE);
diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build
index 629daf977..8fc53e4cf 100644
--- a/hw/xfree86/meson.build
+++ b/hw/xfree86/meson.build
@@ -51,6 +51,7 @@ srcs_xorg = [
xorg_link = [
libxserver,
+ libglxvnd,
xorg_common,
xorg_loader,
xorg_ddc,
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 71a65f3ce..c701eb6ac 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -50,7 +50,7 @@
#include <X11/extensions/XIproto.h>
#include "exevents.h"
#include "extinit.h"
-
+#include "glx_extinit.h"
#include "xserver-properties.h"
#include <sys/types.h>
@@ -670,6 +670,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
AddScreen(DarwinScreenInit, argc, argv);
}
+ xorgGlxCreateVendor();
+
DarwinAdjustScreenOrigins(pScreenInfo);
}
diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index 7204591e3..173686e31 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -24,6 +24,7 @@ Xwayland_SOURCES = \
Xwayland_LDADD = \
$(glamor_lib) \
$(XWAYLAND_LIBS) \
+ $(top_builddir)/glx/libglxvnd.la \
$(XWAYLAND_SYS_LIBS) \
$(top_builddir)/Xext/libXvidmode.la \
$(XSERVER_SYS_LIBS)
diff --git a/hw/xwayland/meson.build b/hw/xwayland/meson.build
index 24203c63e..f6f75001c 100644
--- a/hw/xwayland/meson.build
+++ b/hw/xwayland/meson.build
@@ -70,6 +70,7 @@ executable(
libxserver_xkb_stubs,
libxserver_xi_stubs,
libxserver_glx,
+ libglxvnd,
],
install: true,
)
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 19aa14a47..c57e72ad5 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -1100,5 +1100,7 @@ InitOutput(ScreenInfo * screen_info, int argc, char **argv)
FatalError("Couldn't add screen\n");
}
+ xorgGlxCreateVendor();
+
LocalAccessScopeUser();
}
diff --git a/include/glx_extinit.h b/include/glx_extinit.h
index 710ca6e3e..32b8fcf72 100644
--- a/include/glx_extinit.h
+++ b/include/glx_extinit.h
@@ -40,7 +40,10 @@ struct __GLXprovider {
extern __GLXprovider __glXDRISWRastProvider;
void GlxPushProvider(__GLXprovider * provider);
-
+Bool xorgGlxCreateVendor(void);
+#else
+static inline Bool xorgGlxCreateVendor(void) { return TRUE; }
#endif
+
#endif
--
2.14.3
More information about the xorg-devel
mailing list