gdk: Use the new debug macros

This commit is contained in:
Matthias Clasen 2022-09-22 20:48:58 -04:00
parent 10255eee72
commit 1d48f96fc5
6 changed files with 59 additions and 53 deletions

View File

@ -1729,28 +1729,31 @@ gdk_display_init_egl (GdkDisplay *self,
if (priv->egl_config_high_depth == NULL) if (priv->egl_config_high_depth == NULL)
priv->egl_config_high_depth = priv->egl_config; priv->egl_config_high_depth = priv->egl_config;
GDK_DISPLAY_NOTE (self, OPENGL, { #ifdef G_ENABLE_DEBUG
if (GDK_DISPLAY_DEBUG_CHECK (self, OPENGL))
{
char *ext = describe_extensions (priv->egl_display); char *ext = describe_extensions (priv->egl_display);
char *std_cfg = describe_egl_config (priv->egl_display, priv->egl_config); char *std_cfg = describe_egl_config (priv->egl_display, priv->egl_config);
char *hd_cfg = describe_egl_config (priv->egl_display, priv->egl_config_high_depth); char *hd_cfg = describe_egl_config (priv->egl_display, priv->egl_config_high_depth);
g_message ("EGL API version %d.%d found\n" gdk_debug_message ("EGL API version %d.%d found\n"
" - Vendor: %s\n" " - Vendor: %s\n"
" - Version: %s\n" " - Version: %s\n"
" - Client APIs: %s\n" " - Client APIs: %s\n"
" - Extensions:\n" " - Extensions:\n"
"\t%s\n" "\t%s\n"
" - Selected fbconfig: %s\n" " - Selected fbconfig: %s\n"
" high depth: %s", " high depth: %s",
major, minor, major, minor,
eglQueryString (priv->egl_display, EGL_VENDOR), eglQueryString (priv->egl_display, EGL_VENDOR),
eglQueryString (priv->egl_display, EGL_VERSION), eglQueryString (priv->egl_display, EGL_VERSION),
eglQueryString (priv->egl_display, EGL_CLIENT_APIS), eglQueryString (priv->egl_display, EGL_CLIENT_APIS),
ext, std_cfg, ext, std_cfg,
priv->egl_config_high_depth == priv->egl_config ? "none" : hd_cfg); priv->egl_config_high_depth == priv->egl_config ? "none" : hd_cfg);
g_free (hd_cfg); g_free (hd_cfg);
g_free (std_cfg); g_free (std_cfg);
g_free (ext); g_free (ext);
}); }
#endif
gdk_profiler_end_mark (start_time, "init EGL", NULL); gdk_profiler_end_mark (start_time, "init EGL", NULL);

View File

@ -420,7 +420,7 @@ gdk_display_manager_open_display (GdkDisplayManager *manager,
(any && strstr (allowed_backends, gdk_backends[j].name)) || (any && strstr (allowed_backends, gdk_backends[j].name)) ||
g_str_equal (backend, gdk_backends[j].name)) g_str_equal (backend, gdk_backends[j].name))
{ {
GDK_NOTE (MISC, g_message ("Trying %s backend", gdk_backends[j].name)); GDK_DEBUG (MISC, "Trying %s backend", gdk_backends[j].name);
display = gdk_backends[j].open_display (name); display = gdk_backends[j].open_display (name);
if (display) if (display)
break; break;

View File

@ -402,12 +402,15 @@ gdk_event_alloc (GdkEventType event_type,
GdkEvent *event = (GdkEvent *) g_type_create_instance (gdk_event_types[event_type]); GdkEvent *event = (GdkEvent *) g_type_create_instance (gdk_event_types[event_type]);
GDK_NOTE (EVENTS, { #ifdef G_ENABLE_DEBUG
char *str = g_enum_to_string (GDK_TYPE_EVENT_TYPE, event_type); if (GDK_DEBUG_CHECK (EVENTS))
g_message ("Allocating a new %s for event type %s", {
g_type_name (gdk_event_types[event_type]), str); char *str = g_enum_to_string (GDK_TYPE_EVENT_TYPE, event_type);
g_free (str); gdk_debug_message ("Allocating a new %s for event type %s",
}); g_type_name (gdk_event_types[event_type]), str);
g_free (str);
}
#endif
event->event_type = event_type; event->event_type = event_type;
event->surface = surface != NULL ? g_object_ref (surface) : NULL; event->surface = surface != NULL ? g_object_ref (surface) : NULL;

View File

@ -193,7 +193,7 @@ gdk_gl_context_dispose (GObject *gobject)
if (eglGetCurrentContext () == priv->egl_context) if (eglGetCurrentContext () == priv->egl_context)
eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Destroying EGL context")); GDK_DISPLAY_DEBUG (display, OPENGL, "Destroying EGL context");
eglDestroyContext (egl_display, priv->egl_context); eglDestroyContext (egl_display, priv->egl_context);
priv->egl_context = NULL; priv->egl_context = NULL;
@ -339,13 +339,13 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
context_attribs[i++] = EGL_NONE; context_attribs[i++] = EGL_NONE;
g_assert (i < N_EGL_ATTRS); g_assert (i < N_EGL_ATTRS);
GDK_DISPLAY_NOTE (display, OPENGL, GDK_DISPLAY_DEBUG (display, OPENGL,
g_message ("Creating EGL context version %d.%d (debug:%s, forward:%s, legacy:%s, es:%s)", "Creating EGL context version %d.%d (debug:%s, forward:%s, legacy:%s, es:%s)",
major, minor, major, minor,
debug_bit ? "yes" : "no", debug_bit ? "yes" : "no",
forward_bit ? "yes" : "no", forward_bit ? "yes" : "no",
legacy ? "yes" : "no", legacy ? "yes" : "no",
api == GDK_GL_API_GLES ? "yes" : "no")); api == GDK_GL_API_GLES ? "yes" : "no");
ctx = eglCreateContext (egl_display, ctx = eglCreateContext (egl_display,
egl_config, egl_config,
@ -355,7 +355,7 @@ gdk_gl_context_create_egl_context (GdkGLContext *context,
if (ctx == NULL) if (ctx == NULL)
return 0; return 0;
GDK_DISPLAY_NOTE (display, OPENGL, g_message ("Created EGL context[%p]", ctx)); GDK_DISPLAY_DEBUG (display, OPENGL, "Created EGL context[%p]", ctx);
priv->egl_context = ctx; priv->egl_context = ctx;
gdk_gl_context_set_is_legacy (context, legacy); gdk_gl_context_set_is_legacy (context, legacy);
@ -1533,20 +1533,20 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
priv->has_half_float = gdk_gl_context_check_version (context, 3, 0, 3, 0) || priv->has_half_float = gdk_gl_context_check_version (context, 3, 0, 3, 0) ||
epoxy_has_gl_extension ("OES_vertex_half_float"); epoxy_has_gl_extension ("OES_vertex_half_float");
GDK_DISPLAY_NOTE (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), OPENGL, GDK_DISPLAY_DEBUG (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), OPENGL,
g_message ("%s version: %d.%d (%s)\n" "%s version: %d.%d (%s)\n"
"* GLSL version: %s\n" "* GLSL version: %s\n"
"* Extensions checked:\n" "* Extensions checked:\n"
" - GL_KHR_debug: %s\n" " - GL_KHR_debug: %s\n"
" - GL_EXT_unpack_subimage: %s\n" " - GL_EXT_unpack_subimage: %s\n"
" - OES_vertex_half_float: %s", " - OES_vertex_half_float: %s",
gdk_gl_context_get_use_es (context) ? "OpenGL ES" : "OpenGL", gdk_gl_context_get_use_es (context) ? "OpenGL ES" : "OpenGL",
priv->gl_version / 10, priv->gl_version % 10, priv->gl_version / 10, priv->gl_version % 10,
priv->is_legacy ? "legacy" : "core", priv->is_legacy ? "legacy" : "core",
glGetString (GL_SHADING_LANGUAGE_VERSION), glGetString (GL_SHADING_LANGUAGE_VERSION),
priv->has_khr_debug ? "yes" : "no", priv->has_khr_debug ? "yes" : "no",
priv->has_unpack_subimage ? "yes" : "no", priv->has_unpack_subimage ? "yes" : "no",
priv->has_half_float ? "yes" : "no")); priv->has_half_float ? "yes" : "no");
priv->extensions_checked = TRUE; priv->extensions_checked = TRUE;
} }
@ -1836,8 +1836,8 @@ gdk_gl_backend_use (GdkGLBackend backend_type)
the_gl_backend_type = backend_type; the_gl_backend_type = backend_type;
/* This is important!!!11eleven /* This is important!!!11eleven
* (But really: How do I print a message in 2 categories?) */ * (But really: How do I print a message in 2 categories?) */
GDK_NOTE (OPENGL, g_print ("Using OpenGL backend %s\n", gl_backend_names[the_gl_backend_type])); GDK_DEBUG (OPENGL, "Using OpenGL backend %s", gl_backend_names[the_gl_backend_type]);
GDK_NOTE (MISC, g_message ("Using Opengl backend %s", gl_backend_names[the_gl_backend_type])); GDK_DEBUG (MISC, "Using OpenGL backend %s", gl_backend_names[the_gl_backend_type]);
} }
g_assert (the_gl_backend_type == backend_type); g_assert (the_gl_backend_type == backend_type);

