summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2022-03-02 22:59:23 -0800
committerChristian Hergert <chergert@redhat.com>2022-03-03 01:22:01 -0800
commit5316eb0c355f76a997f7ffc218bb26b9ae24e186 (patch)
tree78d0a156e7fe14018cba8b88d2013dba89747084
parenteaf03532056899f06c33237dfebde18fd1aecc12 (diff)
downloadgtk+-5316eb0c355f76a997f7ffc218bb26b9ae24e186.tar.gz
gdk: use EGL_KHR_swap_buffers_with_damage
It appears that NVIDIA does not implement EGL_EXT_swap_buffers_with_damage on their EGL implementation, but does implement the KHR variant of it. This checks for a suitable implementation and stores a pointer to the compatible implementation within the GdkGLContextPrivate struct.
-rw-r--r--gdk/gdkdisplay.c2
-rw-r--r--gdk/gdkdisplayprivate.h1
-rw-r--r--gdk/gdkglcontext.c10
3 files changed, 8 insertions, 5 deletions
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 0e935d8176..31f039d749 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -1721,8 +1721,6 @@ gdk_display_init_egl (GdkDisplay *self,
self->have_egl_buffer_age =
epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_buffer_age");
- self->have_egl_swap_buffers_with_damage =
- epoxy_has_egl_extension (priv->egl_display, "EGL_EXT_swap_buffers_with_damage");
self->have_egl_no_config_context =
epoxy_has_egl_extension (priv->egl_display, "EGL_KHR_no_config_context");
self->have_egl_pixel_format_float =
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 4eb3625d88..62061cc564 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -107,7 +107,6 @@ struct _GdkDisplay
/* egl info */
guint have_egl_buffer_age : 1;
- guint have_egl_swap_buffers_with_damage : 1;
guint have_egl_no_config_context : 1;
guint have_egl_pixel_format_float : 1;
guint have_egl_win32_libangle : 1;
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index be514c0ac6..1678f3d85c 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -117,6 +117,7 @@ typedef struct {
#ifdef HAVE_EGL
EGLContext egl_context;
+ EGLBoolean (*eglSwapBuffersWithDamage) (EGLDisplay, EGLSurface, const EGLint *, EGLint);
#endif
} GdkGLContextPrivate;
@@ -420,6 +421,11 @@ gdk_gl_context_real_realize (GdkGLContext *context,
gdk_gl_context_set_is_legacy (context, legacy_bit);
+ if (epoxy_has_egl_extension (egl_display, "EGL_KHR_swap_buffers_with_damage"))
+ priv->eglSwapBuffersWithDamage = (gpointer)epoxy_eglGetProcAddress ("eglSwapBuffersWithDamageKHR");
+ else if (epoxy_has_egl_extension (egl_display, "EGL_EXT_swap_buffers_with_damage"))
+ priv->eglSwapBuffersWithDamage = (gpointer)epoxy_eglGetProcAddress ("eglSwapBuffersWithDamageEXT");
+
gdk_profiler_end_mark (start_time, "realize GdkWaylandGLContext", NULL);
return api;
@@ -608,7 +614,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
gdk_profiler_add_mark (GDK_PROFILER_CURRENT_TIME, 0, "EGL", "swap buffers");
- if (display->have_egl_swap_buffers_with_damage)
+ if (priv->eglSwapBuffersWithDamage)
{
EGLint stack_rects[4 * 4]; /* 4 rects */
EGLint *heap_rects = NULL;
@@ -632,7 +638,7 @@ gdk_gl_context_real_end_frame (GdkDrawContext *draw_context,
rects[j++] = rect.width * scale;
rects[j++] = rect.height * scale;
}
- eglSwapBuffersWithDamageEXT (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
+ priv->eglSwapBuffersWithDamage (gdk_display_get_egl_display (display), egl_surface, rects, n_rects);
g_free (heap_rects);
}
else