glx: Store the RENDER_TYPE in indirect rendering
authorTomasz Lis <tomasz.lis@intel.com>
Wed, 17 Jul 2013 11:49:18 +0000 (13:49 +0200)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 18 Jul 2013 23:03:42 +0000 (16:03 -0700)
v2 (idr): Open-code the check for GLX_RENDER_TYPE.
dri2_convert_glx_attribs can't be called from here because that function
only exists in direct-rendering builds.  Also add a stub version of
indirect_create_context_attribs to tests/fake_glx_screen.cpp to prevent
'make check' regressions.

Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glx/create_context.c
src/glx/glxclient.h
src/glx/glxcmds.c
src/glx/indirect_glx.c
src/glx/tests/fake_glx_screen.cpp
src/glx/tests/fake_glx_screen.h

index a755e83f44820f039435ef3219ad68d413bc1920..38e949ab4cd94e09d4574710fdadac05a4328ce0 100644 (file)
@@ -84,7 +84,9 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
 #ifdef GLX_USE_APPLEGL
       gc = applegl_create_context(psc, cfg, share, 0);
 #else
-      gc = indirect_create_context(psc, cfg, share, 0);
+      gc = indirect_create_context_attribs(psc, cfg, share, num_attribs,
+              (const uint32_t *) attrib_list,
+              &dummy_err);
 #endif
    }
 
index 3e9b730e54aa8fa755905f8d5447b74dc7ac6d48..5b99e093d01f5dac355e54f006b8875716299e8d 100644 (file)
@@ -817,5 +817,12 @@ extern struct glx_context *
 indirect_create_context(struct glx_screen *psc,
                        struct glx_config *mode,
                        struct glx_context *shareList, int renderType);
+extern struct glx_context *
+indirect_create_context_attribs(struct glx_screen *base,
+                                struct glx_config *config_base,
+                                struct glx_context *shareList,
+                                unsigned num_attribs,
+                                const uint32_t *attribs,
+                                unsigned *error);
 
 #endif /* !__GLX_client_h__ */
index 415e7849742d57cb54a5a195adda8f10f240cb07..f6eb07df192cc5f2cfb10df6c9ad2819cfae486d 100644 (file)
@@ -344,7 +344,6 @@ CreateContext(Display *dpy, int generic_id, struct glx_config *config,
 
    gc->share_xid = shareList ? shareList->xid : None;
    gc->imported = GL_FALSE;
-   gc->renderType = renderType;
 
    return (GLXContext) gc;
 }
index ff869e2dc8fed168ec45e7e9c0d05a40a1ab67b4..11e92979156cb25f9aa72a3437d79a253f4fe09e 100644 (file)
@@ -362,6 +362,8 @@ indirect_create_context(struct glx_screen *psc,
    gc->isDirect = GL_FALSE;
    gc->vtable = &indirect_context_vtable;
    state = calloc(1, sizeof(struct __GLXattributeRec));
+   gc->renderType = renderType;
+
    if (state == NULL) {
       /* Out of memory */
       free(gc);
@@ -430,7 +432,7 @@ indirect_create_context(struct glx_screen *psc,
    return gc;
 }
 
-static struct glx_context *
+_X_HIDDEN struct glx_context *
 indirect_create_context_attribs(struct glx_screen *base,
                                struct glx_config *config_base,
                                struct glx_context *shareList,
@@ -438,18 +440,24 @@ indirect_create_context_attribs(struct glx_screen *base,
                                const uint32_t *attribs,
                                unsigned *error)
 {
-   /* All of the attribute validation for indirect contexts is handled on the
-    * server, so there's not much to do here.
-    */
-   (void) num_attribs;
-   (void) attribs;
+   int renderType = GLX_RGBA_TYPE;
+   unsigned i;
 
    /* The error parameter is only used on the server so that correct GLX
     * protocol errors can be generated.  On the client, it can be ignored.
     */
    (void) error;
 
-   return indirect_create_context(base, config_base, shareList, 0);
+   /* All of the attribute validation for indirect contexts is handled on the
+    * server, so there's not much to do here. Still, we need to parse the
+    * attributes to correctly set renderType.
+    */
+   for (i = 0; i < num_attribs; i++) {
+      if (attribs[i * 2] == GLX_RENDER_TYPE)
+         renderType = attribs[i * 2 + 1];
+   }
+
+   return indirect_create_context(base, config_base, shareList, renderType);
 }
 
 struct glx_screen_vtable indirect_screen_vtable = {
index 12d003b84f7542a23d5e931ae4ae2a1d4a6fb738..845084faa0fc0fa81a196616e5468c296a959294 100644 (file)
@@ -24,7 +24,7 @@
 
 struct glx_screen_vtable fake_glx_screen::vt = {
    indirect_create_context,
-   fake_glx_context::create_attribs
+   indirect_create_context_attribs
 };
 
 struct glx_screen_vtable fake_glx_screen_direct::vt = {
@@ -55,3 +55,18 @@ indirect_create_context(struct glx_screen *psc, struct glx_config *mode,
 
    return new fake_glx_context(psc, mode);
 }
+
+extern "C" struct glx_context *
+indirect_create_context_attribs(struct glx_screen *base,
+                               struct glx_config *config_base,
+                               struct glx_context *shareList,
+                               unsigned num_attribs,
+                               const uint32_t *attribs,
+                               unsigned *error)
+{
+   (void) num_attribs;
+   (void) attribs;
+   (void) error;
+
+   return indirect_create_context(base, config_base, shareList, 0);
+}
index 6aa6cb68fe94a950e27cb825067f9d21f307bf46..0249e79bcfffded138cc60d175cdf515dbb7d0e9 100644 (file)
@@ -88,21 +88,6 @@ public:
       contexts_allocated--;
    }
 
-   static glx_context *create_attribs(struct glx_screen *psc,
-                                     struct glx_config *mode,
-                                     struct glx_context *shareList,
-                                     unsigned num_attribs,
-                                     const uint32_t *attribs,
-                                     unsigned *error)
-   {
-      (void) shareList;
-      (void) num_attribs;
-      (void) attribs;
-
-      *error = 0;
-      return new fake_glx_context(psc, mode);
-   }
-
    /** Number of context that are allocated (and not freed). */
    static int contexts_allocated;