xserver: Branch 'master' - 8 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Sep 25 17:26:44 UTC 2018


 hw/xwin/glx/indirect.c |  241 ++++++++++++++++++++++++++++++++-----------------
 hw/xwin/glx/indirect.h |    1 
 2 files changed, 160 insertions(+), 82 deletions(-)

New commits:
commit 2f424df0ca340b1c4e47d9461b04a2c5ec3ec649
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Tue May 2 14:00:47 2017 +0100

    hw/xwin/glx: Fix logging about WGL pxfs with overlays
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index ebc1a3c2c..f429bf06d 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -2249,7 +2249,7 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
 
             if (layers > 0) {
                 ErrorF
-                    ("pixelFormat %d: has %d overlay, %d underlays which aren't currently handled",
+                    ("pixelFormat %d: has %d overlay, %d underlays which aren't currently handled\n",
                      i, ATTR_VALUE(WGL_NUMBER_OVERLAYS_ARB, 0),
                      ATTR_VALUE(WGL_NUMBER_UNDERLAYS_ARB, 0));
                 // XXX: need to iterate over layers?
commit d63f9dddeb0c656af2b8c6135cc40a76f0b5604f
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Fri Jul 15 15:18:36 2016 +0100

    hw/xwin/glx: Use multisample attributes with wglChoosePixelFormatARB()
    
    Seems like this was omitted in error
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index d84713a0d..ebc1a3c2c 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -1737,6 +1737,11 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode,
     if (mode->visualRating == GLX_SLOW_VISUAL_EXT)
         SET_ATTR_VALUE(WGL_ACCELERATION_ARB, WGL_NO_ACCELERATION_ARB);
 
+    if (winScreen->has_WGL_ARB_multisample) {
+        SET_ATTR_VALUE(WGL_SAMPLE_BUFFERS_ARB, mode->sampleBuffers);
+        SET_ATTR_VALUE(WGL_SAMPLES_ARB, mode->samples);
+    }
+
     // must support all the drawable types the mode supports
     if ((mode->drawableType | drawableTypeOverride) & GLX_WINDOW_BIT)
         SET_ATTR_VALUE(WGL_DRAW_TO_WINDOW_ARB, TRUE);
commit e3398d921be74df9c5d23408f39e70548df896d8
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Fri Jul 15 15:15:18 2016 +0100

    hw/xwin/glx: Add GLX_ARB_framebuffer_sRGB extension
    
    v2:
    Fix a bogus warning about a missing pixelformat attribute issued for every
    pixelformat when WGL_ARB_framebuffer_sRGB isn't available
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index e9fb3becd..d84713a0d 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -293,11 +293,11 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
         return;
     ErrorF("%d fbConfigs\n", n);
     ErrorF
-        ("pxf vis  fb                      render         Ste                     aux    accum        MS    drawable             Group/\n");
+        ("pxf vis  fb                      render         Ste                     aux    accum        MS    drawable             Group/ sRGB\n");
     ErrorF
-        ("idx  ID  ID VisualType Depth Lvl RGB CI DB Swap reo  R  G  B  A   Z  S  buf AR AG AB AA  bufs num  W P Pb  Float Trans Caveat\n");
+        ("idx  ID  ID VisualType Depth Lvl RGB CI DB Swap reo  R  G  B  A   Z  S  buf AR AG AB AA  bufs num  W P Pb  Float Trans Caveat cap \n");
     ErrorF
-        ("-----------------------------------------------------------------------------------------------------------------------------\n");
+        ("----------------------------------------------------------------------------------------------------------------------------------\n");
 
     while (c != NULL) {
         unsigned int i = ((GLXWinConfig *) c)->pixelFormatIndex;
@@ -317,7 +317,8 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
                "  %s %s %s "
                "    %s   "
                "  %s   "
-               "  %d %s"
+               "  %d %s "
+               "  %s"
                "\n",
                i, c->visualID, c->fbconfigID,
                visual_class_name(c->visualType),
@@ -339,7 +340,8 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
                float_col,
                (c->transparentPixel != GLX_NONE_EXT) ? "y" : ".",
                c->visualSelectGroup,
-               (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " ");
+               (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " ",
+               c->sRGBCapable ? "y" : ".");
 
         c = c->next;
     }
@@ -599,6 +601,7 @@ glxWinScreenProbe(ScreenPtr pScreen)
             { "WGL_ARB_create_context_profile", "GLX_ARB_create_context_profile", 0 },
             { "WGL_ARB_create_context_robustness", "GLX_ARB_create_context_robustness", 0 },
             { "WGL_EXT_create_context_es2_profile", "GLX_EXT_create_context_es2_profile", 0 },
+            { "WGL_ARB_framebuffer_sRGB", "GLX_ARB_framebuffer_sRGB", 0 },
         };
 
         //
@@ -633,6 +636,10 @@ glxWinScreenProbe(ScreenPtr pScreen)
         if (strstr(wgl_extensions, "WGL_ARB_multisample"))
             screen->has_WGL_ARB_multisample = TRUE;
 
+        if (strstr(wgl_extensions, "WGL_ARB_framebuffer_sRGB")) {
+            screen->has_WGL_ARB_framebuffer_sRGB = TRUE;
+        }
+
         screen->base.destroy = glxWinScreenDestroy;
         screen->base.createContext = glxWinCreateContext;
         screen->base.createDrawable = glxWinCreateDrawable;
@@ -1753,6 +1760,9 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode,
                 SET_ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, TRUE);
     }
 
