From 4ef955a12a526dcad388133b6dc8426a51054cdd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 20 Jan 2011 13:32:35 -0700 Subject: graw: fix logic error in pixel format selection The loop to choose a pixel format for the window was incrementing 'i' after we succeeded in creating the window so if we chose format[0] for graw_create_window_and_screen() we were putting format[1] in the pipe_resource template for creating the render target. This only worked because of the order of the elements in the formats[] array. The graw_xlib.c code now properly compares the requested gallium pixel format against the visual's color layout. Update all the graw demos to fix the off-by-one-i error. --- src/gallium/targets/graw-xlib/graw_xlib.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/gallium/targets/graw-xlib') diff --git a/src/gallium/targets/graw-xlib/graw_xlib.c b/src/gallium/targets/graw-xlib/graw_xlib.c index 578086f8f9..b6d798e577 100644 --- a/src/gallium/targets/graw-xlib/graw_xlib.c +++ b/src/gallium/targets/graw-xlib/graw_xlib.c @@ -66,9 +66,6 @@ graw_create_window_and_screen( int x, root = RootWindow( graw.display, scrnum ); - if (format != PIPE_FORMAT_R8G8B8A8_UNORM) - goto fail; - if (graw.display == NULL) goto fail; @@ -88,6 +85,23 @@ graw_create_window_and_screen( int x, exit(1); } + /* See if the requirested pixel format matches the visual */ + if (visinfo->red_mask == 0xff0000 && + visinfo->green_mask == 0xff00 && + visinfo->blue_mask == 0xff) { + if (format != PIPE_FORMAT_B8G8R8A8_UNORM) + goto fail; + } + else if (visinfo->red_mask == 0xff && + visinfo->green_mask == 0xff00 && + visinfo->blue_mask == 0xff0000) { + if (format != PIPE_FORMAT_R8G8B8A8_UNORM) + goto fail; + } + else { + goto fail; + } + /* window attributes */ attr.background_pixel = 0; attr.border_pixel = 0; -- cgit v1.2.3