[Libva] [PATCH] glx: fix gl_create_context() with parent context set.

Gwenole Beauchesne gb.devel at gmail.com
Thu Jul 26 07:26:37 PDT 2012


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 at intel.com>
---
 va/glx/va_glx_impl.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/va/glx/va_glx_impl.c b/va/glx/va_glx_impl.c
index 049be09..f317961 100644
--- a/va/glx/va_glx_impl.c
+++ b/va/glx/va_glx_impl.c
@@ -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,
-- 
1.7.9.5



More information about the Libva mailing list