+    if (winScreen->has_WGL_ARB_framebuffer_sRGB)
+        SET_ATTR_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, TRUE);
+
     SET_ATTR_VALUE(0, 0);       // terminator
 
     /* choose the first match */
@@ -2114,6 +2124,11 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
         ADD_ATTR(WGL_MAX_PBUFFER_HEIGHT_ARB);
     }
 
+    if (screen->has_WGL_ARB_framebuffer_sRGB) {
+        // we may not query these attrs if WGL_ARB_framebuffer_sRGB is not offered
+        ADD_ATTR(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
+    }
+
     /* fill in configs */
     for (i = 0; i < numConfigs; i++) {
         int values[num_attrs];
@@ -2376,7 +2391,12 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
             GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT |
             GLX_TEXTURE_RECTANGLE_BIT_EXT;
         c->base.yInverted = -1;
-        c->base.sRGBCapable = 0;
+
+        /* WGL_ARB_framebuffer_sRGB */
+        if (screen->has_WGL_ARB_framebuffer_sRGB)
+            c->base.sRGBCapable = ATTR_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, 0);
+        else
+            c->base.sRGBCapable = 0;
 
         n++;
 
diff --git a/hw/xwin/glx/indirect.h b/hw/xwin/glx/indirect.h
index bcdef153a..c32ce7894 100644
--- a/hw/xwin/glx/indirect.h
+++ b/hw/xwin/glx/indirect.h
@@ -69,6 +69,7 @@ struct __GLXWinScreen {
     Bool has_WGL_ARB_pbuffer;
     Bool has_WGL_ARB_render_texture;
     Bool has_WGL_ARB_make_current_read;
+    Bool has_WGL_ARB_framebuffer_sRGB;
 
     /* wrapped screen functions */
     RealizeWindowProcPtr RealizeWindow;
commit 1fc240c6877e44fc9e6d85837dc2d27e26193291
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Fri Jul 15 13:46:45 2016 +0100

    hw/xwin/glx: publish GLX create_context extensions
    
    Future work: To properly support GLX_ARB_create_context in indirect mode, we
    need to use wglCreateContextAttribsARB() rather than wglCreateContext(),
    when attribs are provided, rather than just dropping attribs on the floor,
    as we currently do.
    
    That probably entails removing the deferred context creation and instead
    using a temporary window, as direct WGL does.
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 1ab326b46..e9fb3becd 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -595,6 +595,10 @@ glxWinScreenProbe(ScreenPtr pScreen)
             { "WGL_ARB_multisample", "GLX_SGIS_multisample", 0 },
             { "WGL_ARB_pixel_format_float", "GLX_ARB_fbconfig_float", 0 },
             { "WGL_EXT_pixel_format_packed_float", "GLX_EXT_fbconfig_packed_float", 0 },
+            { "WGL_ARB_create_context", "GLX_ARB_create_context", 0 },
+            { "WGL_ARB_create_context_profile", "GLX_ARB_create_context_profile", 0 },
+            { "WGL_ARB_create_context_robustness", "GLX_ARB_create_context_robustness", 0 },
+            { "WGL_EXT_create_context_es2_profile", "GLX_EXT_create_context_es2_profile", 0 },
         };
 
         //
commit 67b47d50dfb5f7a994ae44708d1b1ef1c42537b5
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Fri Jul 15 14:06:32 2016 +0100

    hw/xwin/glx: Add support for float format fbconfig GLX extensions
    
    v2:
    Set renderType more correctly
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 59257362a..1ab326b46 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -302,6 +302,10 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
     while (c != NULL) {
         unsigned int i = ((GLXWinConfig *) c)->pixelFormatIndex;
 
+        const char *float_col = ".";
+        if (c->renderType & GLX_RGBA_FLOAT_BIT_ARB) float_col = "s";
+        if (c->renderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) float_col = "u";
+
         ErrorF("%3d %3x %3x "
                "%-11s"
                " %3d %3d   %s   %s  %s %s  %s  "
@@ -332,8 +336,7 @@ fbConfigsDump(unsigned int n, __GLXconfig * c)
                (c->drawableType & GLX_WINDOW_BIT) ? "y" : ".",
                (c->drawableType & GLX_PIXMAP_BIT) ? "y" : ".",
                (c->drawableType & GLX_PBUFFER_BIT) ? "y" : ".",
-               (c->renderType & (GLX_RGBA_FLOAT_BIT_ARB |
-                   GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT)) ? "y" : ".",
+               float_col,
                (c->transparentPixel != GLX_NONE_EXT) ? "y" : ".",
                c->visualSelectGroup,
                (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " ");
@@ -590,6 +593,8 @@ glxWinScreenProbe(ScreenPtr pScreen)
             { "WGL_ARB_pbuffer", "GLX_SGIX_pbuffer", 1 },
             { "WGL_ARB_multisample", "GLX_ARB_multisample", 1 },
             { "WGL_ARB_multisample", "GLX_SGIS_multisample", 0 },
+            { "WGL_ARB_pixel_format_float", "GLX_ARB_fbconfig_float", 0 },
+            { "WGL_EXT_pixel_format_packed_float", "GLX_EXT_fbconfig_packed_float", 0 },
         };
 
         //
@@ -1664,13 +1669,34 @@ fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode,
     int attribList[60];
 
     SET_ATTR_VALUE(WGL_SUPPORT_OPENGL_ARB, TRUE);
-    SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB,
-                   (mode->visualType ==
-                    GLX_TRUE_COLOR) ? WGL_TYPE_RGBA_ARB :
-                   WGL_TYPE_COLORINDEX_ARB);
-    SET_ATTR_VALUE(WGL_COLOR_BITS_ARB,
-                   (mode->visualType ==
-                    GLX_TRUE_COLOR) ? mode->rgbBits : mode->indexBits);
+
+    switch (mode->renderType)
+        {
+        case GLX_COLOR_INDEX_BIT:
+        case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT:
+            SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_COLORINDEX_ARB);
+            SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->indexBits);
+            break;
+
+        default:
+            ErrorF("unexpected renderType %x\n", mode->renderType);
+            /* fall-through */
+        case GLX_RGBA_BIT:
+            SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB);
+            SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits);
+            break;
+
+        case GLX_RGBA_FLOAT_BIT_ARB:
+            SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_FLOAT_ARB);
+            SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits);
+            break;
+
+        case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT:
+            SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT);
+            SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits);
+            break;
+        }
+
     SET_ATTR_VALUE(WGL_RED_BITS_ARB, mode->redBits);
     SET_ATTR_VALUE(WGL_GREEN_BITS_ARB, mode->greenBits);
     SET_ATTR_VALUE(WGL_BLUE_BITS_ARB, mode->blueBits);
