[Cogl] [PATCH 1/3] egl: Only allow GLES2 context creation for the GLES2 driver

Robert Bragg robert at sixbynine.org
Mon Oct 1 05:39:33 PDT 2012


This looks good to land to me:

Reviewed-by: Robert Bragg <robert at linux.intel.com>

thanks,
- Robert

On Mon, Oct 1, 2012 at 12:06 PM, Neil Roberts <neil at linux.intel.com> wrote:
> Previously, Cogl was advertising the GLES2 context feature whenever
> the EGL winsys was used, even if the winsys was used with the GL
> driver. This wasn't working because when the GL context is created the
> API is set to GL with eglBindAPI and it is never changed back to GLES
> when the GLES2 context is created. That meant that the created context
> is actually GL not GLES2. Any rendering would then fail because the GL
> context does not understand the precision statement.
>
> It could be possible to fix it so that it will set the API correctly
> before creating the context. It would then also need to reset the API
> and unbind the previous context whenever switching between GLES2 and
> GL contexts. If the context isn't unbound first then eglMakeCurrent
> will actually try to bind both contexts at the same time and at least
> Mesa detects this situation and reports that the two contexts
> conflict. Presumably we would also need to do something more clever
> when we retrieve the function pointers for the GLES2 context.
> Currently we just copy them from the CoglContext but if the context is
> using the GL driver then this would mean the functions came from libGL
> not libGLESv2.
> ---
>  cogl/winsys/cogl-winsys-egl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
> index 2ff7687..91f247d 100644
> --- a/cogl/winsys/cogl-winsys-egl.c
> +++ b/cogl/winsys/cogl-winsys-egl.c
> @@ -489,7 +489,8 @@ _cogl_winsys_context_init (CoglContext *context, CoglError **error)
>    /* NB: We currently only support creating standalone GLES2 contexts
>     * for offscreen rendering and so we need a dummy (non-visible)
>     * surface to be able to bind those contexts */
> -  if (egl_display->dummy_surface != EGL_NO_SURFACE)
> +  if (egl_display->dummy_surface != EGL_NO_SURFACE &&
> +      context->driver == COGL_DRIVER_GLES2)
>      COGL_FLAGS_SET (context->features,
>                      COGL_FEATURE_ID_GLES2_CONTEXT, TRUE);
>
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list