[mutter] cogl: Use EGL_IMG_context_priority if available
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cogl: Use EGL_IMG_context_priority if available
- Date: Thu, 18 Apr 2019 20:33:19 +0000 (UTC)
commit 7df86fb24646f8a19a47e54b86424048ec08e715
Author: Adam Jackson <ajax redhat com>
Date: Wed Feb 20 17:14:14 2019 -0500
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
.../winsys/cogl-winsys-egl-feature-functions.h | 6 +++++
cogl/cogl/winsys/cogl-winsys-egl-private.h | 3 ++-
cogl/cogl/winsys/cogl-winsys-egl.c | 29 +++++++++++++++++++++-
3 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
b/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
index 17a99f269..bbe4912bc 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
+++ b/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
@@ -147,3 +147,9 @@ COGL_WINSYS_FEATURE_BEGIN (surfaceless_context,
"surfaceless_context\0",
COGL_EGL_WINSYS_FEATURE_SURFACELESS_CONTEXT)
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 ()
diff --git a/cogl/cogl/winsys/cogl-winsys-egl-private.h b/cogl/cogl/winsys/cogl-winsys-egl-private.h
index b98bffcf8..89fe585b9 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl-private.h
+++ b/cogl/cogl/winsys/cogl-winsys-egl-private.h
@@ -105,7 +105,8 @@ typedef enum _CoglEGLWinsysFeature
COGL_EGL_WINSYS_FEATURE_CREATE_CONTEXT =1L<<3,
COGL_EGL_WINSYS_FEATURE_BUFFER_AGE =1L<<4,
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;
typedef struct _CoglRendererEGL
diff --git a/cogl/cogl/winsys/cogl-winsys-egl.c b/cogl/cogl/winsys/cogl-winsys-egl.c
index e3eb311da..7b5e70bf7 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/cogl/winsys/cogl-winsys-egl.c
@@ -71,6 +71,12 @@
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
#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
@@ -347,7 +353,7 @@ try_create_context (CoglDisplay *display,
CoglRendererEGL *egl_renderer = renderer->winsys;
EGLDisplay edpy;
EGLConfig config;
- EGLint attribs[9];
+ EGLint attribs[11];
EGLint cfg_attribs[MAX_EGL_CONFIG_ATTRIBS];
GError *config_error = NULL;
const char *error_message;
@@ -404,6 +410,13 @@ try_create_context (CoglDisplay *display,
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;
egl_display->egl_context = eglCreateContext (edpy,
@@ -417,6 +430,20 @@ try_create_context (CoglDisplay *display,
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 &&
!egl_renderer->platform_vtable->context_created (display, error))
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]