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 <tomasz.lis@intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Tomasz Lis
2013-07-17 13:49:18 +02:00
committed by Ian Romanick
parent 1c748dff6b
commit 27c8aa5cfb
6 changed files with 41 additions and 25 deletions

View 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
}

View 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__ */

View 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;
}

View 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 = {

View 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);
}

View 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;