diff options
author | Adam Jackson <ajax@redhat.com> | 2016-03-16 11:38:13 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2016-03-30 11:13:57 -0400 |
commit | b08526eecf1e165ed9ec2e6b571a5a616a9b696e (patch) | |
tree | c96fe75cf1fb030e7a1ff572642cd08112c41ca2 /glx | |
parent | 2e8781ead3067b195baec2e76a28091575679383 (diff) |
glx: Implement GLX_EXT_libglvnd (v2)
For the dri2 backend, we depend on xfree86 already, so we can walk the
options for the screen looking for a vendor string from xorg.conf. For
the swrast backend we don't have that luxury, so just say mesa. This
extension isn't really meaningful on Windows or OSX yet (since libglvnd
isn't really functional there yet), so on those platforms we don't say
anything and return BadValue for the token from QueryServerString.
v2: Use xnf* allocators when parsing options (Eric and Emil)
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'glx')
-rw-r--r-- | glx/extension_string.c | 1 | ||||
-rw-r--r-- | glx/extension_string.h | 1 | ||||
-rw-r--r-- | glx/glxcmds.c | 10 | ||||
-rw-r--r-- | glx/glxdri2.c | 22 | ||||
-rw-r--r-- | glx/glxdriswrast.c | 3 | ||||
-rw-r--r-- | glx/glxscreens.c | 4 | ||||
-rw-r--r-- | glx/glxscreens.h | 1 |
7 files changed, 42 insertions, 0 deletions
diff --git a/glx/extension_string.c b/glx/extension_string.c index 7e74090df..d1da4815c 100644 --- a/glx/extension_string.c +++ b/glx/extension_string.c @@ -85,6 +85,7 @@ static const struct extension_info known_glx_extensions[] = { { GLX(EXT_fbconfig_packed_float), VER(0,0), N, }, { GLX(EXT_framebuffer_sRGB), VER(0,0), N, }, { GLX(EXT_import_context), VER(0,0), Y, }, + { GLX(EXT_libglvnd), VER(0,0), N, }, { GLX(EXT_stereo_tree), VER(0,0), N, }, { GLX(EXT_texture_from_pixmap), VER(0,0), N, }, { GLX(EXT_visual_info), VER(0,0), Y, }, diff --git a/glx/extension_string.h b/glx/extension_string.h index 425a8058b..a10d7108a 100644 --- a/glx/extension_string.h +++ b/glx/extension_string.h @@ -47,6 +47,7 @@ enum { EXT_create_context_es2_profile_bit, EXT_fbconfig_packed_float_bit, EXT_import_context_bit, + EXT_libglvnd_bit, EXT_stereo_tree_bit, EXT_texture_from_pixmap_bit, EXT_visual_info_bit, diff --git a/glx/glxcmds.c b/glx/glxcmds.c index 4693e6803..0f0b714fa 100644 --- a/glx/glxcmds.c +++ b/glx/glxcmds.c @@ -2444,6 +2444,10 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) return Success; } +#ifndef GLX_VENDOR_NAMES_EXT +#define GLX_VENDOR_NAMES_EXT 0x20F6 +#endif + int __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) { @@ -2471,6 +2475,12 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) case GLX_EXTENSIONS: ptr = pGlxScreen->GLXextensions; break; + case GLX_VENDOR_NAMES_EXT: + if (pGlxScreen->glvnd) { + ptr = pGlxScreen->glvnd; + break; + } + /* else fall through */ default: return BadValue; } diff --git a/glx/glxdri2.c b/glx/glxdri2.c index 15253d19d..d1fc3f9fa 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -934,12 +934,23 @@ initializeExtensions(__GLXscreen * screen) /* white lie */ extern glx_func_ptr glXGetProcAddressARB(const char *); +enum { + GLXOPT_VENDOR_LIBRARY, +}; + +static const OptionInfoRec GLXOptions[] = { + { GLXOPT_VENDOR_LIBRARY, "GlxVendorLibrary", OPTV_STRING, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE }, +}; + static __GLXscreen * __glXDRIscreenProbe(ScreenPtr pScreen) { const char *driverName, *deviceName; __GLXDRIscreen *screen; ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + const char *glvnd = NULL; + OptionInfoPtr options; screen = calloc(1, sizeof *screen); if (screen == NULL) @@ -985,6 +996,17 @@ __glXDRIscreenProbe(ScreenPtr pScreen) GLX_PIXMAP_BIT | GLX_PBUFFER_BIT); + options = xnfalloc(sizeof(GLXOptions)); + memcpy(options, GLXOptions, sizeof(GLXOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + glvnd = xf86GetOptValString(options, GLXOPT_VENDOR_LIBRARY); + if (glvnd) + screen->base.glvnd = xnfstrdup(glvnd); + free(options); + + if (!screen->base.glvnd) + screen->base.glvnd = strdup("mesa"); + __glXScreenInit(&screen->base, pScreen); screen->enterVT = pScrn->EnterVT; diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c index 0b5122f6f..1e46d978f 100644 --- a/glx/glxdriswrast.c +++ b/glx/glxdriswrast.c @@ -487,6 +487,9 @@ __glXDRIscreenProbe(ScreenPtr pScreen) GLX_PIXMAP_BIT | GLX_PBUFFER_BIT); +#if !defined(XQUARTZ) && !defined(WIN32) + screen->base.glvnd = strdup("mesa"); +#endif __glXScreenInit(&screen->base, pScreen); __glXsetGetProcAddress(glXGetProcAddressARB); diff --git a/glx/glxscreens.c b/glx/glxscreens.c index 7e083cf19..536c0c495 100644 --- a/glx/glxscreens.c +++ b/glx/glxscreens.c @@ -384,6 +384,9 @@ __glXScreenInit(__GLXscreen * pGlxScreen, ScreenPtr pScreen) dixSetPrivate(&pScreen->devPrivates, glxScreenPrivateKey, pGlxScreen); + if (pGlxScreen->glvnd) + __glXEnableExtension(pGlxScreen->glx_enable_bits, "GLX_EXT_libglvnd"); + i = __glXGetExtensionString(pGlxScreen->glx_enable_bits, NULL); if (i > 0) { pGlxScreen->GLXextensions = xnfalloc(i); @@ -396,6 +399,7 @@ __glXScreenInit(__GLXscreen * pGlxScreen, ScreenPtr pScreen) void __glXScreenDestroy(__GLXscreen * screen) { + free(screen->glvnd); free(screen->GLXextensions); free(screen->GLextensions); free(screen->visuals); diff --git a/glx/glxscreens.h b/glx/glxscreens.h index c63fb5684..15196fa43 100644 --- a/glx/glxscreens.h +++ b/glx/glxscreens.h @@ -143,6 +143,7 @@ struct __GLXscreen { char *GLextensions; char *GLXextensions; + char *glvnd; unsigned char glx_enable_bits[__GLX_EXT_BYTES]; Bool (*CloseScreen) (ScreenPtr pScreen); |