st/glx: Remove a wrong assertion in choose_pixel_format.
authorChia-I Wu <olv@lunarg.com>
Tue, 30 Mar 2010 01:17:20 +0000 (09:17 +0800)
committerChia-I Wu <olv@lunarg.com>
Tue, 30 Mar 2010 03:20:53 +0000 (11:20 +0800)
There are X visuals that Gallium or the code does not support.  We could
not assert the color format to be supported.  Return PIPE_FORMAT_NONE in
such cases and let the caller handle it.

src/gallium/state_trackers/glx/xlib/glx_api.c
src/gallium/state_trackers/glx/xlib/xm_api.c

index 4930cd6..eb8d6a1 100644 (file)
@@ -1758,6 +1758,10 @@ glXGetFBConfigs( Display *dpy, int screen, int *nelements )
       }
       for (i = 0; i < *nelements; i++) {
          results[i] = create_glx_visual(dpy, visuals + i);
+         if (!results[i]) {
+            *nelements = i;
+            break;
+         }
       }
       return (GLXFBConfig *) results;
    }
index 3022d45..fd03d3c 100644 (file)
@@ -327,8 +327,7 @@ choose_pixel_format(XMesaVisual v)
       return PIPE_FORMAT_B5G6R5_UNORM;
    }
 
-   assert(0);
-   return 0;
+   return PIPE_FORMAT_NONE;
 }
 
 
@@ -737,6 +736,12 @@ XMesaVisual XMesaCreateVisual( Display *display,
    }
 
    v->stvis.color_format = choose_pixel_format(v);
+   if (v->stvis.color_format == PIPE_FORMAT_NONE) {
+      FREE(v->visinfo);
+      FREE(v);
+      return NULL;
+   }
+
    v->stvis.depth_stencil_format =
       choose_depth_stencil_format(xmdpy, depth_size, stencil_size);