[Mesa-dev] [PATCH 2/2 v2] Fix indirect fallback when a non-Mesa GLX extension is present.

Aaron Plattner aplattner at nvidia.com
Thu Apr 22 10:48:02 PDT 2010


When driCreateScreen calls driConvertConfigs to try to convert the configs for
swrast, it fails and returns NULL.  Instead of checking, it just clobbers
psc->configs.  Then, when the application asks for the FBconfigs, there aren't
any.

Instead, make the caller responsible for freeing the modes lists if both calls
to driConvertConfigs succeed.

Without the second fix, glxinfo fails unless you run it with
LIBGL_ALWAYS_INDIRECT:

    $ glxinfo
    name of display: :0.0
    Error: couldn't find RGB GLX visual or fbconfig

    $ LIBGL_ALWAYS_INDIRECT=1 glxinfo
    name of display: :0.0
    display: :0  screen: 0
    direct rendering: No (LIBGL_ALWAYS_INDIRECT set)
    server glx vendor string: NVIDIA Corporation
    server glx version string: 1.4
    [...]

Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
---
On Thu, 2010-04-22 at 10:35 -0700, tom fogal wrote:
> Am I missing something, or does your 2/2 undo your 1/2 (what's the
> point, if so?)?

D'oh, it wasn't supposed to!  Apparently I screwed it up the git incantations
when I tried to rearrange the changes in my tree.  Here's the updated copy to
drop that part of it.  Thanks for catching it.

 src/glx/dri2_glx.c   |   21 +++++++++++++++++++--
 src/glx/dri_common.c |    2 --
 src/glx/dri_glx.c    |   19 ++++++++++++++++---
 src/glx/drisw_glx.c  |   22 ++++++++++++++++++++--
 4 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 3a53ce9..7cb6b4e 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -536,6 +536,7 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
    const __GLXDRIdisplayPrivate *const pdp = (__GLXDRIdisplayPrivate *)
       priv->dri2Display;
    __GLXDRIscreen *psp;
+   __GLcontextModes *configs = NULL, *visuals = NULL;
    char *driverName, *deviceName;
    drm_magic_t magic;
    int i;
@@ -607,8 +608,16 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
    driBindCommonExtensions(psc);
    dri2BindExtensions(psc);
 
-   psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
-   psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+   configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
+   visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+
+   if (!configs || !visuals)
+       goto handle_error;
+
+   _gl_context_modes_destroy(psc->configs);
+   psc->configs = configs;
+   _gl_context_modes_destroy(psc->visuals);
+   psc->visuals = visuals;
 
    psc->driver_configs = driver_configs;
 
@@ -652,6 +661,14 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
    return psp;
 
 handle_error:
+   if (configs)
+       _gl_context_modes_destroy(configs);
+   if (visuals)
+       _gl_context_modes_destroy(visuals);
+   if (psc->__driScreen)
+       (*psc->core->destroyScreen) (psc->__driScreen);
+   psc->__driScreen = NULL;
+
    Xfree(driverName);
    Xfree(deviceName);
    XFree(psp);
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index e403416..06f79ec 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -331,8 +331,6 @@ driConvertConfigs(const __DRIcoreExtension * core,
       tail = tail->next;
    }
 
-   _gl_context_modes_destroy(modes);
-
    return head.next;
 }
 
diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c
index e47db82..8f0da68 100644
--- a/src/glx/dri_glx.c
+++ b/src/glx/dri_glx.c
@@ -314,7 +314,7 @@ CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
    drm_handle_t hFB;
    int junk;
    const __DRIconfig **driver_configs;
-   __GLcontextModes *visual;
+   __GLcontextModes *visual, *configs = NULL, *visuals = NULL;
 
    /* DRI protocol version. */
    dri_version.major = driDpy->driMajor;
@@ -424,8 +424,16 @@ CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
       goto handle_error;
    }
 
-   psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
-   psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+   configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
+   visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+
+   if (!configs || !visuals)
+       goto handle_error;
+
+   _gl_context_modes_destroy(psc->configs);
+   psc->configs = configs;
+   _gl_context_modes_destroy(psc->visuals);
+   psc->visuals = visuals;
 
    psc->driver_configs = driver_configs;
 
@@ -454,6 +462,11 @@ CallCreateNewScreen(Display * dpy, int scrn, __GLXscreenConfigs * psc,
    return psp;
 
  handle_error:
+   if (configs)
+       _gl_context_modes_destroy(configs);
+   if (visuals)
+       _gl_context_modes_destroy(visuals);
+
    if (pSAREA != MAP_FAILED)
       drmUnmap(pSAREA, SAREA_MAX);
 
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 786faff..6a266c4 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -396,6 +396,7 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
    __GLXDRIscreen *psp;
    const __DRIconfig **driver_configs;
    const __DRIextension **extensions;
+   __GLcontextModes *configs = NULL, *visuals = NULL;
    int i;
 
    psp = Xcalloc(1, sizeof *psp);
@@ -435,8 +436,16 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
    driBindExtensions(psc);
    driBindCommonExtensions(psc);
 
-   psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
-   psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+   configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
+   visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+
+   if (!configs || !visuals)
+       goto handle_error;
+
+   _gl_context_modes_destroy(psc->configs);
+   psc->configs = configs;
+   _gl_context_modes_destroy(psc->visuals);
+   psc->visuals = visuals;
 
    psc->driver_configs = driver_configs;
 
@@ -450,6 +459,15 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
    return psp;
 
  handle_error:
+   if (configs)
+       _gl_context_modes_destroy(configs);
+   if (visuals)
+       _gl_context_modes_destroy(visuals);
+
+   if (psc->__driScreen)
+       (*psc->core->destroyScreen) (psc->__driScreen);
+   psc->__driScreen = NULL;
+
    Xfree(psp);
 
    if (psc->driver)
-- 
1.6.3.3



More information about the mesa-dev mailing list