mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 21:34:09 +00:00
cogl: Use EGL_IMG_context_priority if available
We're the context closest to the display, so we should take priority over other clients. v2: Warn if we asked for a high-priority context and didn't get one. https://gitlab.gnome.org/GNOME/mutter/merge_requests/454
This commit is contained in:
parent
3f29b47809
commit
7df86fb246
@ -147,3 +147,9 @@ 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 ()
|
||||||
|
|
||||||
|
COGL_WINSYS_FEATURE_BEGIN (context_priority,
|
||||||
|
"IMG\0",
|
||||||
|
"context_priority\0",
|
||||||
|
COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
|
||||||
|
COGL_WINSYS_FEATURE_END ()
|
||||||
|
@ -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
|
||||||
|
@ -71,6 +71,12 @@
|
|||||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EGL_IMG_context_priority
|
||||||
|
#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100
|
||||||
|
#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101
|
||||||
|
#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102
|
||||||
|
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_EGL_CONFIG_ATTRIBS 30
|
#define MAX_EGL_CONFIG_ATTRIBS 30
|
||||||
|
|
||||||
@ -347,7 +353,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;
|
||||||
@ -404,6 +410,13 @@ try_create_context (CoglDisplay *display,
|
|||||||
attribs[i++] = 2;
|
attribs[i++] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (egl_renderer->private_features &
|
||||||
|
COGL_EGL_WINSYS_FEATURE_CONTEXT_PRIORITY)
|
||||||
|
{
|
||||||
|
attribs[i++] = EGL_CONTEXT_PRIORITY_LEVEL_IMG;
|
||||||
|
attribs[i++] = EGL_CONTEXT_PRIORITY_HIGH_IMG;
|
||||||
|
}
|
||||||
|
|
||||||
attribs[i++] = EGL_NONE;
|
attribs[i++] = EGL_NONE;
|
||||||
|
|
||||||
egl_display->egl_context = eglCreateContext (edpy,
|
egl_display->egl_context = eglCreateContext (edpy,
|
||||||
@ -417,6 +430,20 @@ 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…
x
Reference in New Issue
Block a user