From f7aa6b33b059d11c6c41ec3c339e972dfb9ef415 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 17 Nov 2015 17:18:57 +0900 Subject: [PATCH] Evas GL: Fix BadMatch with pbuffer make current This is the kind of horrible things you'll encounter when working with GL. The surface and context need to have matching configuration otherwise make current will fail, and the only way to get a matching config is to reuse the config selected to create the context. Gah. This is the same fix as for EGL. More a hack than a fix, to be honest. @fix --- src/modules/evas/engines/gl_common/evas_gl_common.h | 3 +++ src/modules/evas/engines/gl_x11/evas_engine.c | 12 +++++++++++- src/modules/evas/engines/gl_x11/evas_x_main.c | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h index 202e81bc8a..378a806f80 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -334,6 +334,9 @@ struct _Evas_Engine_GL_Context // FIXME: hack. expose egl display to gl core for egl image sec extn. void *egldisp; void *eglctxt; +#else + int glxcfg_rgb; + int glxcfg_rgba; #endif GLuint preserve_bit; diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c index ab45b76acc..84db094fc8 100644 --- a/src/modules/evas/engines/gl_x11/evas_engine.c +++ b/src/modules/evas/engines/gl_x11/evas_engine.c @@ -767,19 +767,22 @@ evgl_eng_pbuffer_surface_create(void *data, EVGL_Surface *sfc, return egl_sfc; #else + Evas_Engine_GL_Context *evasglctx; GLXPbuffer pbuf; GLXFBConfig *cfgs; int config_attrs[20]; int surface_attrs[20]; int ncfg = 0, i; - // TODO: Check all required config attributes + evasglctx = re->window_gl_context_get(re->software.ob); #ifndef GLX_VISUAL_ID # define GLX_VISUAL_ID 0x800b #endif i = 0; +#if 0 + // DISABLED BECAUSE BadMatch HAPPENS if (sfc->pbuffer.color_fmt != EVAS_GL_NO_FBO) { config_attrs[i++] = GLX_BUFFER_SIZE; @@ -808,6 +811,13 @@ evgl_eng_pbuffer_surface_create(void *data, EVGL_Surface *sfc, } //config_attrs[i++] = GLX_VISUAL_ID; //config_attrs[i++] = XVisualIDFromVisual(vis); +#else + config_attrs[i++] = GLX_FBCONFIG_ID; + if (sfc->pbuffer.color_fmt == EVAS_GL_RGB_888) + config_attrs[i++] = evasglctx->glxcfg_rgb; + else + config_attrs[i++] = evasglctx->glxcfg_rgba; +#endif config_attrs[i++] = 0; cfgs = glXChooseFBConfig(re->software.ob->disp, re->software.ob->screen, diff --git a/src/modules/evas/engines/gl_x11/evas_x_main.c b/src/modules/evas/engines/gl_x11/evas_x_main.c index 8ee32d2dde..d00b4ff92c 100644 --- a/src/modules/evas/engines/gl_x11/evas_x_main.c +++ b/src/modules/evas/engines/gl_x11/evas_x_main.c @@ -564,6 +564,9 @@ try_gles2: #ifdef GL_GLES gw->gl_context->egldisp = gw->egl_disp; gw->gl_context->eglctxt = gw->egl_context[0]; +#else + glXGetFBConfigAttrib(gw->disp, evis->config, GLX_FBCONFIG_ID, &gw->gl_context->glxcfg_rgb); + glXGetFBConfigAttrib(gw->disp, evis2->config, GLX_FBCONFIG_ID, &gw->gl_context->glxcfg_rgba); #endif eng_window_use(gw); glsym_evas_gl_common_context_resize(gw->gl_context, w, h, rot);