[mutter/wip/chergert/KHR_swap_buffers_with_damage: 68/68] winsys: Check for KHR_swap_buffers_with_damage
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/chergert/KHR_swap_buffers_with_damage: 68/68] winsys: Check for KHR_swap_buffers_with_damage
- Date: Tue, 8 Mar 2022 14:12:24 +0000 (UTC)
commit 75bb27e4d192a86b9200002d9d5c5db0a381339a
Author: Christian Hergert <chergert redhat com>
Date: Thu Mar 3 00:30:56 2022 -0800
winsys: Check for KHR_swap_buffers_with_damage
Previously, we would only check for EXT_swap_buffers_with_damage which
generally will find an implementation. However, some EGL implementations
do not appear to support that naming of the extension, preferring to
only advertise KHR_swap_buffers_with_damage.
cogl/cogl/winsys/cogl-onscreen-egl.c | 24 +++++++++++++++++-----
.../winsys/cogl-winsys-egl-feature-functions.h | 15 ++++++++++++--
2 files changed, 32 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl/winsys/cogl-onscreen-egl.c b/cogl/cogl/winsys/cogl-onscreen-egl.c
index f078968668..54f37e2646 100644
--- a/cogl/cogl/winsys/cogl-onscreen-egl.c
+++ b/cogl/cogl/winsys/cogl-onscreen-egl.c
@@ -36,6 +36,9 @@
typedef struct _CoglOnscreenEglPrivate
{
EGLSurface egl_surface;
+
+ /* Can use PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC (or the EXT variant) */
+ EGLBoolean (*pf_eglSwapBuffersWithDamage) (EGLDisplay, EGLSurface, const EGLint *, EGLint);
} CoglOnscreenEglPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (CoglOnscreenEgl, cogl_onscreen_egl,
@@ -143,6 +146,17 @@ bind_onscreen_with_context (CoglOnscreen *onscreen,
CoglRenderer *renderer = context->display->renderer;
CoglRendererEGL *egl_renderer = renderer->winsys;
+ if (egl_renderer->pf_eglSwapBuffersWithDamageKHR)
+ {
+ priv->pf_eglSwapBuffersWithDamage =
+ egl_renderer->pf_eglSwapBuffersWithDamageKHR;
+ }
+ else
+ {
+ priv->pf_eglSwapBuffersWithDamage =
+ egl_renderer->pf_eglSwapBuffersWithDamageEXT;
+ }
+
eglSwapInterval (egl_renderer->edpy, 1);
}
}
@@ -310,7 +324,7 @@ cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
cogl_framebuffer_create_timestamp_query (COGL_FRAMEBUFFER (onscreen));
}
- if (n_rectangles && egl_renderer->pf_eglSwapBuffersWithDamage)
+ if (n_rectangles && priv->pf_eglSwapBuffersWithDamage)
{
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
size_t size = n_rectangles * sizeof (int) * 4;
@@ -327,10 +341,10 @@ cogl_onscreen_egl_swap_buffers_with_damage (CoglOnscreen *onscreen,
cogl_framebuffer_get_height (framebuffer) - rect[1] - rect[3];
}
- if (egl_renderer->pf_eglSwapBuffersWithDamage (egl_renderer->edpy,
- priv->egl_surface,
- flipped,
- n_rectangles) == EGL_FALSE)
+ if (priv->pf_eglSwapBuffersWithDamage (egl_renderer->edpy,
+ priv->egl_surface,
+ flipped,
+ n_rectangles) == EGL_FALSE)
g_warning ("Error reported by eglSwapBuffersWithDamage");
}
else
diff --git a/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
b/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
index 53d9bd27b1..494d5ea39f 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
+++ b/cogl/cogl/winsys/cogl-winsys-egl-feature-functions.h
@@ -105,11 +105,22 @@ COGL_WINSYS_FEATURE_BEGIN (buffer_age,
COGL_EGL_WINSYS_FEATURE_BUFFER_AGE)
COGL_WINSYS_FEATURE_END ()
-COGL_WINSYS_FEATURE_BEGIN (swap_buffers_with_damage,
+COGL_WINSYS_FEATURE_BEGIN (KHR_swap_buffers_with_damage,
+ "KHR\0",
+ "swap_buffers_with_damage\0",
+ 0)
+COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglSwapBuffersWithDamageKHR,
+ (EGLDisplay dpy,
+ EGLSurface surface,
+ const EGLint *rects,
+ EGLint n_rects))
+COGL_WINSYS_FEATURE_END ()
+
+COGL_WINSYS_FEATURE_BEGIN (EXT_swap_buffers_with_damage,
"EXT\0",
"swap_buffers_with_damage\0",
0)
-COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglSwapBuffersWithDamage,
+COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglSwapBuffersWithDamageEXT,
(EGLDisplay dpy,
EGLSurface surface,
const EGLint *rects,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]