@@ -2138,23 +2164,42 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
             c->base.indexBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
             c->base.rgbBits = 0;
             c->base.visualType = GLX_STATIC_COLOR;
+            c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT;
+
+            /*
+              Assume RGBA rendering is available on all single-channel visuals
+              (it is specified to render to red component in single-channel
+              visuals, if supported, but there doesn't seem to be any mechanism
+              to check if it is supported)
+
+              Color index rendering is only supported on single-channel visuals
+            */
+
+            break;
+
+        case WGL_TYPE_RGBA_ARB:
+            c->base.indexBits = 0;
+            c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
+            c->base.visualType = GLX_TRUE_COLOR;
+            c->base.renderType = GLX_RGBA_BIT;
             break;
 
         case WGL_TYPE_RGBA_FLOAT_ARB:
-            GLWIN_DEBUG_MSG
-                ("pixelFormat %d is WGL_TYPE_RGBA_FLOAT_ARB, skipping", i + 1);
-            continue;
+            c->base.indexBits = 0;
+            c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
+            c->base.visualType = GLX_TRUE_COLOR;
+            c->base.renderType = GLX_RGBA_FLOAT_BIT_ARB;
+            // assert pbuffer drawable
+            // assert WGL_ARB_pixel_format_float
+            break;
 
         case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT:
