From 703539b0cb35e7b4c636f4cd3d8907fc5420beb8 Mon Sep 17 00:00:00 2001
From: Jerome Glisse <jglisse@redhat.com>
Date: Tue, 29 Jan 2013 18:37:41 -0500
Subject: [PATCH] glx do not use multisample visual config for front or pixmap

There is no garanty that glXGetFBConfigs will return fbconfig ordered
with non msaa config first. This patch make sure that non msaa config
get choose.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
---
 cogl/winsys/cogl-winsys-glx.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 2eddd1a..14cb594 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -518,13 +518,20 @@ glx_attributes_from_framebuffer_config (CoglDisplay *display,
   attributes[i++] = GLX_STENCIL_SIZE;
   attributes[i++] = config->need_stencil ? 1: GLX_DONT_CARE;
 
-  if (glx_renderer->glx_major == 1 && glx_renderer->glx_minor >= 4 &&
-      config->samples_per_pixel)
+  if (glx_renderer->glx_major == 1 && glx_renderer->glx_minor >= 4)
     {
-       attributes[i++] = GLX_SAMPLE_BUFFERS;
-       attributes[i++] = 1;
-       attributes[i++] = GLX_SAMPLES;
-       attributes[i++] = config->samples_per_pixel;
+       if (config->samples_per_pixel)
+         {
+            attributes[i++] = GLX_SAMPLE_BUFFERS;
+            attributes[i++] = 1;
+            attributes[i++] = GLX_SAMPLES;
+            attributes[i++] = config->samples_per_pixel;
+         }
+       else
+         {
+            attributes[i++] = GLX_SAMPLE_BUFFERS;
+            attributes[i++] = 0;
+         }
     }
 
   attributes[i++] = None;
@@ -1572,6 +1579,13 @@ get_fbconfig_for_depth (CoglContext *context,
       if (value != depth && (value - alpha) != depth)
         continue;
 
+      glx_renderer->glXGetFBConfigAttrib (dpy,
+                                          fbconfigs[i],
+                                          GLX_SAMPLES,
+                                          &value);
+      if (value > 1)
+        continue;
+
       value = 0;
       if (depth == 32)
         {
-- 
1.8.1

