egl: remove special re-try without stencil code
The EGL winsys had a special case code path when trying to create a context where if it failed it would try again except without requesting a stencil buffer. Historically this code path was to allow Clutter to run on PowerVR MBX hardware which doesn't support a stencil buffer. It doesn't really make sense to keep this workaround in Cogl as it would leave Cogl in a state where the clip stack doesn't work without providing any feedback to the developer. If we need to support running on MBX like hardware - probably not very likely these days - then we should provide developer control over the stencil buffer so the equivalent workaround could be implemented on top of Cogl. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit a7c391a985e82707b17f2fb1105de5d37822a390)
This commit is contained in:
parent
01937201e4
commit
986ba3aa79
@ -108,7 +108,6 @@ typedef struct _CoglDisplayEGL
|
|||||||
|
|
||||||
EGLConfig egl_config;
|
EGLConfig egl_config;
|
||||||
CoglBool found_egl_config;
|
CoglBool found_egl_config;
|
||||||
CoglBool stencil_disabled;
|
|
||||||
|
|
||||||
EGLSurface current_read_surface;
|
EGLSurface current_read_surface;
|
||||||
EGLSurface current_draw_surface;
|
EGLSurface current_draw_surface;
|
||||||
|
@ -199,7 +199,6 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
|
|||||||
static void
|
static void
|
||||||
egl_attributes_from_framebuffer_config (CoglDisplay *display,
|
egl_attributes_from_framebuffer_config (CoglDisplay *display,
|
||||||
CoglFramebufferConfig *config,
|
CoglFramebufferConfig *config,
|
||||||
CoglBool needs_stencil_override,
|
|
||||||
EGLint *attributes)
|
EGLint *attributes)
|
||||||
{
|
{
|
||||||
CoglRenderer *renderer = display->renderer;
|
CoglRenderer *renderer = display->renderer;
|
||||||
@ -212,8 +211,11 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
|
|||||||
config,
|
config,
|
||||||
attributes);
|
attributes);
|
||||||
|
|
||||||
|
if (config->need_stencil)
|
||||||
|
{
|
||||||
attributes[i++] = EGL_STENCIL_SIZE;
|
attributes[i++] = EGL_STENCIL_SIZE;
|
||||||
attributes[i++] = needs_stencil_override ? 2 : 0;
|
attributes[i++] = 2;
|
||||||
|
}
|
||||||
|
|
||||||
attributes[i++] = EGL_RED_SIZE;
|
attributes[i++] = EGL_RED_SIZE;
|
||||||
attributes[i++] = 1;
|
attributes[i++] = 1;
|
||||||
@ -254,78 +256,6 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
|
|||||||
g_assert (i < MAX_EGL_CONFIG_ATTRIBS);
|
g_assert (i < MAX_EGL_CONFIG_ATTRIBS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglBool
|
|
||||||
try_create_context (CoglDisplay *display,
|
|
||||||
CoglBool with_stencil_buffer,
|
|
||||||
CoglError **error)
|
|
||||||
{
|
|
||||||
CoglRenderer *renderer = display->renderer;
|
|
||||||
CoglDisplayEGL *egl_display = display->winsys;
|
|
||||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
|
||||||
EGLDisplay edpy;
|
|
||||||
EGLConfig config;
|
|
||||||
EGLint config_count = 0;
|
|
||||||
EGLBoolean status;
|
|
||||||
EGLint attribs[3];
|
|
||||||
EGLint cfg_attribs[MAX_EGL_CONFIG_ATTRIBS];
|
|
||||||
const char *error_message;
|
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context == NULL, TRUE);
|
|
||||||
|
|
||||||
if (renderer->driver == COGL_DRIVER_GL)
|
|
||||||
eglBindAPI (EGL_OPENGL_API);
|
|
||||||
|
|
||||||
if (display->renderer->driver == COGL_DRIVER_GLES2)
|
|
||||||
{
|
|
||||||
attribs[0] = EGL_CONTEXT_CLIENT_VERSION;
|
|
||||||
attribs[1] = 2;
|
|
||||||
attribs[2] = EGL_NONE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
attribs[0] = EGL_NONE;
|
|
||||||
|
|
||||||
egl_attributes_from_framebuffer_config (display,
|
|
||||||
&display->onscreen_template->config,
|
|
||||||
with_stencil_buffer,
|
|
||||||
cfg_attribs);
|
|
||||||
|
|
||||||
edpy = egl_renderer->edpy;
|
|
||||||
|
|
||||||
status = eglChooseConfig (edpy,
|
|
||||||
cfg_attribs,
|
|
||||||
&config, 1,
|
|
||||||
&config_count);
|
|
||||||
if (status != EGL_TRUE || config_count == 0)
|
|
||||||
{
|
|
||||||
error_message = "Unable to find a usable EGL configuration";
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
egl_display->egl_config = config;
|
|
||||||
|
|
||||||
egl_display->egl_context = eglCreateContext (edpy,
|
|
||||||
config,
|
|
||||||
EGL_NO_CONTEXT,
|
|
||||||
attribs);
|
|
||||||
if (egl_display->egl_context == EGL_NO_CONTEXT)
|
|
||||||
{
|
|
||||||
error_message = "Unable to create a suitable EGL context";
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (egl_renderer->platform_vtable->context_created &&
|
|
||||||
!egl_renderer->platform_vtable->context_created (display, error))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
fail:
|
|
||||||
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
|
||||||
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
|
||||||
"%s", error_message);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
_cogl_winsys_egl_make_current (CoglDisplay *display,
|
_cogl_winsys_egl_make_current (CoglDisplay *display,
|
||||||
EGLSurface draw,
|
EGLSurface draw,
|
||||||
@ -374,28 +304,76 @@ cleanup_context (CoglDisplay *display)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglBool
|
static CoglBool
|
||||||
create_context (CoglDisplay *display, CoglError **error)
|
try_create_context (CoglDisplay *display,
|
||||||
|
CoglError **error)
|
||||||
{
|
{
|
||||||
|
CoglRenderer *renderer = display->renderer;
|
||||||
CoglDisplayEGL *egl_display = display->winsys;
|
CoglDisplayEGL *egl_display = display->winsys;
|
||||||
|
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||||
|
EGLDisplay edpy;
|
||||||
|
EGLConfig config;
|
||||||
|
EGLint config_count = 0;
|
||||||
|
EGLBoolean status;
|
||||||
|
EGLint attribs[3];
|
||||||
|
EGLint cfg_attribs[MAX_EGL_CONFIG_ATTRIBS];
|
||||||
|
const char *error_message;
|
||||||
|
|
||||||
/* Note: we don't just rely on eglChooseConfig to correctly
|
_COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context == NULL, TRUE);
|
||||||
* report that the driver doesn't support a stencil buffer
|
|
||||||
* because we've seen PVR drivers that claim stencil buffer
|
if (renderer->driver == COGL_DRIVER_GL)
|
||||||
* support according to the EGLConfig but then later fail
|
eglBindAPI (EGL_OPENGL_API);
|
||||||
* when trying to create a context with such a config.
|
|
||||||
*/
|
if (display->renderer->driver == COGL_DRIVER_GLES2)
|
||||||
if (try_create_context (display, TRUE, error))
|
|
||||||
{
|
{
|
||||||
egl_display->stencil_disabled = FALSE;
|
attribs[0] = EGL_CONTEXT_CLIENT_VERSION;
|
||||||
return TRUE;
|
attribs[1] = 2;
|
||||||
|
attribs[2] = EGL_NONE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
attribs[0] = EGL_NONE;
|
||||||
|
|
||||||
|
egl_attributes_from_framebuffer_config (display,
|
||||||
|
&display->onscreen_template->config,
|
||||||
|
cfg_attribs);
|
||||||
|
|
||||||
|
edpy = egl_renderer->edpy;
|
||||||
|
|
||||||
|
status = eglChooseConfig (edpy,
|
||||||
|
cfg_attribs,
|
||||||
|
&config, 1,
|
||||||
|
&config_count);
|
||||||
|
if (status != EGL_TRUE || config_count == 0)
|
||||||
{
|
{
|
||||||
_cogl_clear_error (error);
|
error_message = "Unable to find a usable EGL configuration";
|
||||||
cleanup_context (display);
|
goto fail;
|
||||||
egl_display->stencil_disabled = TRUE;
|
|
||||||
return try_create_context (display, FALSE, error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
egl_display->egl_config = config;
|
||||||
|
|
||||||
|
egl_display->egl_context = eglCreateContext (edpy,
|
||||||
|
config,
|
||||||
|
EGL_NO_CONTEXT,
|
||||||
|
attribs);
|
||||||
|
if (egl_display->egl_context == EGL_NO_CONTEXT)
|
||||||
|
{
|
||||||
|
error_message = "Unable to create a suitable EGL context";
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (egl_renderer->platform_vtable->context_created &&
|
||||||
|
!egl_renderer->platform_vtable->context_created (display, error))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
||||||
|
COGL_WINSYS_ERROR_CREATE_CONTEXT,
|
||||||
|
"%s", error_message);
|
||||||
|
|
||||||
|
cleanup_context (display);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -443,7 +421,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
|
|||||||
!egl_renderer->platform_vtable->display_setup (display, error))
|
!egl_renderer->platform_vtable->display_setup (display, error))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!create_context (display, error))
|
if (!try_create_context (display, error))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
egl_display->found_egl_config = TRUE;
|
egl_display->found_egl_config = TRUE;
|
||||||
@ -570,14 +548,11 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
|
|||||||
EGLConfig egl_config;
|
EGLConfig egl_config;
|
||||||
EGLint config_count = 0;
|
EGLint config_count = 0;
|
||||||
EGLBoolean status;
|
EGLBoolean status;
|
||||||
CoglBool need_stencil =
|
|
||||||
egl_display->stencil_disabled ? FALSE : framebuffer->config.need_stencil;
|
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context, FALSE);
|
_COGL_RETURN_VAL_IF_FAIL (egl_display->egl_context, FALSE);
|
||||||
|
|
||||||
egl_attributes_from_framebuffer_config (display,
|
egl_attributes_from_framebuffer_config (display,
|
||||||
&framebuffer->config,
|
&framebuffer->config,
|
||||||
need_stencil,
|
|
||||||
attributes);
|
attributes);
|
||||||
|
|
||||||
status = eglChooseConfig (egl_renderer->edpy,
|
status = eglChooseConfig (egl_renderer->edpy,
|
||||||
|
Loading…
Reference in New Issue
Block a user