-            GLWIN_DEBUG_MSG
-                ("pixelFormat %d is WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT, skipping",
-                 i + 1);
-            continue;
-
-        case WGL_TYPE_RGBA_ARB:
             c->base.indexBits = 0;
             c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0);
             c->base.visualType = GLX_TRUE_COLOR;
+            c->base.renderType = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
+            // assert pbuffer drawable
+            // assert WGL_EXT_pixel_format_packed_float
             break;
 
         default:
@@ -2252,21 +2297,6 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
              | (ATTR_VALUE(WGL_DRAW_TO_BITMAP_ARB, 0) ? GLX_PIXMAP_BIT : 0)
              | (ATTR_VALUE(WGL_DRAW_TO_PBUFFER_ARB, 0) ? GLX_PBUFFER_BIT : 0));
 
-        /*
-           Assume OpenGL RGBA rendering is available on all visuals
-           (it is specified to render to red component in single-channel visuals,
-           if supported, but there doesn't seem to be any mechanism to check if it
-           is supported)
-
-           Color index rendering is only supported on single-channel visuals
-         */
-        if (c->base.visualType == GLX_STATIC_COLOR) {
-            c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT;
-        }
-        else {
-            c->base.renderType = GLX_RGBA_BIT;
-        }
-
         c->base.fbconfigID = -1;        // will be set by __glXScreenInit()
 
         /* SGIX_pbuffer / GLX 1.3 */
commit 6be9681eb9eb6645b19c09f7b3b6d5b5bef8866d
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Fri Jul 15 14:02:10 2016 +0100

    hw/xwin/glx: Make WGL -> GLX extension mapping table-driven
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 91fb6cffe..59257362a 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -572,47 +572,57 @@ glxWinScreenProbe(ScreenPtr pScreen)
     // might have completely different capabilities.  Of course, good luck getting
     // those screens to be accelerated in XP and earlier...
 
