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. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2316>
This commit is contained in:
parent
3c9622bea9
commit
858f89084e
2 changed files with 32 additions and 7 deletions
|
@ -36,6 +36,9 @@
|
||||||
typedef struct _CoglOnscreenEglPrivate
|
typedef struct _CoglOnscreenEglPrivate
|
||||||
{
|
{
|
||||||
EGLSurface egl_surface;
|
EGLSurface egl_surface;
|
||||||
|
|
||||||
|
/* Can use PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC (or the EXT variant) */
|
||||||
|
EGLBoolean (*pf_eglSwapBuffersWithDamage) (EGLDisplay, EGLSurface, const EGLint *, EGLint);
|
||||||
} CoglOnscreenEglPrivate;
|
} CoglOnscreenEglPrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (CoglOnscreenEgl, cogl_onscreen_egl,
|
G_DEFINE_TYPE_WITH_PRIVATE (CoglOnscreenEgl, cogl_onscreen_egl,
|
||||||
|
@ -143,6 +146,17 @@ bind_onscreen_with_context (CoglOnscreen *onscreen,
|
||||||
CoglRenderer *renderer = context->display->renderer;
|
CoglRenderer *renderer = context->display->renderer;
|
||||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
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);
|
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));
|
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);
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||||
size_t size = n_rectangles * sizeof (int) * 4;
|
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];
|
cogl_framebuffer_get_height (framebuffer) - rect[1] - rect[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (egl_renderer->pf_eglSwapBuffersWithDamage (egl_renderer->edpy,
|
if (priv->pf_eglSwapBuffersWithDamage (egl_renderer->edpy,
|
||||||
priv->egl_surface,
|
priv->egl_surface,
|
||||||
flipped,
|
flipped,
|
||||||
n_rectangles) == EGL_FALSE)
|
n_rectangles) == EGL_FALSE)
|
||||||
g_warning ("Error reported by eglSwapBuffersWithDamage");
|
g_warning ("Error reported by eglSwapBuffersWithDamage");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -105,11 +105,22 @@ COGL_WINSYS_FEATURE_BEGIN (buffer_age,
|
||||||
COGL_EGL_WINSYS_FEATURE_BUFFER_AGE)
|
COGL_EGL_WINSYS_FEATURE_BUFFER_AGE)
|
||||||
COGL_WINSYS_FEATURE_END ()
|
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",
|
"EXT\0",
|
||||||
"swap_buffers_with_damage\0",
|
"swap_buffers_with_damage\0",
|
||||||
0)
|
0)
|
||||||
COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglSwapBuffersWithDamage,
|
COGL_WINSYS_FEATURE_FUNCTION (EGLBoolean, eglSwapBuffersWithDamageEXT,
|
||||||
(EGLDisplay dpy,
|
(EGLDisplay dpy,
|
||||||
EGLSurface surface,
|
EGLSurface surface,
|
||||||
const EGLint *rects,
|
const EGLint *rects,
|
||||||
|
|
Loading…
Reference in a new issue