From 27c8aa5cfbcf6f2ad21564dfcdabbe747c277cab Mon Sep 17 00:00:00 2001 From: Tomasz Lis Date: Wed, 17 Jul 2013 13:49:18 +0200 Subject: [PATCH] glx: Store the RENDER_TYPE in indirect rendering 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 Signed-off-by: Ian Romanick Reviewed-by: Ian Romanick --- src/glx/create_context.c | 4 +++- src/glx/glxclient.h | 7 +++++++ src/glx/glxcmds.c | 1 - src/glx/indirect_glx.c | 22 +++++++++++++++------- src/glx/tests/fake_glx_screen.cpp | 17 ++++++++++++++++- src/glx/tests/fake_glx_screen.h | 15 --------------- 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/glx/create_context.c b/src/glx/create_context.c index a755e83f448..38e949ab4cd 100644 --- a/src/glx/create_context.c +++ b/src/glx/create_context.c @@ -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 } diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 3e9b730e54a..5b99e093d01 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -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__ */ diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 415e7849742..f6eb07df192 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -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; } diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index ff869e2dc8f..11e92979156 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -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 = { diff --git a/src/glx/tests/fake_glx_screen.cpp b/src/glx/tests/fake_glx_screen.cpp index 12d003b84f7..845084faa0f 100644 --- a/src/glx/tests/fake_glx_screen.cpp +++ b/src/glx/tests/fake_glx_screen.cpp @@ -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); +} diff --git a/src/glx/tests/fake_glx_screen.h b/src/glx/tests/fake_glx_screen.h index 6aa6cb68fe9..0249e79bcff 100644 --- a/src/glx/tests/fake_glx_screen.h +++ b/src/glx/tests/fake_glx_screen.h @@ -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; -- 2.30.2