+
     {
+        int i;
+
+        const struct
+        {
+            const char *wglext;
+            const char *glxext;
+            Bool mandatory;
+        } extensionMap[] = {
+            { "WGL_ARB_make_current_read", "GLX_SGI_make_current_read", 1 },
+            { "WGL_EXT_swap_control", "GLX_SGI_swap_control", 0 },
+            { "WGL_EXT_swap_control", "GLX_MESA_swap_control", 0 },
+            //      { "WGL_ARB_render_texture", "GLX_EXT_texture_from_pixmap", 0 },
+            // Sufficiently different that it's not obvious if this can be done...
+            { "WGL_ARB_pbuffer", "GLX_SGIX_pbuffer", 1 },
+            { "WGL_ARB_multisample", "GLX_ARB_multisample", 1 },
+            { "WGL_ARB_multisample", "GLX_SGIS_multisample", 0 },
+        };
+
         //
         // Based on the WGL extensions available, enable various GLX extensions
-        // XXX: make this table-driven ?
         //
         __glXInitExtensionEnableBits(screen->base.glx_enable_bits);
 
-        if (strstr(wgl_extensions, "WGL_ARB_make_current_read"))
-            screen->has_WGL_ARB_make_current_read = TRUE;
-        else
-            LogMessage(X_WARNING, "AIGLX: missing WGL_ARB_make_current_read\n");
+        for (i = 0; i < sizeof(extensionMap)/sizeof(extensionMap[0]); i++) {
+            if (strstr(wgl_extensions, extensionMap[i].wglext)) {
+                __glXEnableExtension(screen->base.glx_enable_bits, extensionMap[i].glxext);
+                LogMessage(X_INFO, "GLX: enabled %s\n", extensionMap[i].glxext);
+            }
+            else if (extensionMap[i].mandatory) {
+                LogMessage(X_ERROR, "required WGL extension %s is missing\n", extensionMap[i].wglext);
+            }
+        }
 
+        // Because it pre-dates WGL_EXT_extensions_string, GL_WIN_swap_hint might
+        // only be in GL_EXTENSIONS
         if (strstr(gl_extensions, "GL_WIN_swap_hint")) {
             __glXEnableExtension(screen->base.glx_enable_bits,
                                  "GLX_MESA_copy_sub_buffer");
             LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
         }
 
-        if (strstr(wgl_extensions, "WGL_EXT_swap_control")) {
-            __glXEnableExtension(screen->base.glx_enable_bits,
-                                 "GLX_SGI_swap_control");
-            LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_swap_control\n");
-        }
-
-/*       // Hmm?  screen->texOffset */
-/*       if (strstr(wgl_extensions, "WGL_ARB_render_texture")) */
-/*         { */
-/*           __glXEnableExtension(screen->base.glx_enable_bits, "GLX_EXT_texture_from_pixmap"); */
-/*           LogMessage(X_INFO, "AIGLX: GLX_EXT_texture_from_pixmap backed by buffer objects\n"); */
-/*           screen->has_WGL_ARB_render_texture = TRUE; */
-/*         } */
+        if (strstr(wgl_extensions, "WGL_ARB_make_current_read"))
+            screen->has_WGL_ARB_make_current_read = TRUE;
 
         if (strstr(wgl_extensions, "WGL_ARB_pbuffer"))
             screen->has_WGL_ARB_pbuffer = TRUE;
-        else
-            LogMessage(X_WARNING, "AIGLX: missing WGL_ARB_pbuffer\n");
 
         if (strstr(wgl_extensions, "WGL_ARB_multisample"))
             screen->has_WGL_ARB_multisample = TRUE;
-        else
-            LogMessage(X_WARNING, "AIGLX: missing WGL_ARB_multisample\n");
 
         screen->base.destroy = glxWinScreenDestroy;
         screen->base.createContext = glxWinCreateContext;
commit ad6b4113cd27e7c57908081c0a20ab956d418f06
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Thu Jul 24 12:26:22 2014 +0100

    hw/xwin/glx: Fallback to ChoosePixelFormat() if wglChoosePixelFormatARB() fails
    
    In glxWinSetPixelFormat() handle the case where wglChoosePixelFormatARB()
    fails and fallback to ChoosePixelFormat()
    
    It seems for some drivers, wglChoosePixelFormatARB() can fail when the
    provided DC doesn't belong to the driver (e.g. it's a compatible DC for a
    bitmap, so allow a fallback to ChoosePixelFormat() if it fails.
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 5d2defb05..91fb6cffe 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -1133,7 +1133,30 @@ glxWinSetPixelFormat(HDC hdc, int bppOverride, int drawableTypeOverride,
          (config->redBits + config->greenBits + config->blueBits), bppOverride,
          config->drawableType, drawableTypeOverride);
 
-    if (!winScreen->has_WGL_ARB_pixel_format) {
+    if (winScreen->has_WGL_ARB_pixel_format) {
+        int pixelFormat =
+            fbConfigToPixelFormatIndex(hdc, config,
+                                       drawableTypeOverride, winScreen);
+        if (pixelFormat != 0) {
+            GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d",
+                            pixelFormat);
+            ErrorF
+                ("wglChoosePixelFormat: chose pixelFormatIndex %d (rather than %d as originally planned)\n",
+                 pixelFormat, winConfig->pixelFormatIndex);
+
+            if (!SetPixelFormat(hdc, pixelFormat, NULL)) {
+                ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
+                return FALSE;
+            }
+        }
+    }
+
+    /*
+      For some drivers, wglChoosePixelFormatARB() can fail when the provided
+      DC doesn't belong to the driver (e.g. it's a compatible DC for a bitmap,
+      so allow fallback to ChoosePixelFormat()
+     */
+    {
         PIXELFORMATDESCRIPTOR pfd;
         int pixelFormat;
 
@@ -1169,25 +1192,6 @@ glxWinSetPixelFormat(HDC hdc, int bppOverride, int drawableTypeOverride,
             return FALSE;
         }
     }
-    else {
-        int pixelFormat = fbConfigToPixelFormatIndex(hdc, config,
-                                                     drawableTypeOverride,
-                                                     winScreen);
-        if (pixelFormat == 0) {
-            return FALSE;
-        }
-
-        GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d",
-                        pixelFormat);
-        ErrorF
-            ("wglChoosePixelFormat: chose pixelFormatIndex %d (rather than %d as originally planned)\n",
-             pixelFormat, winConfig->pixelFormatIndex);
-
-        if (!SetPixelFormat(hdc, pixelFormat, NULL)) {
-            ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage());
-            return FALSE;
-        }
-    }
 
     return TRUE;
 }
