[gtk/wip.win32.fixes] gdkglcontext-win32-egl.c: Add a better debug message
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip.win32.fixes] gdkglcontext-win32-egl.c: Add a better debug message
- Date: Thu, 7 Oct 2021 09:04:37 +0000 (UTC)
commit dc5e26cc3acbc0a17f84fcb73082dcd8da9516d3
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Thu Oct 7 15:44:38 2021 +0800
gdkglcontext-win32-egl.c: Add a better debug message
In line with what is done in X11 and Wayland, improve the debug message
that is output when EGL is being used.
gdk/win32/gdkglcontext-win32-egl.c | 87 ++++++++++++++++++++++++++++++++++----
1 file changed, 78 insertions(+), 9 deletions(-)
---
diff --git a/gdk/win32/gdkglcontext-win32-egl.c b/gdk/win32/gdkglcontext-win32-egl.c
index 1507dd8225..2f62e8c45a 100644
--- a/gdk/win32/gdkglcontext-win32-egl.c
+++ b/gdk/win32/gdkglcontext-win32-egl.c
@@ -247,6 +247,65 @@ find_eglconfig_for_window (GdkWin32Display *display,
return TRUE;
}
+#ifdef G_ENABLE_DEBUG
+
+static int
+strvcmp (gconstpointer p1,
+ gconstpointer p2)
+{
+ const char * const *s1 = p1;
+ const char * const *s2 = p2;
+
+ return strcmp (*s1, *s2);
+}
+
+static char *
+describe_extensions (EGLDisplay dpy)
+{
+ const char *extensions;
+ char **exts;
+ char *ext;
+
+ extensions = eglQueryString (dpy, EGL_EXTENSIONS);
+
+ exts = g_strsplit (extensions, " ", -1);
+ qsort (exts, g_strv_length (exts), sizeof (char *), strvcmp);
+
+ ext = g_strjoinv ("\n\t", exts);
+ if (ext[0] == '\n')
+ ext[0] = ' ';
+ g_strfreev (exts);
+
+ return g_strstrip (ext);
+}
+
+static char *
+describe_egl_config (EGLDisplay dpy,
+ EGLConfig config)
+{
+ EGLint red, green, blue, alpha, type;
+
+ if (!config)
+ return g_strdup ("-");
+
+ if (!eglGetConfigAttrib (dpy, config, EGL_RED_SIZE, &red) ||
+ !eglGetConfigAttrib (dpy, config, EGL_GREEN_SIZE, &green) ||
+ !eglGetConfigAttrib (dpy, config, EGL_BLUE_SIZE, &blue) ||
+ !eglGetConfigAttrib (dpy, config, EGL_ALPHA_SIZE, &alpha))
+ return g_strdup ("Unknown");
+
+ if (epoxy_has_egl_extension (dpy, "EGL_EXT_pixel_format_float"))
+ {
+ if (!eglGetConfigAttrib (dpy, config, EGL_COLOR_COMPONENT_TYPE_EXT, &type))
+ type = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
+ }
+ else
+ type = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
+
+ return g_strdup_printf ("R%dG%dB%dA%d%s", red, green, blue, alpha, type ==
EGL_COLOR_COMPONENT_TYPE_FIXED_EXT ? "" : " float");
+}
+#endif
+
gboolean
gdk_win32_display_init_egl (GdkDisplay *display,
GError **error)
@@ -284,15 +343,25 @@ gdk_win32_display_init_egl (GdkDisplay *display,
display_win32->hasEglSurfacelessContext =
epoxy_has_egl_extension (egl_disp, "EGL_KHR_surfaceless_context");
- GDK_NOTE (OPENGL,
- g_print ("EGL API version %d.%d found\n"
- " - Vendor: %s\n"
- " - Checked extensions:\n"
- "\t* EGL_KHR_surfaceless_context: %s\n",
- display_win32->egl_version / 10,
- display_win32->egl_version % 10,
- eglQueryString (display_win32->egl_disp, EGL_VENDOR),
- display_win32->hasEglSurfacelessContext ? "yes" : "no"));
+
+ GDK_DISPLAY_NOTE (display, OPENGL, {
+ char *ext = describe_extensions (display_win32->egl_disp);
+ char *cfg = describe_egl_config (display_win32->egl_disp,
+ display_win32->egl_config);
+ g_message ("EGL found\n"
+ " - Version: %s\n"
+ " - Vendor: %s\n"
+ " - Client API: %s\n"
+ " - Extensions:\n"
+ "\t%s\n"
+ " - Config: %s",
+ eglQueryString (display_win32->egl_disp, EGL_VERSION),
+ eglQueryString (display_win32->egl_disp, EGL_VENDOR),
+ eglQueryString (display_win32->egl_disp, EGL_CLIENT_APIS),
+ ext, cfg);
+ g_free (ext);
+ g_free (cfg);
+ });
return find_eglconfig_for_window (display_win32, &display_win32->egl_config,
&display_win32->egl_min_swap_interval, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]