[PATCH xserver 7/7] glx: Conditionalize building indirect GLX support
Adam Jackson
ajax at redhat.com
Fri Apr 1 16:53:35 UTC 2016
This nerfs:
- Render and RenderLarge
- UseXFont
- CopyContext
- vendor private GL requests
- vendor private GLX requests where GLX protocol is only generated for
indirect contexts, namely SGI_swap_control, MESA_copy_sub_buffer, and
EXT_texture_from_pixmap
What's left is enough GLX to support direct contexts only, and the
resulting libglx does not need to link against libGL.
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
configure.ac | 12 +++++--
glx/Makefile.am | 39 +++++++++++---------
glx/glxcmds.c | 50 +++++++++++++++++++++++++-
glx/glxcmdsswap.c | 34 ++++++++++++++++++
glx/glxdri2.c | 6 ++++
glx/glxdriswrast.c | 7 +++-
glx/glxext.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++-
glx/glxserver.h | 4 +++
include/dix-config.h.in | 3 ++
9 files changed, 229 insertions(+), 22 deletions(-)
diff --git a/configure.ac b/configure.ac
index dff06ef..9ef0f39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -571,6 +571,8 @@ AC_ARG_ENABLE(visibility, AS_HELP_STRING([--enable-visibility], [Enable symb
[SYMBOL_VISIBILITY=auto])
dnl GLX build options
+AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
+AC_ARG_ENABLE(iglx, AS_HELP_STRING([--disable-iglx], [Build indirect GLX support (default: enabled)]), [IGLX=$enableval], [IGLX=yes])
AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
[AIGLX=$enableval],
[AIGLX=yes])
@@ -590,7 +592,6 @@ AC_ARG_ENABLE(dga, AS_HELP_STRING([--disable-dga], [Build DGA extensi
AC_ARG_ENABLE(screensaver, AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
AC_ARG_ENABLE(xdmcp, AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
AC_ARG_ENABLE(xdm-auth-1, AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
-AC_ARG_ENABLE(glx, AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
AC_ARG_ENABLE(dri, AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
AC_ARG_ENABLE(dri2, AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval], [DRI2=auto])
AC_ARG_ENABLE(dri3, AS_HELP_STRING([--enable-dri3], [Build DRI3 extension (default: auto)]), [DRI3=$enableval], [DRI3=auto])
@@ -1318,12 +1319,19 @@ if test "x$GLX" = xyes; then
AC_SUBST(XLIB_CFLAGS)
AC_DEFINE(GLXEXT, 1, [Build GLX extension])
GLX_LIBS='$(top_builddir)/glx/libglx.la'
- GLX_SYS_LIBS="$GLX_SYS_LIBS $GL_LIBS"
+ if test "x$IGLX" = xyes; then
+ GLX_SYS_LIBS="$GLX_SYS_LIBS $GL_LIBS"
+ fi
else
GLX=no
fi
AM_CONDITIONAL(GLX, test "x$GLX" = xyes)
+if test "x$IGLX" = xyes; then
+ AC_DEFINE(IGLX, 1, [Build indirect GLX support])
+fi
+AM_CONDITIONAL(IGLX, test "x$IGLX" = xyes)
+
if test "x$GLX" = xno; then
AIGLX=no
fi
diff --git a/glx/Makefile.am b/glx/Makefile.am
index 54e8140..fc34502 100644
--- a/glx/Makefile.am
+++ b/glx/Makefile.am
@@ -27,7 +27,8 @@ if DRI2_AIGLX
AM_CPPFLAGS += -I$(top_srcdir)/hw/xfree86/dri2
endif
-indirect_sources = \
+if IGLX
+indirect_gen_sources = \
indirect_dispatch.c \
indirect_dispatch.h \
indirect_dispatch_swap.c \
@@ -38,6 +39,25 @@ indirect_sources = \
indirect_size_get.h \
indirect_table.c
+indirect_sources = \
+ $(indirect_gen_sources) \
+ indirect_program.c \
+ indirect_texture_compression.c \
+ indirect_util.c \
+ render2.c \
+ render2swap.c \
+ renderpix.c \
+ renderpixswap.c \
+ rensize.c \
+ single2.c \
+ single2swap.c \
+ singlepix.c \
+ singlepixswap.c \
+ singlesize.c \
+ swap_interval.c \
+ xfont.c
+endif
+
libglxdri_la_SOURCES =
if DRI2_AIGLX
@@ -52,11 +72,8 @@ libglx_la_SOURCES = \
createcontext.c \
extension_string.c \
extension_string.h \
- indirect_util.c \
indirect_util.h \
- indirect_program.c \
indirect_table.h \
- indirect_texture_compression.c \
glxbyteorder.h \
glxcmds.c \
glxcmdsswap.c \
@@ -71,19 +88,7 @@ libglx_la_SOURCES = \
glxscreens.h \
glxserver.h \
glxutil.h \
- render2.c \
- render2swap.c \
- renderpix.c \
- renderpixswap.c \
- rensize.c \
- single2.c \
- single2swap.c \
- singlepix.c \
- singlepixswap.c \
- singlesize.c \
singlesize.h \
- swap_interval.c \
- unpack.h \
- xfont.c
+ unpack.h
libglx_la_LIBADD = $(DLOPEN_LIBS)
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 5b5b93e..f725509 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -289,7 +289,10 @@ DoCreateContext(__GLXclientState * cl, GLXContextID gcId,
* it's a massive attack surface for buffer overflow type
* errors.
*/
- if (!enableIndirectGLX) {
+#if defined(IGLX)
+ if (!enableIndirectGLX)
+#endif
+ {
client->errorValue = isDirect;
return BadValue;
}
@@ -863,6 +866,7 @@ __glXDisp_WaitX(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_CopyContext(__GLXclientState * cl, GLbyte * pc)
{
+#if defined(IGLX)
ClientPtr client = cl->client;
xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
GLXContextID source;
@@ -937,6 +941,10 @@ __glXDisp_CopyContext(__GLXclientState * cl, GLbyte * pc)
return BadValue;
}
return Success;
+#else
+ /* we know we never have indirect contexts */
+ return __glXError(GLXBadContext);
+#endif
}
enum {
@@ -1777,6 +1785,7 @@ __glXDisp_QueryContext(__GLXclientState * cl, GLbyte * pc)
return DoQueryContext(cl, req->context);
}
+#if defined(IGLX)
int
__glXDisp_BindTexImageEXT(__GLXclientState * cl, GLbyte * pc)
{
@@ -1914,6 +1923,7 @@ __glXDisp_CopySubBufferMESA(__GLXclientState * cl, GLbyte * pc)
return Success;
}
+#endif
/* hack for old glxext.h */
#ifndef GLX_STEREO_TREE_EXT
@@ -2024,6 +2034,7 @@ __glXDisp_GetDrawableAttributesSGIX(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_Render(__GLXclientState * cl, GLbyte * pc)
{
+#if defined(IGLX)
xGLXRenderReq *req;
ClientPtr client = cl->client;
int left, cmdlen, error;
@@ -2118,6 +2129,9 @@ __glXDisp_Render(__GLXclientState * cl, GLbyte * pc)
commandsDone++;
}
return Success;
+#else
+ return BadImplementation;
+#endif
}
/*
@@ -2126,6 +2140,7 @@ __glXDisp_Render(__GLXclientState * cl, GLbyte * pc)
int
__glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
{
+#if defined(IGLX)
xGLXRenderLargeReq *req;
ClientPtr client = cl->client;
size_t dataBytes;
@@ -2340,10 +2355,35 @@ __glXDisp_RenderLarge(__GLXclientState * cl, GLbyte * pc)
}
return Success;
}
+#else
+ return BadImplementation;
+#endif
}
/************************************************************************/
+#if !defined(IGLX)
+
+#define proc(s) \
+ if (vendorcode == X_GLXvop_ ## s) \
+ return __glXDisp_ ## s;
+
+static __GLXdispatchVendorPrivProcPtr
+__glXGetVendorPrivProc(GLint vendorcode)
+{
+ proc(QueryContextInfoEXT);
+ proc(MakeCurrentReadSGI);
+ proc(GetFBConfigsSGIX);
+ proc(CreateContextWithConfigSGIX);
+ proc(CreateGLXPixmapWithConfigSGIX);
+ proc(CreateGLXPbufferSGIX);
+ proc(DestroyGLXPbufferSGIX);
+ proc(ChangeDrawableAttributesSGIX);
+ proc(GetDrawableAttributesSGIX);
+ return NULL;
+}
+#endif
+
/*
** No support is provided for the vendor-private requests other than
** allocating the entry points in the dispatch table.
@@ -2359,9 +2399,13 @@ __glXDisp_VendorPrivate(__GLXclientState * cl, GLbyte * pc)
REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
+#if defined(IGLX)
proc = (__GLXdispatchVendorPrivProcPtr)
__glXGetProtocolDecodeFunction(&VendorPriv_dispatch_info,
vendorcode, 0);
+#else
+ proc = __glXGetVendorPrivProc(vendorcode);
+#endif
if (proc != NULL) {
(*proc) (cl, (GLbyte *) req);
return Success;
@@ -2381,9 +2425,13 @@ __glXDisp_VendorPrivateWithReply(__GLXclientState * cl, GLbyte * pc)
REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
+#if defined(IGLX)
proc = (__GLXdispatchVendorPrivProcPtr)
__glXGetProtocolDecodeFunction(&VendorPriv_dispatch_info,
vendorcode, 0);
+#else
+ proc = __glXGetVendorPrivProc(vendorcode);
+#endif
if (proc != NULL) {
return (*proc) (cl, (GLbyte *) req);
}
diff --git a/glx/glxcmdsswap.c b/glx/glxcmdsswap.c
index 9ec1222..a63c2ef 100644
--- a/glx/glxcmdsswap.c
+++ b/glx/glxcmdsswap.c
@@ -618,6 +618,7 @@ __glXDispSwap_SwapBuffers(__GLXclientState * cl, GLbyte * pc)
return __glXDisp_SwapBuffers(cl, pc);
}
+#if defined(IGLX)
int
__glXDispSwap_UseXFont(__GLXclientState * cl, GLbyte * pc)
{
@@ -637,6 +638,7 @@ __glXDispSwap_UseXFont(__GLXclientState * cl, GLbyte * pc)
return __glXDisp_UseXFont(cl, pc);
}
+#endif
int
__glXDispSwap_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
@@ -705,6 +707,7 @@ __glXDispSwap_QueryContextInfoEXT(__GLXclientState * cl, GLbyte * pc)
return __glXDisp_QueryContextInfoEXT(cl, pc);
}
+#if defined(IGLX)
int
__glXDispSwap_BindTexImageEXT(__GLXclientState * cl, GLbyte * pc)
{
@@ -787,6 +790,7 @@ __glXDispSwap_CopySubBufferMESA(__GLXclientState * cl, GLbyte * pc)
return __glXDisp_CopySubBufferMESA(cl, pc);
}
+#endif
int
__glXDispSwap_GetDrawableAttributesSGIX(__GLXclientState * cl, GLbyte * pc)
@@ -950,6 +954,28 @@ __glXDispSwap_RenderLarge(__GLXclientState * cl, GLbyte * pc)
/************************************************************************/
+#if !defined(IGLX)
+
+#define proc(s) \
+ if (vendorcode == X_GLXvop_ ## s) \
+ return __glXDispSwap_ ## s;
+
+static __GLXdispatchVendorPrivProcPtr
+__glXGetSwapVendorPrivProc(GLint vendorcode)
+{
+ proc(QueryContextInfoEXT);
+ proc(MakeCurrentReadSGI);
+ proc(GetFBConfigsSGIX);
+ proc(CreateContextWithConfigSGIX);
+ proc(CreateGLXPixmapWithConfigSGIX);
+ proc(CreateGLXPbufferSGIX);
+ proc(DestroyGLXPbufferSGIX);
+ proc(ChangeDrawableAttributesSGIX);
+ proc(GetDrawableAttributesSGIX);
+ return NULL;
+}
+#endif
+
/*
** No support is provided for the vendor-private requests other than
** allocating these entry points in the dispatch table.
@@ -972,9 +998,13 @@ __glXDispSwap_VendorPrivate(__GLXclientState * cl, GLbyte * pc)
vendorcode = req->vendorCode;
+#if defined(IGLX)
proc = (__GLXdispatchVendorPrivProcPtr)
__glXGetProtocolDecodeFunction(&VendorPriv_dispatch_info,
vendorcode, 1);
+#else
+ proc = __glXGetSwapVendorPrivProc(vendorcode);
+#endif
if (proc != NULL) {
(*proc) (cl, (GLbyte *) req);
return Success;
@@ -1001,9 +1031,13 @@ __glXDispSwap_VendorPrivateWithReply(__GLXclientState * cl, GLbyte * pc)
vendorcode = req->vendorCode;
+#if defined(IGLX)
proc = (__GLXdispatchVendorPrivProcPtr)
__glXGetProtocolDecodeFunction(&VendorPriv_dispatch_info,
vendorcode, 1);
+#else
+ proc = __glXGetSwapVendorPrivProc(vendorcode);
+#endif
if (proc != NULL) {
return (*proc) (cl, (GLbyte *) req);
}
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index ebf29d2..25ef83a 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -50,6 +50,7 @@
#include <GL/glxtokens.h>
#include "extension_string.h"
+#include "indirect_util.h"
typedef struct __GLXDRIscreen __GLXDRIscreen;
typedef struct __GLXDRIcontext __GLXDRIcontext;
@@ -119,6 +120,8 @@ copy_box(__GLXdrawable * drawable,
}
}
+#if defined(IGLX)
+
/* white lie */
extern glx_func_ptr glXGetProcAddressARB(const char *);
@@ -637,6 +640,7 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
return &private->base;
}
+#endif
static __DRIbuffer *
dri2GetBuffers(__DRIdrawable * driDrawable,
@@ -969,9 +973,11 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
}
screen->base.destroy = __glXDRIscreenDestroy;
+#if defined(IGLX)
screen->base.createContext = __glXDRIscreenCreateContext;
screen->base.createDrawable = __glXDRIscreenCreateDrawable;
screen->base.swapInterval = __glXDRIdrawableSwapInterval;
+#endif
screen->base.pScreen = pScreen;
__glXInitExtensionEnableBits(screen->base.glx_enable_bits);
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index 7354f4a..5a1667f 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -49,6 +49,7 @@
#include "glxdricommon.h"
#include "extension_string.h"
+#include "indirect_util.h"
/* RTLD_LOCAL is not defined on Cygwin */
#ifdef __CYGWIN__
@@ -89,6 +90,8 @@ struct __GLXDRIdrawable {
GCPtr swapgc; /* GC for swapping the color buffers */
};
+#if defined(IGLX)
+
/* white lie */
extern glx_func_ptr glXGetProcAddressARB(const char *);
@@ -301,6 +304,7 @@ __glXDRIscreenCreateDrawable(ClientPtr client,
return &private->base;
}
+#endif
static void
swrastGetDrawableInfo(__DRIdrawable * draw,
@@ -456,9 +460,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
return NULL;
screen->base.destroy = __glXDRIscreenDestroy;
+#if defined(IGLX)
screen->base.createContext = __glXDRIscreenCreateContext;
screen->base.createDrawable = __glXDRIscreenCreateDrawable;
- screen->base.swapInterval = NULL;
+#endif
screen->base.pScreen = pScreen;
__glXInitExtensionEnableBits(screen->base.glx_enable_bits);
diff --git a/glx/glxext.c b/glx/glxext.c
index 8984cc7..5c2f61f 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -553,6 +553,7 @@ __glXleaveServer(GLboolean rendering)
glxServerLeaveCount++;
}
+#if defined(IGLX)
static glx_gpa_proc _get_proc_address;
void
@@ -567,6 +568,89 @@ void *__glGetProcAddress(const char *proc)
return ret ? ret : (void *) NoopDDA;
}
+#endif
+
+#if !defined(IGLX)
+#include "indirect_dispatch.h"
+
+static const __GLXdispatchSingleProcPtr GLXProcVector[] = {
+ NULL,
+ __glXDisp_Render,
+ __glXDisp_RenderLarge,
+ __glXDisp_CreateContext,
+ __glXDisp_DestroyContext,
+ __glXDisp_MakeCurrent,
+ __glXDisp_IsDirect,
+ __glXDisp_QueryVersion,
+ __glXDisp_WaitGL,
+ __glXDisp_WaitX,
+ __glXDisp_CopyContext,
+ __glXDisp_SwapBuffers,
+ NULL, /* UseXFont */
+ __glXDisp_CreateGLXPixmap,
+ __glXDisp_GetVisualConfigs,
+ __glXDisp_DestroyGLXPixmap,
+ __glXDisp_VendorPrivate,
+ __glXDisp_VendorPrivateWithReply,
+ __glXDisp_QueryExtensionsString,
+ __glXDisp_QueryServerString,
+ __glXDisp_ClientInfo,
+ __glXDisp_GetFBConfigs,
+ __glXDisp_CreatePixmap,
+ __glXDisp_DestroyPixmap,
+ __glXDisp_CreateNewContext,
+ __glXDisp_QueryContext,
+ __glXDisp_MakeContextCurrent,
+ __glXDisp_CreatePbuffer,
+ __glXDisp_DestroyPbuffer,
+ __glXDisp_GetDrawableAttributes,
+ __glXDisp_ChangeDrawableAttributes,
+ __glXDisp_CreateWindow,
+ __glXDisp_DestroyWindow,
+ __glXDisp_SetClientInfoARB,
+ __glXDisp_CreateContextAttribsARB,
+ __glXDisp_SetClientInfo2ARB,
+};
+
+static const __GLXdispatchSingleProcPtr SGLXProcVector[] = {
+ NULL,
+ __glXDispSwap_Render,
+ __glXDispSwap_RenderLarge,
+ __glXDispSwap_CreateContext,
+ __glXDispSwap_DestroyContext,
+ __glXDispSwap_MakeCurrent,
+ __glXDispSwap_IsDirect,
+ __glXDispSwap_QueryVersion,
+ __glXDispSwap_WaitGL,
+ __glXDispSwap_WaitX,
+ __glXDispSwap_CopyContext,
+ __glXDispSwap_SwapBuffers,
+ NULL, /* UseXFont */
+ __glXDispSwap_CreateGLXPixmap,
+ __glXDispSwap_GetVisualConfigs,
+ __glXDispSwap_DestroyGLXPixmap,
+ __glXDispSwap_VendorPrivate,
+ __glXDispSwap_VendorPrivateWithReply,
+ __glXDispSwap_QueryExtensionsString,
+ __glXDispSwap_QueryServerString,
+ __glXDispSwap_ClientInfo,
+ __glXDispSwap_GetFBConfigs,
+ __glXDispSwap_CreatePixmap,
+ __glXDispSwap_DestroyPixmap,
+ __glXDispSwap_CreateNewContext,
+ __glXDispSwap_QueryContext,
+ __glXDispSwap_MakeContextCurrent,
+ __glXDispSwap_CreatePbuffer,
+ __glXDispSwap_DestroyPbuffer,
+ __glXDispSwap_GetDrawableAttributes,
+ __glXDispSwap_ChangeDrawableAttributes,
+ __glXDispSwap_CreateWindow,
+ __glXDispSwap_DestroyWindow,
+ __glXDispSwap_SetClientInfoARB,
+ __glXDispSwap_CreateContextAttribsARB,
+ __glXDispSwap_SetClientInfo2ARB,
+};
+#endif
/*
** Top level dispatcher; all commands are executed from here down.
@@ -576,7 +660,7 @@ __glXDispatch(ClientPtr client)
{
REQUEST(xGLXSingleReq);
CARD8 opcode;
- __GLXdispatchSingleProcPtr proc;
+ __GLXdispatchSingleProcPtr proc = NULL;
__GLXclientState *cl;
int retval;
@@ -605,8 +689,18 @@ __glXDispatch(ClientPtr client)
/*
** Use the opcode to index into the procedure table.
*/
+#if defined(IGLX)
proc = __glXGetProtocolDecodeFunction(&Single_dispatch_info, opcode,
client->swapped);
+#else
+ if (opcode <= X_GLXSetConfigInfo2ARB) {
+ if (client->swapped)
+ proc = SGLXProcVector[opcode];
+ else
+ proc = GLXProcVector[opcode];
+ }
+#endif
+
if (proc != NULL) {
GLboolean rendering = opcode <= X_GLXRenderLarge;
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 9088ec4..86bf82b 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -115,10 +115,14 @@ void __glXleaveServer(GLboolean rendering);
void glxSuspendClients(void);
void glxResumeClients(void);
+#if defined(IGLX)
typedef void (*glx_func_ptr)(void);
typedef glx_func_ptr (*glx_gpa_proc)(const char *);
void __glXsetGetProcAddress(glx_gpa_proc get_proc_address);
void *__glGetProcAddress(const char *);
+#else
+#define __glXsetGetProcAddress(p) do {} while (0)
+#endif
void
__glXsendSwapEvent(__GLXdrawable *drawable, int type, CARD64 ust,
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index a164c15..93ab62b 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -45,6 +45,9 @@
/* Build GLX extension */
#undef GLXEXT
+/* Build indirect GLX support */
+#undef IGLX
+
/* Build GLX DRI loader */
#undef GLX_DRI
--
2.5.0
More information about the xorg-devel
mailing list