OSDN Git Service

glx: fix gl_create_context() with parent context set.
authorGwenole Beauchesne <gb.devel@gmail.com>
Thu, 26 Jul 2012 14:26:37 +0000 (16:26 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 28 Sep 2012 13:58:42 +0000 (15:58 +0200)
If GLX window was created from a foreign Display, then that same Display shall
be used for subsequent glXMakeCurrent(). This means that gl_create_context()
will now use the same Display that the parent, if available.

This fixes cluttersink with the Intel GenX VA driver.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
va/glx/va_glx_impl.c

index 049be09..f317961 100644 (file)
@@ -340,8 +340,14 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
     if (!cs)
         goto error;
 
-    cs->display = ctx->native_dpy;
-    cs->window  = parent ? parent->window : None;
+    if (parent) {
+        cs->display = parent->display;
+        cs->window  = parent->window;
+    }
+    else {
+        cs->display = ctx->native_dpy;
+        cs->window  = None;
+    }
     cs->context = NULL;
 
     if (parent && parent->context) {
@@ -357,8 +363,8 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
             goto choose_fbconfig;
 
         fbconfigs = glXGetFBConfigs(
-            ctx->native_dpy,
-            ctx->x11_screen,
+            parent->display,
+            DefaultScreen(parent->display),
             &n_fbconfigs
         );
         if (!fbconfigs)
@@ -367,7 +373,7 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
         /* Find out a GLXFBConfig compatible with the parent context */
         for (n = 0; n < n_fbconfigs; n++) {
             status = glXGetFBConfigAttrib(
-                ctx->native_dpy,
+                cs->display,
                 fbconfigs[n],
                 GLX_FBCONFIG_ID, &val
             );
@@ -392,7 +398,7 @@ gl_create_context(VADriverContextP ctx, OpenGLContextStateP parent)
     }
 
     cs->context = glXCreateNewContext(
-        ctx->native_dpy,
+        cs->display,
         fbconfigs[n],
         GLX_RGBA_TYPE,
         parent ? parent->context : NULL,