From 37a36a6b5b887d5c5a17a6931ceba8ad5d1bb6d5 Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Thu, 19 Oct 2017 15:14:51 -0600 Subject: [PATCH 1/3] GLX: Add a per-client vendor mapping. Each client now has its own (screen, vendor) mapping. Currently, it's just a copy of the global mapping, but later changes will allow it to change. Signed-off-by: Aaron Plattner Reviewed-by: Aaron Plattner Reviewed-by: Adam Jackson --- glx/vndext.c | 11 ++++++++++- glx/vndserver.h | 5 +++++ glx/vndservermapping.c | 19 +++++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/glx/vndext.c b/glx/vndext.c index d7936467b..20c0648cc 100644 --- a/glx/vndext.c +++ b/glx/vndext.c @@ -139,8 +139,17 @@ GlxGetClientData(ClientPtr client) { GlxClientPriv *cl = xglvGetClientPrivate(client); if (cl == NULL) { - cl = calloc(1, sizeof(GlxClientPriv)); + cl = calloc(1, sizeof(GlxClientPriv) + + screenInfo.numScreens * sizeof(GlxServerVendor *)); if (cl != NULL) { + int i; + + cl->vendors = (GlxServerVendor **) (cl + 1); + for (i=0; ivendors[i] = GlxGetVendorForScreen(NULL, screenInfo.screens[i]); + } + xglvSetClientPrivate(client, cl); } } diff --git a/glx/vndserver.h b/glx/vndserver.h index a175656ae..78246d212 100644 --- a/glx/vndserver.h +++ b/glx/vndserver.h @@ -57,6 +57,11 @@ typedef struct GlxContextTagInfoRec { typedef struct GlxClientPrivRec { GlxContextTagInfo *contextTags; unsigned int contextTagCount; + + /** + * The vendor handles for each screen. + */ + GlxServerVendor **vendors; } GlxClientPriv; extern int GlxErrorBase; diff --git a/glx/vndservermapping.c b/glx/vndservermapping.c index fd3be92d9..778656bb6 100644 --- a/glx/vndservermapping.c +++ b/glx/vndservermapping.c @@ -187,10 +187,21 @@ Bool GlxSetScreenVendor(ScreenPtr screen, GlxServerVendor *vendor) GlxServerVendor *GlxGetVendorForScreen(ClientPtr client, ScreenPtr screen) { - GlxScreenPriv *priv = GlxGetScreen(screen); - if (priv != NULL) { - return priv->vendor; + // Note that the client won't be sending GPU screen numbers, so we don't + // need per-client mappings for them. + if (client != NULL && !screen->isGPU) { + GlxClientPriv *cl = GlxGetClientData(client); + if (cl != NULL) { + return cl->vendors[screen->myNum]; + } else { + return NULL; + } } else { - return NULL; + GlxScreenPriv *priv = GlxGetScreen(screen); + if (priv != NULL) { + return priv->vendor; + } else { + return NULL; + } } } From 8b67ec7cc6fda243480a5a8ca118b66242f3eb2c Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Wed, 8 May 2019 08:44:54 -0600 Subject: [PATCH 2/3] GLX: Use the sending client for looking up XID's When GlxGetXIDMap looks up an unknown XID, it will now look up a vendor based on the screen number for the XID and the client that sent the current request. In GlxGetXIDMap, if the XID is for a regular X window, then it won't be in the (XID -> vendor) mapping, so we have to look up a vendor by screen number. With this change, GlxGetXIDMap will use the (screen -> vendor) map for whichever client sent the current request, instead of using the global (screen -> vendor) map. Since GlxGetXIDMap doesn't take a ClientPtr argument, GlxDispatchRequest will store the client for the current request in a global variable. That way, the ABI for GLXVND doesn't need to change. v2: Fix an error check in GlxDispatchRequest. Signed-off-by: Aaron Plattner Reviewed-by: Aaron Plattner Reviewed-by: Adam Jackson --- glx/vndcmds.c | 13 +++++++++++-- glx/vndserver.h | 7 +++++++ glx/vndservermapping.c | 12 ++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/glx/vndcmds.c b/glx/vndcmds.c index f0779d14a..21c6fef9e 100644 --- a/glx/vndcmds.c +++ b/glx/vndcmds.c @@ -468,15 +468,24 @@ void GlxDispatchReset(void) int GlxDispatchRequest(ClientPtr client) { REQUEST(xReq); + int result; + if (GlxExtensionEntry->base == 0) return BadRequest; + + GlxSetRequestClient(client); + if (stuff->data < OPCODE_ARRAY_LEN) { if (dispatchFuncs[stuff->data] == NULL) { // Try to find a dispatch stub. dispatchFuncs[stuff->data] = GetVendorDispatchFunc(stuff->data, 0); } - return dispatchFuncs[stuff->data](client); + result = dispatchFuncs[stuff->data](client); } else { - return dispatch_GLXSingle(client); + result = dispatch_GLXSingle(client); } + + GlxSetRequestClient(NULL); + + return result; } diff --git a/glx/vndserver.h b/glx/vndserver.h index 78246d212..613fef0fe 100644 --- a/glx/vndserver.h +++ b/glx/vndserver.h @@ -95,6 +95,13 @@ Bool GlxAddXIDMap(XID id, GlxServerVendor *vendor); GlxServerVendor * GlxGetXIDMap(XID id); void GlxRemoveXIDMap(XID id); +/** + * Records the client that sent the current request. This is needed in + * GlxGetXIDMap to know which client's (screen -> vendor) mapping to use for a + * regular X window. + */ +void GlxSetRequestClient(ClientPtr client); + GlxContextTagInfo *GlxAllocContextTag(ClientPtr client, GlxServerVendor *vendor); GlxContextTagInfo *GlxLookupContextTag(ClientPtr client, GLXContextTag tag); void GlxFreeContextTag(GlxContextTagInfo *tagInfo); diff --git a/glx/vndservermapping.c b/glx/vndservermapping.c index 778656bb6..4efab8b81 100644 --- a/glx/vndservermapping.c +++ b/glx/vndservermapping.c @@ -33,6 +33,13 @@ #include "vndservervendor.h" +static ClientPtr requestClient = NULL; + +void GlxSetRequestClient(ClientPtr client) +{ + requestClient = client; +} + static GlxServerVendor *LookupXIDMapResource(XID id) { void *ptr = NULL; @@ -59,10 +66,7 @@ GlxServerVendor *GlxGetXIDMap(XID id) DixGetAttrAccess); if (rv == Success && ptr != NULL) { DrawablePtr draw = (DrawablePtr) ptr; - GlxScreenPriv *screenPriv = GlxGetScreen(draw->pScreen); - if (screenPriv != NULL) { - vendor = screenPriv->vendor; - } + vendor = GlxGetVendorForScreen(requestClient, draw->pScreen); } } return vendor; From 56c0a71fdd94a008e5d746261f70a713c4767f93 Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Thu, 2 May 2019 07:17:21 -0600 Subject: [PATCH 3/3] GLX: Add a function to change a clients vendor list. Add a new function, GlxServerExports::setClientScreenVendor, which will change the vendor that handles GLX requests for a screen, but only for requests from a specific client. v2: Increment the GLXVND minor version number. v3: Note the GLXVND version requirement for setClientScreenVendor. Signed-off-by: Aaron Plattner Reviewed-by: Aaron Plattner Reviewed-by: Adam Jackson --- glx/vndext.c | 1 + glx/vndserver.h | 1 + glx/vndservermapping.c | 21 +++++++++++++++++++++ include/glxvndabi.h | 13 ++++++++++++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/glx/vndext.c b/glx/vndext.c index 20c0648cc..582e60b6e 100644 --- a/glx/vndext.c +++ b/glx/vndext.c @@ -324,6 +324,7 @@ _X_EXPORT const GlxServerExports glxServer = { .getContextTagPrivate = GlxGetContextTagPrivate, .getVendorForScreen = GlxGetVendorForScreen, .forwardRequest = GlxForwardRequest, + .setClientScreenVendor = GlxSetClientScreenVendor, }; const GlxServerExports * diff --git a/glx/vndserver.h b/glx/vndserver.h index 613fef0fe..772b458a1 100644 --- a/glx/vndserver.h +++ b/glx/vndserver.h @@ -107,6 +107,7 @@ GlxContextTagInfo *GlxLookupContextTag(ClientPtr client, GLXContextTag tag); void GlxFreeContextTag(GlxContextTagInfo *tagInfo); Bool GlxSetScreenVendor(ScreenPtr screen, GlxServerVendor *vendor); +Bool GlxSetClientScreenVendor(ClientPtr client, ScreenPtr screen, GlxServerVendor *vendor); GlxScreenPriv *GlxGetScreen(ScreenPtr pScreen); GlxServerVendor *GlxGetVendorForScreen(ClientPtr client, ScreenPtr screen); diff --git a/glx/vndservermapping.c b/glx/vndservermapping.c index 4efab8b81..04788ffbd 100644 --- a/glx/vndservermapping.c +++ b/glx/vndservermapping.c @@ -189,6 +189,27 @@ Bool GlxSetScreenVendor(ScreenPtr screen, GlxServerVendor *vendor) return TRUE; } +Bool GlxSetClientScreenVendor(ClientPtr client, ScreenPtr screen, GlxServerVendor *vendor) +{ + GlxClientPriv *cl; + + if (screen == NULL || screen->isGPU) { + return FALSE; + } + + cl = GlxGetClientData(client); + if (cl == NULL) { + return FALSE; + } + + if (vendor != NULL) { + cl->vendors[screen->myNum] = vendor; + } else { + cl->vendors[screen->myNum] = GlxGetVendorForScreen(NULL, screen); + } + return TRUE; +} + GlxServerVendor *GlxGetVendorForScreen(ClientPtr client, ScreenPtr screen) { // Note that the client won't be sending GPU screen numbers, so we don't diff --git a/include/glxvndabi.h b/include/glxvndabi.h index b78306d23..71f36e722 100644 --- a/include/glxvndabi.h +++ b/include/glxvndabi.h @@ -75,7 +75,7 @@ * will still work. */ #define GLXSERVER_VENDOR_ABI_MAJOR_VERSION 0 -#define GLXSERVER_VENDOR_ABI_MINOR_VERSION 0 +#define GLXSERVER_VENDOR_ABI_MINOR_VERSION 1 #if defined(__cplusplus) extern "C" { @@ -236,6 +236,17 @@ typedef struct GlxServerExportsRec { * \param client The client. */ int (* forwardRequest) (GlxServerVendor *vendor, ClientPtr client); + + /** + * Sets the vendor library to use for a screen for a specific client. + * + * This function changes which vendor should handle GLX requests for a + * screen. Unlike \c setScreenVendor, this function can be called at any + * time, and only applies to requests from a single client. + * + * This function is available in GLXVND version 0.1 or later. + */ + Bool (* setClientScreenVendor) (ClientPtr client, ScreenPtr screen, GlxServerVendor *vendor); } GlxServerExports; extern _X_EXPORT const GlxServerExports glxServer;