From: Chia-I Wu Date: Tue, 30 Mar 2010 01:17:20 +0000 (+0800) Subject: st/glx: Remove a wrong assertion in choose_pixel_format. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c1a392ac4c6a7da4026653de556c2c7698f86860;p=mesa.git st/glx: Remove a wrong assertion in choose_pixel_format. 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. --- diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 4930cd6cd50..eb8d6a19333 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -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; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 3022d45157a..fd03d3c46a4 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -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);