View File

@ -309,8 +309,8 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext *context,
} }
else else
{ {
GDK_DISPLAY_NOTE (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), GDK_DISPLAY_DEBUG (gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)), VULKAN,
VULKAN, g_warning ("Vulkan swapchain doesn't do transparency. Using opaque swapchain instead.")); "Vulkan swapchain doesn't do transparency. Using opaque swapchain instead.");
composite_alpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; composite_alpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
} }
@ -950,7 +950,7 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
if (has_incremental_present) if (has_incremental_present)
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); g_ptr_array_add (device_extensions, (gpointer) VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
GDK_DISPLAY_NOTE (display, VULKAN, g_print ("Using Vulkan device %u, queue %u\n", i, j)); GDK_DISPLAY_DEBUG (display, VULKAN, "Using Vulkan device %u, queue %u", i, j);
if (GDK_VK_CHECK (vkCreateDevice, devices[i], if (GDK_VK_CHECK (vkCreateDevice, devices[i],
&(VkDeviceCreateInfo) { &(VkDeviceCreateInfo) {
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,

View File

@ -62,7 +62,7 @@ gdk_vulkan_handle_result (VkResult res,
{ {
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
{ {
GDK_NOTE (VULKAN, g_printerr ("%s(): %s (%d)\n", called_function, gdk_vulkan_strerror (res), res)); GDK_DEBUG (VULKAN, "%s(): %s (%d)", called_function, gdk_vulkan_strerror (res), res);
} }
return res; return res;
@ -81,7 +81,7 @@ static inline gboolean
gdk_display_ref_vulkan (GdkDisplay *display, gdk_display_ref_vulkan (GdkDisplay *display,
GError **error) GError **error)
{ {
GDK_DISPLAY_NOTE (display, VULKAN, g_message ("Support for Vulkan disabled at compile-time")); GDK_DISPLAY_DEBUG (display, VULKAN, "Support for Vulkan disabled at compile-time");
g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_UNSUPPORTED, g_set_error_literal (error, GDK_VULKAN_ERROR, GDK_VULKAN_ERROR_UNSUPPORTED,
"Vulkan support was not enabled at compile time."); "Vulkan support was not enabled at compile time.");