From 09092f7ac45dc6fdfdc9358feca1ca4cfe6f2fb7 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Tue, 23 Mar 2010 09:47:08 -0700 Subject: [PATCH] GLX/DRI2: only expose swap control extensions if DDX support is present Export DDX swap control status from the DRI2 module and check for it in GLX when initializing extensions. Signed-off-by: Jesse Barnes --- glx/glxdri2.c | 23 +++++++++-------------- hw/xfree86/dri2/dri2.c | 8 ++++++++ hw/xfree86/dri2/dri2.h | 2 ++ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/glx/glxdri2.c b/glx/glxdri2.c index edd29b0..e791bf6 100644 --- a/glx/glxdri2.c +++ b/glx/glxdri2.c @@ -616,6 +616,7 @@ glxDRILeaveVT (int index, int flags) static void initializeExtensions(__GLXDRIscreen *screen) { + ScreenPtr pScreen = screen->base.pScreen; const __DRIextension **extensions; int i; @@ -625,10 +626,17 @@ initializeExtensions(__GLXDRIscreen *screen) "GLX_MESA_copy_sub_buffer"); LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n"); - /* FIXME: only if DDX supports it */ __glXEnableExtension(screen->glx_enable_bits, "GLX_INTEL_swap_event"); LogMessage(X_INFO, "AIGLX: enabled GLX_INTEL_swap_event\n"); + if (DRI2HasSwapControl(pScreen)) { + __glXEnableExtension(screen->glx_enable_bits, + "GLX_SGI_swap_control"); + __glXEnableExtension(screen->glx_enable_bits, + "GLX_MESA_swap_control"); + LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n"); + } + for (i = 0; extensions[i]; i++) { #ifdef __DRI_READ_DRAWABLE if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) { @@ -639,19 +647,6 @@ initializeExtensions(__GLXDRIscreen *screen) } #endif -#ifdef __DRI_SWAP_CONTROL - if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) { - screen->swapControl = - (const __DRIswapControlExtension *) extensions[i]; - __glXEnableExtension(screen->glx_enable_bits, - "GLX_SGI_swap_control"); - __glXEnableExtension(screen->glx_enable_bits, - "GLX_MESA_swap_control"); - - LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control\n"); - } -#endif - #ifdef __DRI_TEX_BUFFER if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) { screen->texBuffer = diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 8b4c36f..2bdb733 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -831,6 +831,14 @@ DRI2DestroyDrawable(DrawablePtr pDraw) } Bool +DRI2HasSwapControl(ScreenPtr pScreen) +{ + DRI2ScreenPtr ds = DRI2GetScreen(pScreen); + + return (ds->ScheduleSwap && ds->GetMSC); +} + +Bool DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd, const char **driverName, const char **deviceName) { diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h index e1881ba..ce8a5df 100644 --- a/hw/xfree86/dri2/dri2.h +++ b/hw/xfree86/dri2/dri2.h @@ -188,6 +188,8 @@ extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, extern _X_EXPORT void DRI2CloseScreen(ScreenPtr pScreen); +extern _X_EXPORT Bool DRI2HasSwapControl(ScreenPtr pScreen); + extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd, -- 1.6.6.1