[gtk+] GdkGLContextX11: Ensure we get the fbconfig with the exact same visual
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GdkGLContextX11: Ensure we get the fbconfig with the exact same visual
- Date: Tue, 28 Oct 2014 17:30:54 +0000 (UTC)
commit 8d6d6dcca3bc30ed071232944c49443f3a45119e
Author: Alexander Larsson <alexl redhat com>
Date: Tue Oct 28 16:43:38 2014 +0100
GdkGLContextX11: Ensure we get the fbconfig with the exact same visual
We really want a gl context with exactly the same visual, or we will
get a badmatch later, which hits us on nvidia as per:
https://bugzilla.gnome.org/show_bug.cgi?id=738670
gdk/x11/gdkglcontext-x11.c | 50 +++++++++++++++----------------------------
1 files changed, 18 insertions(+), 32 deletions(-)
---
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index accc8a5..061b15a 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -574,6 +574,7 @@ find_fbconfig_for_visual (GdkDisplay *display,
int n_configs, i;
gboolean use_rgba;
gboolean retval = FALSE;
+ VisualID xvisual_id = XVisualIDFromVisual(gdk_x11_visual_get_xvisual (visual));
i = 0;
attrs[i++] = GLX_DRAWABLE_TYPE;
@@ -586,14 +587,13 @@ find_fbconfig_for_visual (GdkDisplay *display,
attrs[i++] = GL_TRUE;
attrs[i++] = GLX_RED_SIZE;
- attrs[i++] = gdk_visual_get_bits_per_rgb (visual);
+ attrs[i++] = 1;
attrs[i++] = GLX_GREEN_SIZE;
- attrs[i++] = gdk_visual_get_bits_per_rgb (visual);;
+ attrs[i++] = 1;
attrs[i++] = GLX_BLUE_SIZE;
- attrs[i++] = gdk_visual_get_bits_per_rgb (visual);;
+ attrs[i++] = 1;
use_rgba = (visual == gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)));
-
if (use_rgba)
{
attrs[i++] = GLX_ALPHA_SIZE;
@@ -618,44 +618,30 @@ find_fbconfig_for_visual (GdkDisplay *display,
return FALSE;
}
- /* if we don't care about an alpha channel, then the first
- * valid configuration is the one we give back
- */
- if (!use_rgba)
- {
- if (fb_config_out != NULL)
- *fb_config_out = configs[0];
-
- if (visinfo_out != NULL)
- *visinfo_out = glXGetVisualFromFBConfig (dpy, configs[0]);
-
- retval = TRUE;
- goto out;
- }
-
for (i = 0; i < n_configs; i++)
{
XVisualInfo *visinfo;
- unsigned long mask;
visinfo = glXGetVisualFromFBConfig (dpy, configs[i]);
if (visinfo == NULL)
- continue;
-
- mask = visinfo->red_mask | visinfo->green_mask | visinfo->blue_mask;
- if (visinfo->depth == 32 && mask != 0xffffffff)
{
- if (fb_config_out != NULL)
- *fb_config_out = configs[i];
+ XFree (visinfo);
+ continue;
+ }
- if (visinfo_out != NULL)
- *visinfo_out = visinfo;
+ if (visinfo->visualid != xvisual_id)
+ continue;
- retval = TRUE;
- goto out;
- }
+ if (fb_config_out != NULL)
+ *fb_config_out = configs[i];
- XFree (visinfo);
+ if (visinfo_out != NULL)
+ *visinfo_out = visinfo;
+ else
+ XFree (visinfo);
+
+ retval = TRUE;
+ goto out;
}
g_set_error (error, GDK_GL_ERROR,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]