Evas GL: Fix BadMatch with pbuffer make current
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 17 Nov 2015 08:18:57 +0000 (17:18 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 17 Nov 2015 09:04:43 +0000 (18:04 +0900)
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
src/modules/evas/engines/gl_x11/evas_engine.c
src/modules/evas/engines/gl_x11/evas_x_main.c

index 202e81b..378a806 100644 (file)
@@ -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;
index ab45b76..84db094 100644 (file)
@@ -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,
index 8ee32d2..d00b4ff 100644 (file)
@@ -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);