commit 8c0adf404a25407995dae79664ef4875ce093497
Author: Jon Turney <jon.turney at dronecode.org.uk>
Date:   Sat Jan 11 16:35:31 2014 +0000

    hw/xwin/glx: Don't create fbConfigs for un-accelerated pixelFormats
    
    Exposing these pixelFormats is problematic: they are provided by the 'GDI
    Generic' renderer, which doesn't support the same set of extensions as the
    IGD providing the more capable pixelFormats.
    
    Signed-off-by: Jon Turney <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 1aaa87d8f..5d2defb05 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -1839,6 +1839,8 @@ glxWinCreateConfigs(HDC hdc, glxWinScreen * screen)
         /* EXT_visual_rating / GLX 1.2 */
         if (pfd.dwFlags & PFD_GENERIC_FORMAT) {
             c->base.visualRating = GLX_SLOW_VISUAL_EXT;
+            GLWIN_DEBUG_MSG("pixelFormat %d is un-accelerated, skipping", i + 1);
+            continue;
         }
         else {
             // PFD_GENERIC_ACCELERATED is not considered, so this may be MCD or ICD acclerated...
@@ -2183,6 +2185,8 @@ glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen)
 
         case WGL_NO_ACCELERATION_ARB:
             c->base.visualRating = GLX_SLOW_VISUAL_EXT;
+            GLWIN_DEBUG_MSG("pixelFormat %d is un-accelerated, skipping", i + 1);
+            continue;
             break;
 
         case WGL_GENERIC_ACCELERATION_ARB:


More information about the xorg-commit mailing list