From 551d459af421a2eb937e9e16301bb64da4624f89 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Fri, 7 Mar 2014 18:05:47 +0000 Subject: Add the EGL_MESA_configless_context extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This extension provides a way for an application to render to multiple surfaces with different buffer formats without having to use multiple contexts. An EGLContext can be created without an EGLConfig by passing EGL_NO_CONFIG_MESA. In that case there are no restrictions on the surfaces that can be used with the context apart from that they must be using the same EGLDisplay. _mesa_initialze_context can now take a NULL gl_config which will mark the context as ‘configless’. It will memset the visual to zero in that case. Previously the i965 and i915 drivers were explicitly creating a zeroed visual whenever 0 is passed for the EGLConfig. Mesa needs to be aware that the context is configless because it affects the initial value to use for glDrawBuffer. The first time the context is bound it will set the initial value for configless contexts depending on whether the framebuffer used is double-buffered. Reviewed-by: Kristian Høgsberg --- src/egl/main/eglapi.c | 2 +- src/egl/main/eglcontext.c | 20 ++++++++++++++++---- src/egl/main/egldisplay.h | 1 + src/egl/main/eglmisc.c | 1 + 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/egl/main') diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 42bcb720f41..950c447de9d 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -431,7 +431,7 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list, _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv); - if (!config) + if (!config && !disp->Extensions.MESA_configless_context) RETURN_EGL_ERROR(disp, EGL_BAD_CONFIG, EGL_NO_CONTEXT); if (!share && share_list != EGL_NO_CONTEXT) diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c index 79a92c7c4a6..70277ab9db6 100644 --- a/src/egl/main/eglcontext.c +++ b/src/egl/main/eglcontext.c @@ -523,10 +523,22 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read) return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent"); } - /* simply require the configs to be equal */ - if ((draw && draw->Config != ctx->Config) || - (read && read->Config != ctx->Config)) - return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); + /* If the context has a config then it must match that of the two + * surfaces */ + if (ctx->Config) { + if ((draw && draw->Config != ctx->Config) || + (read && read->Config != ctx->Config)) + return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); + } else { + /* Otherwise we must be using the EGL_MESA_configless_context + * extension */ + assert(dpy->Extensions.MESA_configless_context); + + /* The extension doesn't permit binding draw and read buffers with + * differing contexts */ + if (draw && read && draw->Config != read->Config) + return _eglError(EGL_BAD_MATCH, "eglMakeCurrent"); + } switch (ctx->ClientAPI) { /* OpenGL and OpenGL ES are conflicting */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index 66aaff52ac1..0952bc960cf 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -89,6 +89,7 @@ struct _egl_extensions EGLBoolean MESA_copy_context; EGLBoolean MESA_drm_display; EGLBoolean MESA_drm_image; + EGLBoolean MESA_configless_context; EGLBoolean WL_bind_wayland_display; EGLBoolean WL_create_wayland_buffer_from_image; diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index 341a723be5d..65669d8830f 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -90,6 +90,7 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(MESA_copy_context); _EGL_CHECK_EXTENSION(MESA_drm_display); _EGL_CHECK_EXTENSION(MESA_drm_image); + _EGL_CHECK_EXTENSION(MESA_configless_context); _EGL_CHECK_EXTENSION(WL_bind_wayland_display); _EGL_CHECK_EXTENSION(WL_create_wayland_buffer_from_image); -- cgit v1.2.3