Add x11glvnd X11 extension
This will be used to handle the corner case when a drawable XID is passed into the API library which belongs to an X window or otherwise has never been seen before by the process, by providing a way to lookup which screen the corresponding drawable belongs. This still is racey since we can't guarantee a different process won't free the XID and cause it to be recycled as a handle for a different resource after the lookup, but better than not being able to figure out the mapping at all. This extension also solves the less-difficult problem of mapping a screen to a vendor name (though it may make more sense to at some point directly map drawables to a vendor to better support render-offload scenarios).
This commit is contained in:
parent
8b3953b2f7
commit
3eb00015de
|
@ -156,6 +156,7 @@ CFLAGS="$CFLAGS -Wall -Werror -std=gnu99 -include config.h -fvisibility=hidden $
|
|||
AC_CONFIG_FILES([Makefile
|
||||
src/Makefile
|
||||
src/GLX/Makefile
|
||||
src/x11glvnd/Makefile
|
||||
src/GLdispatch/Makefile
|
||||
src/util/glvnd_pthread/Makefile
|
||||
src/util/trace/Makefile])
|
||||
|
|
|
@ -32,8 +32,9 @@ TRACE_DIR = ../util/trace
|
|||
GLVND_PTHREAD_DIR = ../util/glvnd_pthread
|
||||
UTHASH_DIR = ../util/uthash/src
|
||||
GL_DISPATCH_DIR = ../GLdispatch
|
||||
X11GLVND_DIR = ../x11glvnd
|
||||
|
||||
SUBDIRS = $(GL_DISPATCH_DIR) $(TRACE_DIR) $(GLVND_PTHREAD_DIR)
|
||||
SUBDIRS = $(GL_DISPATCH_DIR) $(X11GLVND_DIR) $(TRACE_DIR) $(GLVND_PTHREAD_DIR)
|
||||
|
||||
# Warning settings
|
||||
# Include paths
|
||||
|
@ -43,6 +44,7 @@ libGLX_la_CFLAGS += -I$(TRACE_DIR)
|
|||
libGLX_la_CFLAGS += -I$(GLVND_PTHREAD_DIR)
|
||||
libGLX_la_CFLAGS += -I$(GL_DISPATCH_DIR)
|
||||
libGLX_la_CFLAGS += -I$(top_builddir)/include
|
||||
libGLX_la_CFLAGS += -I$(X11GLVND_DIR)
|
||||
|
||||
# Required library flags
|
||||
libGLX_la_CFLAGS += $(PTHREAD_CFLAGS)
|
||||
|
@ -52,6 +54,7 @@ libGLX_la_LIBADD = -ldl
|
|||
libGLX_la_LIBADD += $(X11_LIBS)
|
||||
libGLX_la_LIBADD += $(XEXT_LIBS)
|
||||
libGLX_la_LIBADD += $(GL_DISPATCH_DIR)/libGLdispatch.la
|
||||
libGLX_la_LIBADD += $(X11GLVND_DIR)/libx11glvnd_client.la
|
||||
libGLX_la_LIBADD += $(TRACE_DIR)/libtrace.la
|
||||
libGLX_la_LIBADD += $(GLVND_PTHREAD_DIR)/libglvnd_pthread.la
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "utils_misc.h"
|
||||
#include "trace.h"
|
||||
#include "GL/glxproto.h"
|
||||
#include "x11glvnd.h"
|
||||
|
||||
#include "lkdhash.h"
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "trace.h"
|
||||
|
||||
#include "lkdhash.h"
|
||||
#include "x11glvnd.h"
|
||||
|
||||
#define _GNU_SOURCE 1
|
||||
|
||||
|
@ -424,7 +425,7 @@ __GLXvendorInfo *__glXLookupVendorByScreen(Display *dpy, const int screen)
|
|||
}
|
||||
|
||||
if (!vendor) {
|
||||
queriedVendorName = NULL; // TODO: query X somehow for the name
|
||||
queriedVendorName = XGLVQueryScreenVendorMapping(dpy, screen);
|
||||
vendor = __glXLookupVendorByName(queriedVendorName);
|
||||
Xfree(queriedVendorName);
|
||||
}
|
||||
|
@ -706,7 +707,7 @@ static int ScreenFromXID(Display *dpy, XID xid)
|
|||
if (pEntry) {
|
||||
screen = pEntry->screen;
|
||||
} else {
|
||||
// TODO: somehow query X for the screen number
|
||||
screen = XGLVQueryXIDScreenMapping(dpy, xid);
|
||||
AddScreenXIDMapping(xid, screen);
|
||||
}
|
||||
|
||||
|
|
52
src/x11glvnd/Makefile.am
Normal file
52
src/x11glvnd/Makefile.am
Normal file
|
@ -0,0 +1,52 @@
|
|||
# Copyright (c) 2013, NVIDIA CORPORATION.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and/or associated documentation files (the
|
||||
# "Materials"), to deal in the Materials without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
# permit persons to whom the Materials are furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# unaltered in all copies or substantial portions of the Materials.
|
||||
# Any additions, deletions, or changes to the original source files
|
||||
# must be clearly indicated in accompanying documentation.
|
||||
#
|
||||
# If only executable code is distributed, then the accompanying
|
||||
# documentation must state that "this software is based in part on the
|
||||
# work of the Khronos Group."
|
||||
#
|
||||
# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
|
||||
noinst_LTLIBRARIES = libx11glvnd_client.la
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(srcdir)/../util/uthash/src
|
||||
|
||||
libx11glvnd_client_la_CFLAGS = $(X11_CFLAGS) $(INCLUDES)
|
||||
|
||||
libx11glvnd_client_la_LIBADD = $(XEXT_LIBS)
|
||||
|
||||
libx11glvnd_client_la_SOURCES = \
|
||||
x11glvndclient.c
|
||||
|
||||
lib_LTLIBRARIES = libx11glvnd.la
|
||||
|
||||
libx11glvnd_la_CFLAGS = \
|
||||
$(XORG_CFLAGS) \
|
||||
$(X11_CFLAGS) \
|
||||
$(INCLUDES)
|
||||
|
||||
libx11glvnd_la_LDFLAGS = \
|
||||
-shared
|
||||
|
||||
libx11glvnd_la_SOURCES = \
|
||||
x11glvndserver.c
|
61
src/x11glvnd/x11glvnd.h
Normal file
61
src/x11glvnd/x11glvnd.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2013, NVIDIA CORPORATION.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
* "Materials"), to deal in the Materials without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
* permit persons to whom the Materials are furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* unaltered in all copies or substantial portions of the Materials.
|
||||
* Any additions, deletions, or changes to the original source files
|
||||
* must be clearly indicated in accompanying documentation.
|
||||
*
|
||||
* If only executable code is distributed, then the accompanying
|
||||
* documentation must state that "this software is based in part on the
|
||||
* work of the Khronos Group."
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
#ifndef __X11GLVND_H__
|
||||
#define __X11GLVND_H__
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
/*
|
||||
* Describes the client-side functions implemented by the XGLVendor extension.
|
||||
* This is a simple extension to query the X server for XID -> screen and screen
|
||||
* -> vendor mappings, used by libGLX. This may eventually be replaced by a
|
||||
* server-side GLX extension which does the same thing.
|
||||
*/
|
||||
|
||||
#define XGLV_EXTENSION_NAME "XGLVendor"
|
||||
|
||||
/*!
|
||||
* Returns the screen associated with this XID, or -1 if there was an error.
|
||||
*/
|
||||
int XGLVQueryXIDScreenMapping(
|
||||
Display *dpy,
|
||||
XID xid
|
||||
);
|
||||
|
||||
/*!
|
||||
* Returns the vendor associated with this screen, or NULL if there was an
|
||||
* error.
|
||||
*/
|
||||
char *XGLVQueryScreenVendorMapping(
|
||||
Display *dpy,
|
||||
int screen
|
||||
);
|
||||
|
||||
#endif // __X11GLVND_H__
|
57
src/x11glvnd/x11glvndclient.c
Normal file
57
src/x11glvnd/x11glvndclient.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2013, NVIDIA CORPORATION.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
* "Materials"), to deal in the Materials without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
* permit persons to whom the Materials are furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* unaltered in all copies or substantial portions of the Materials.
|
||||
* Any additions, deletions, or changes to the original source files
|
||||
* must be clearly indicated in accompanying documentation.
|
||||
*
|
||||
* If only executable code is distributed, then the accompanying
|
||||
* documentation must state that "this software is based in part on the
|
||||
* work of the Khronos Group."
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "x11glvnd.h"
|
||||
|
||||
/*
|
||||
* Returns the screen associated with this XID, or -1 if there was an error.
|
||||
*/
|
||||
int XGLVQueryXIDScreenMapping(
|
||||
Display *dpy,
|
||||
XID xid
|
||||
)
|
||||
{
|
||||
/* TODO */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the vendor associated with this screen, or NULL if there was an
|
||||
* error.
|
||||
*/
|
||||
char *XGLVQueryScreenVendorMapping(
|
||||
Display *dpy,
|
||||
int screen
|
||||
)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
160
src/x11glvnd/x11glvndserver.c
Normal file
160
src/x11glvnd/x11glvndserver.c
Normal file
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* Copyright (c) 2013, NVIDIA CORPORATION.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
* "Materials"), to deal in the Materials without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
* permit persons to whom the Materials are furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* unaltered in all copies or substantial portions of the Materials.
|
||||
* Any additions, deletions, or changes to the original source files
|
||||
* must be clearly indicated in accompanying documentation.
|
||||
*
|
||||
* If only executable code is distributed, then the accompanying
|
||||
* documentation must state that "this software is based in part on the
|
||||
* work of the Khronos Group."
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
// #include "include/scrnintstr.h"
|
||||
|
||||
#include <xorg-server.h>
|
||||
#include <xorgVersion.h>
|
||||
#include <string.h>
|
||||
#include <xf86Module.h>
|
||||
#include <scrnintstr.h>
|
||||
#include <windowstr.h>
|
||||
#include <dixstruct.h>
|
||||
#include <extnsionst.h>
|
||||
#include <xf86.h>
|
||||
|
||||
#include "x11glvnd.h"
|
||||
#include "x11glvndserver.h"
|
||||
#include "glvnd_list.h"
|
||||
|
||||
/*
|
||||
* Screen-private structure
|
||||
*/
|
||||
typedef struct XGLVScreenPrivRec {
|
||||
char *vendorLib;
|
||||
} XGLVScreenPriv;
|
||||
|
||||
DevPrivateKeyRec glvXGLVScreenPrivKey;
|
||||
|
||||
/* Dispatch information */
|
||||
typedef int ProcVectorFunc(ClientPtr);
|
||||
typedef ProcVectorFunc *ProcVectorFuncPtr;
|
||||
|
||||
static void GLVExtensionInit(void);
|
||||
|
||||
/* Module information */
|
||||
static ExtensionModule glvExtensionModule = {
|
||||
GLVExtensionInit,
|
||||
XGLV_EXTENSION_NAME,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static XF86ModuleVersionInfo x11glvndVersionInfo =
|
||||
{
|
||||
"x11glvnd",
|
||||
"NVIDIA Corporation",
|
||||
MODINFOSTRING1,
|
||||
MODINFOSTRING2,
|
||||
XORG_VERSION_NUMERIC(4,0,2,0,0),
|
||||
1, 0, 0,
|
||||
NULL, // ABI_CLASS_EXTENSION,
|
||||
ABI_EXTENSION_VERSION,
|
||||
MOD_CLASS_EXTENSION,
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
static void *glvSetup(void *module, void *opts, int *errmaj, int *errmin);
|
||||
|
||||
/*
|
||||
* x11glvndModuleData is a magic symbol needed to load the x11glvnd module in
|
||||
* the X server.
|
||||
*/
|
||||
PUBLIC const XF86ModuleData x11glvndModuleData = { &x11glvndVersionInfo,
|
||||
glvSetup, NULL };
|
||||
|
||||
static void *glvSetup(void *module, void *opts, int *errmaj, int *errmin)
|
||||
{
|
||||
typedef int (*LoaderGetABIVersionProc)(const char *abiclass);
|
||||
LoaderGetABIVersionProc pLoaderGetABIVersion;
|
||||
int extMajor = 0;
|
||||
|
||||
xf86Msg(X_INFO, "x11glvnd Loading\n");
|
||||
|
||||
if ((pLoaderGetABIVersion = (LoaderGetABIVersionProc)LoaderSymbol("LoaderGetABIVersion"))) {
|
||||
extMajor = GET_ABI_MAJOR(pLoaderGetABIVersion(ABI_CLASS_EXTENSION));
|
||||
}
|
||||
|
||||
if (extMajor != GET_ABI_MAJOR(ABI_EXTENSION_VERSION)) {
|
||||
xf86Msg(X_INFO, "x11glvnd: X server major extension ABI mismatch: expected %d but saw %d\n",
|
||||
GET_ABI_MAJOR(ABI_EXTENSION_VERSION), extMajor);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LoadExtension(&glvExtensionModule, False);
|
||||
|
||||
return (pointer)1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hook for GLX drivers to register their GLX drawable types.
|
||||
*/
|
||||
PUBLIC void _XGLVRegisterGLXDrawableType(RESTYPE rtype)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
enum {
|
||||
OPTION_GL_VENDOR,
|
||||
};
|
||||
|
||||
|
||||
static int ProcGLVDispatch(ClientPtr client)
|
||||
{
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static int SProcGLVDispatch(ClientPtr client)
|
||||
{
|
||||
return BadImplementation;
|
||||
}
|
||||
|
||||
static void GLVReset(ExtensionEntry *extEntry)
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
static void GLVExtensionInit(void)
|
||||
{
|
||||
ExtensionEntry *extEntry;
|
||||
char ext_name[] = XGLV_EXTENSION_NAME;
|
||||
|
||||
if ((extEntry = AddExtension(ext_name,
|
||||
0,
|
||||
0,
|
||||
ProcGLVDispatch,
|
||||
SProcGLVDispatch,
|
||||
GLVReset,
|
||||
StandardMinorOpcode)))
|
||||
{
|
||||
// do stuff with extEntry?
|
||||
}
|
||||
|
||||
// TODO: do the screen -> vendor mappings now
|
||||
}
|
||||
|
55
src/x11glvnd/x11glvndserver.h
Normal file
55
src/x11glvnd/x11glvndserver.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2013, NVIDIA CORPORATION.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and/or associated documentation files (the
|
||||
* "Materials"), to deal in the Materials without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
* permit persons to whom the Materials are furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* unaltered in all copies or substantial portions of the Materials.
|
||||
* Any additions, deletions, or changes to the original source files
|
||||
* must be clearly indicated in accompanying documentation.
|
||||
*
|
||||
* If only executable code is distributed, then the accompanying
|
||||
* documentation must state that "this software is based in part on the
|
||||
* work of the Khronos Group."
|
||||
*
|
||||
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
#ifndef __X11GLVNDSERVER_H__
|
||||
#define __X11GLVNDSERVER_H__
|
||||
|
||||
#include <X11/Xdefs.h>
|
||||
#include "compiler.h"
|
||||
|
||||
/*!
|
||||
* Public symbols exported by the x11glvnd X server module. Server-side GLX can
|
||||
* hook into these symbols in order to implement tracking of GLX drawables and
|
||||
* potentially implement active notification of clients when XID -> screen
|
||||
* mappings change (this could be done via shared memory in the direct rendering
|
||||
* case). The latter will allow clients to cache XID -> screen values, saving a
|
||||
* round trip in the common case.
|
||||
*
|
||||
* XXX: Currently there is a race between the XID -> screen lookup and potential
|
||||
* destruction of a GLX drawable and recycling of its XID. Will we need to
|
||||
* somehow lock drawables on the server to prevent them from going away until we
|
||||
* have dispatched to the vendor? Or should it be safe to dispatch even if the
|
||||
* drawable disappears?
|
||||
*/
|
||||
|
||||
#define XGLV_X_CONFIG_OPTION_NAME "GLVendor"
|
||||
|
||||
PUBLIC void _XGLVRegisterGLXDrawableType(RESTYPE rtype);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue