mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 00:50:42 -05:00
cogl/egl: Use EGL_IMG_context_priority
As long as the context_priority extension is available request a high priority context, to help the compositor look fluid despite heavy GPU usage from other applications at a regular priority. This becomes sort of pointless if/when unredirection applies, should still help with overview/workspace switch animations, or if the application is not fullscreen. Based on a similar patch by Daniel Stone to Weston.
This commit is contained in:
parent
ff507273d2
commit
162d6d45a0
@ -147,3 +147,11 @@ COGL_WINSYS_FEATURE_BEGIN (surfaceless_context,
|
|||||||
"surfaceless_context\0",
|
"surfaceless_context\0",
|
||||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT)
|
COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT)
|
||||||
COGL_WINSYS_FEATURE_END ()
|
COGL_WINSYS_FEATURE_END ()
|
||||||
|
|
||||||
|
#ifdef EGL_IMG_context_priority
|
||||||
|
COGL_WINSYS_FEATURE_BEGIN (context_priority,
|
||||||
|
"IMG\0",
|
||||||
|
"context_priority\0",
|
||||||
|
COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
|
||||||
|
COGL_WINSYS_FEATURE_END ()
|
||||||
|
#endif
|
||||||
|
@ -105,7 +105,8 @@ typedef enum _CoglEGLWinsysFeature
|
|||||||
COGL_EGL_WINSYS_FEATURE_CREATE_CONTEXT =1L<<3,
|
COGL_EGL_WINSYS_FEATURE_CREATE_CONTEXT =1L<<3,
|
||||||
COGL_EGL_WINSYS_FEATURE_BUFFER_AGE =1L<<4,
|
COGL_EGL_WINSYS_FEATURE_BUFFER_AGE =1L<<4,
|
||||||
COGL_EGL_WINSYS_FEATURE_FENCE_SYNC =1L<<5,
|
COGL_EGL_WINSYS_FEATURE_FENCE_SYNC =1L<<5,
|
||||||
COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT =1L<<6
|
COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT =1L<<6,
|
||||||
|
COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY =1L<<7,
|
||||||
} CoglEGLWinsysFeature;
|
} CoglEGLWinsysFeature;
|
||||||
|
|
||||||
typedef struct _CoglRendererEGL
|
typedef struct _CoglRendererEGL
|
||||||
|
@ -345,7 +345,7 @@ try_create_context (CoglDisplay *display,
|
|||||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||||
EGLDisplay edpy;
|
EGLDisplay edpy;
|
||||||
EGLConfig config;
|
EGLConfig config;
|
||||||
EGLint attribs[9];
|
EGLint attribs[11];
|
||||||
EGLint cfg_attribs[MAX_EGL_CONFIG_ATTRIBS];
|
EGLint cfg_attribs[MAX_EGL_CONFIG_ATTRIBS];
|
||||||
GError *config_error = NULL;
|
GError *config_error = NULL;
|
||||||
const char *error_message;
|
const char *error_message;
|
||||||
@ -394,7 +394,15 @@ try_create_context (CoglDisplay *display,
|
|||||||
attribs[5] = EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
attribs[5] = EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
|
||||||
attribs[6] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
attribs[6] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
|
||||||
attribs[7] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
attribs[7] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
|
||||||
attribs[8] = EGL_NONE;
|
|
||||||
|
if (egl_renderer->private_features & COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
|
||||||
|
{
|
||||||
|
attribs[8] = EGL_CONTEXT_PRIORITY_LEVEL_IMG;
|
||||||
|
attribs[9] = EGL_CONTEXT_PRIORITY_HIGH_IMG;
|
||||||
|
attribs[10] = EGL_NONE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
attribs[8] = EGL_NONE;
|
||||||
}
|
}
|
||||||
else if (display->renderer->driver == COGL_DRIVER_GLES2)
|
else if (display->renderer->driver == COGL_DRIVER_GLES2)
|
||||||
{
|
{
|
||||||
@ -416,6 +424,17 @@ try_create_context (CoglDisplay *display,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (egl_renderer->private_features & COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
|
||||||
|
{
|
||||||
|
EGLint value = EGL_CONTEXT_PRIORITY_MEDIUM_IMG;
|
||||||
|
|
||||||
|
eglQueryContext(egl_renderer->edpy, egl_display->egl_context,
|
||||||
|
EGL_CONTEXT_PRIORITY_LEVEL_IMG, &value);
|
||||||
|
|
||||||
|
if (value != EGL_CONTEXT_PRIORITY_HIGH_IMG)
|
||||||
|
g_warning ("Failed to obtain high priority context");
|
||||||
|
}
|
||||||
|
|
||||||
if (egl_renderer->platform_vtable->context_created &&
|
if (egl_renderer->platform_vtable->context_created &&
|
||||||
!egl_renderer->platform_vtable->context_created (display, error))
|
!egl_renderer->platform_vtable->context_created (display, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user