[PATCH xserver 6/8] xwin/glx: Assume WGL_ARB_make_current_read exists

Adam Jackson ajax at redhat.com
Mon Mar 21 20:29:44 UTC 2016


This seems to be fairly universal these days, and if it doesn't exist
the only thing you break is separate drawable and readable, which is a
fairly rare feature to use. So pretend it's always there and just throw
an error on MakeCurrent if it doesn't.

As a result we can enable GLX 1.4 unconditionally.

Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 hw/xwin/glx/indirect.c | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 626238f..220ad7e 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -143,6 +143,7 @@ struct __GLXWinScreen {
     Bool has_WGL_ARB_pixel_format;
     Bool has_WGL_ARB_pbuffer;
     Bool has_WGL_ARB_render_texture;
+    Bool has_WGL_ARB_make_current_read;
 
     /* wrapped screen functions */
     RealizeWindowProcPtr RealizeWindow;
@@ -627,8 +628,6 @@ glxWinScreenProbe(ScreenPtr pScreen)
     // those screens to be accelerated in XP and earlier...
 
     {
-        Bool glx_sgi_make_current_read = FALSE;
-
         //
         // Based on the WGL extensions available, enable various GLX extensions
         // XXX: make this table-driven ?
@@ -640,6 +639,7 @@ glxWinScreenProbe(ScreenPtr pScreen)
         __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_import_context");
         __glXEnableExtension(screen->glx_enable_bits, "GLX_OML_swap_method");
         __glXEnableExtension(screen->glx_enable_bits, "GLX_SGIX_fbconfig");
+        __glXEnableExtension(screen->glx_enable_bits, "GLX_SGI_make_current_read");
 
         // GLX_ARB_multisample is always enabled, even if no configs support it
         if (strstr(wgl_extensions, "WGL_ARB_multisample"))
@@ -649,12 +649,9 @@ glxWinScreenProbe(ScreenPtr pScreen)
         if (strstr(wgl_extensions, "WGL_ARB_pbuffer"))
             screen->has_WGL_ARB_pbuffer = TRUE;
 
-        if (strstr(wgl_extensions, "WGL_ARB_make_current_read")) {
-            __glXEnableExtension(screen->glx_enable_bits,
-                                 "GLX_SGI_make_current_read");
-            LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_make_current_read\n");
-            glx_sgi_make_current_read = TRUE;
-        }
+        // GLX_SGI_make_current_read is effectively mandatory
+        if (strstr(wgl_extensions, "WGL_ARB_make_current_read"))
+            screen->has_WGL_ARB_make_current_read = TRUE;
 
         if (strstr(gl_extensions, "GL_WIN_swap_hint")) {
             __glXEnableExtension(screen->glx_enable_bits,
@@ -731,17 +728,8 @@ glxWinScreenProbe(ScreenPtr pScreen)
             }
         }
 
-        //
-        // Override the GLX version (__glXScreenInit() sets it to "1.2")
-        // if we have all the needed extensions to operate as a higher version
-        //
-        // SGIX_fbconfig && SGIX_pbuffer && SGI_make_current_read -> 1.3
-        // ARB_multisample -> 1.4
-        //
-        if (glx_sgi_make_current_read) {
-            screen->base.GLXmajor = 1;
-            screen->base.GLXminor = 4;
-        }
+        screen->base.GLXmajor = 1;
+        screen->base.GLXminor = 4;
     }
     LogMessage(X_INFO, "AIGLX: Set GLX version to %d.%d\n",
                screen->base.GLXmajor, screen->base.GLXminor);
@@ -1408,6 +1396,7 @@ static int
 glxWinContextMakeCurrent(__GLXcontext * base)
 {
     __GLXWinContext *gc = (__GLXWinContext *) base;
+    __GLXWinScreen *scr = (__GLXWinScreen *) base->pGlxScreen;
     BOOL ret;
     HDC drawDC;
     HDC readDC = NULL;
@@ -1440,7 +1429,14 @@ glxWinContextMakeCurrent(__GLXcontext * base)
     }
 
     if ((gc->base.readPriv != NULL) && (gc->base.readPriv != gc->base.drawPriv)) {
-        // XXX: should only occur with WGL_ARB_make_current_read
+        /*
+         * We enable this unconditionally, but the renderer _might_ not support
+         * it. It's fairly rare to use this feature so just error out if it
+         * can't work.
+         */
+        if (!scr->has_WGL_ARB_make_current_read)
+            return False;
+
         /*
            If there is a separate read drawable, create a separate read DC, and
            use the wglMakeContextCurrent extension to make the context current drawing
-- 
2.5.0



More information about the xorg-devel mailing list