dmabuf: Improve consistency of debug messages

Make sure all our dmabuf debug messages are display-scoped so the
inspector doesn't trigger them, use the same formatting throughout,
and improve consistency of wording here and there.
This commit is contained in:
Matthias Clasen 2023-11-12 12:05:35 +01:00
parent 7cf805c8b3
commit b24ae31716
8 changed files with 85 additions and 52 deletions

View File

@ -1885,7 +1885,7 @@ gdk_display_init_dmabuf (GdkDisplay *self)
builder = gdk_dmabuf_formats_builder_new ();
#ifdef HAVE_DMABUF
if (!GDK_DEBUG_CHECK (DMABUF_DISABLE))
if (!GDK_DISPLAY_DEBUG_CHECK (self, DMABUF_DISABLE))
{
gdk_display_prepare_gl (self, NULL);

View File

@ -368,7 +368,8 @@ get_drm_format_info (guint32 fourcc)
}
GdkMemoryFormat
gdk_dmabuf_get_memory_format (guint32 fourcc,
gdk_dmabuf_get_memory_format (GdkDisplay *display,
guint32 fourcc,
gboolean premultiplied)
{
const GdkDrmFormatInfo *info = get_drm_format_info (fourcc);
@ -377,7 +378,8 @@ gdk_dmabuf_get_memory_format (guint32 fourcc,
return premultiplied ? info->premultiplied_memory_format
: info->unpremultiplied_memory_format;
GDK_DEBUG (DMABUF, "Falling back to generic ARGB for dmabuf format %.4s", (char *)&fourcc);
GDK_DISPLAY_DEBUG (display, DMABUF,
"Falling back to generic ARGB for dmabuf format %.4s", (char *)&fourcc);
return premultiplied ? GDK_MEMORY_A8R8G8B8_PREMULTIPLIED
: GDK_MEMORY_A8R8G8B8;
@ -392,7 +394,8 @@ gdk_dmabuf_direct_downloader_add_formats (const GdkDmabufDownloader *downloader,
for (i = 0; i < G_N_ELEMENTS (supported_formats); i++)
{
GDK_DEBUG (DMABUF, "%s dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
GDK_DISPLAY_DEBUG (display, DMABUF,
"%s dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
downloader->name,
(char *) &supported_formats[i].fourcc, (guint64) DRM_FORMAT_MOD_LINEAR);
@ -441,7 +444,8 @@ gdk_dmabuf_direct_downloader_supports (const GdkDmabufDownloader *downloader,
}
static void
gdk_dmabuf_direct_downloader_do_download (GdkTexture *texture,
gdk_dmabuf_direct_downloader_do_download (const GdkDmabufDownloader *downloader,
GdkTexture *texture,
guchar *data,
gsize stride)
{
@ -455,9 +459,9 @@ gdk_dmabuf_direct_downloader_do_download (GdkTexture *texture,
dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture));
info = get_drm_format_info (dmabuf->fourcc);
GDK_DEBUG (DMABUF,
"Using mmap() and memcpy() for downloading a dmabuf (format %.4s::%016llx)",
(char *)&dmabuf->fourcc, (long long unsigned) dmabuf->modifier);
GDK_DISPLAY_DEBUG (gdk_dmabuf_texture_get_display (GDK_DMABUF_TEXTURE (texture)), DMABUF,
"Using %s for downloading a dmabuf (format %.4s:%#" G_GINT64_MODIFIER "x)",
downloader->name, (char *)&dmabuf->fourcc, dmabuf->modifier);
for (i = 0; i < dmabuf->n_planes; i++)
{
@ -526,7 +530,7 @@ gdk_dmabuf_direct_downloader_download (const GdkDmabufDownloader *downloader,
GdkMemoryFormat src_format = gdk_texture_get_format (texture);
if (format == src_format)
gdk_dmabuf_direct_downloader_do_download (texture, data, stride);
gdk_dmabuf_direct_downloader_do_download (downloader, texture, data, stride);
else
{
unsigned int width, height;
@ -539,7 +543,7 @@ gdk_dmabuf_direct_downloader_download (const GdkDmabufDownloader *downloader,
src_stride = width * gdk_memory_format_bytes_per_pixel (src_format);
src_data = g_new (guchar, src_stride * height);
gdk_dmabuf_direct_downloader_do_download (texture, src_data, src_stride);
gdk_dmabuf_direct_downloader_do_download (downloader, texture, src_data, src_stride);
gdk_memory_convert (data, stride, format,
src_data, src_stride, src_format,

View File

@ -104,7 +104,8 @@ gdk_dmabuf_egl_downloader_collect_formats (const GdkDmabufDownloader *downloader
if (modifiers[j] != DRM_FORMAT_MOD_LINEAR &&
(!external_only[j] || gdk_gl_context_get_use_es (context)))
{
GDK_DEBUG (DMABUF, "%s%s dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
GDK_DISPLAY_DEBUG (display, DMABUF,
"%s%s dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
external_only[j] ? "external " : "",
downloader->name,
(char *) &fourccs[i],
@ -173,7 +174,7 @@ gdk_dmabuf_egl_downloader_supports (const GdkDmabufDownloader *downloader,
{
if (gdk_dmabuf_formats_contains (display->egl_dmabuf_formats, dmabuf->fourcc, dmabuf->modifier))
{
*out_format = gdk_dmabuf_get_memory_format (dmabuf->fourcc, premultiplied);
*out_format = gdk_dmabuf_get_memory_format (display, dmabuf->fourcc, premultiplied);
return TRUE;
}
@ -308,14 +309,20 @@ gdk_dmabuf_egl_downloader_download (const GdkDmabufDownloader *downloader,
gsize stride)
{
Download download;
GDK_DEBUG (DMABUF, "Using %s for downloading a dmabuf", downloader->name);
const GdkDmabuf *dmabuf;
download.texture = GDK_DMABUF_TEXTURE (texture);
download.format = format;
download.data = data;
download.stride = stride;
dmabuf = gdk_dmabuf_texture_get_dmabuf (GDK_DMABUF_TEXTURE (texture));
GDK_DISPLAY_DEBUG (gdk_dmabuf_texture_get_display (download.texture), DMABUF,
"Using %s for downloading a dmabuf (format %.4s:%#" G_GINT64_MODIFIER "x)",
downloader->name, (char *)&dmabuf->fourcc, dmabuf->modifier);
gdk_dmabuf_egl_downloader_run (gdk_dmabuf_egl_downloader_do_download, &download);
}

View File

@ -51,7 +51,8 @@ gboolean gdk_dmabuf_sanitize (GdkDmabuf
gboolean gdk_dmabuf_is_disjoint (const GdkDmabuf *dmabuf);
GdkMemoryFormat gdk_dmabuf_get_memory_format (guint32 fourcc,
GdkMemoryFormat gdk_dmabuf_get_memory_format (GdkDisplay *display,
guint32 fourcc,
gboolean premultiplied);
#endif

View File

@ -172,8 +172,8 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder,
return NULL;
}
GDK_DEBUG (DMABUF,
"Dmabuf texture, format %.4s:%#lx, %s%u planes, memory format %u, downloader %s",
GDK_DISPLAY_DEBUG (display, DMABUF,
"Creating dmabuf texture, format %.4s:%#" G_GINT64_MODIFIER "x, %s%u planes, memory format %u, downloader %s",
(char *) &dmabuf.fourcc, dmabuf.modifier,
gdk_dmabuf_texture_builder_get_premultiplied (builder) ? " premultiplied, " : "",
dmabuf.n_planes,

View File

@ -991,9 +991,10 @@ gdk_dmabuf_texture_builder_build (GdkDmabufTextureBuilder *self,
for (i = 0; i < self->dmabuf.n_planes; i++)
g_return_val_if_fail (self->dmabuf.planes[i].fd != -1, NULL);
if (GDK_DEBUG_CHECK (DMABUF_DISABLE))
if (GDK_DISPLAY_DEBUG_CHECK (self->display, DMABUF_DISABLE))
{
g_set_error_literal (error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
g_set_error_literal (error,
GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_NOT_AVAILABLE,
"dmabuf support disabled via GDK_DEBUG environment variable");
return NULL;
}

View File

@ -2003,9 +2003,13 @@ gdk_gl_context_import_dmabuf_for_target (GdkGLContext *self,
g_return_val_if_fail (target == GL_TEXTURE_2D || target == GL_TEXTURE_EXTERNAL_OES, 0);
if (egl_display == EGL_NO_DISPLAY || !display->have_egl_dma_buf_import)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import dmabufs into GL, missing EGL or EGL_EXT_image_dma_buf_import_modifiers");
return 0;
}
GDK_DEBUG (DMABUF,
GDK_DISPLAY_DEBUG (display, DMABUF,
"Importing dmabuf (format: %.4s:%#" G_GINT64_MODIFIER "x, planes: %u) into GL",
(char *) &dmabuf->fourcc, dmabuf->modifier, dmabuf->n_planes);
@ -2056,7 +2060,9 @@ gdk_gl_context_import_dmabuf_for_target (GdkGLContext *self,
if (image == EGL_NO_IMAGE)
{
GDK_DEBUG (DMABUF, "Creating EGLImage for dmabuf failed: %#x", eglGetError ());
GDK_DISPLAY_DEBUG (display, DMABUF,
"Creating EGLImage for dmabuf failed: %#x",
eglGetError ());
return 0;
}
@ -2094,23 +2100,26 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
GL_TEXTURE_2D);
if (texture_id == 0)
{
GDK_DEBUG (DMABUF, "Failed import of %dx%d %.4s::%016llx",
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, (long long unsigned) dmabuf->modifier);
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DEBUG (DMABUF, "Imported %dx%d %.4s::%016llx dmabuf as GL_TEXTURE_2D texture",
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_2D texture",
width, height,
(char *) &dmabuf->fourcc, (long long unsigned) dmabuf->modifier);
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = FALSE;
return texture_id;
}
if (!gdk_gl_context_get_use_es (self))
{
GDK_DEBUG (DMABUF, "Can't import external_only %.4s::%016llx outside of GLES",
(char *) &dmabuf->fourcc, (long long unsigned) dmabuf->modifier);
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't import external_only %.4s:%#" G_GINT64_MODIFIER "x outside of GLES",
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
@ -2120,15 +2129,17 @@ gdk_gl_context_import_dmabuf (GdkGLContext *self,
GL_TEXTURE_EXTERNAL_OES);
if (texture_id == 0)
{
GDK_DEBUG (DMABUF, "Failed import of external_only %dx%d %.4s::%016llx dmabuf",
GDK_DISPLAY_DEBUG (display, DMABUF,
"Import of external_only %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf failed",
width, height,
(char *) &dmabuf->fourcc, (long long unsigned) dmabuf->modifier);
(char *) &dmabuf->fourcc, dmabuf->modifier);
return 0;
}
GDK_DEBUG (DMABUF, "Imported %dx%d %.4s::%016llx dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
GDK_DISPLAY_DEBUG (display, DMABUF,
"Imported %dx%d %.4s:%#" G_GINT64_MODIFIER "x dmabuf as GL_TEXTURE_EXTERNAL_OES texture",
width, height,
(char *) &dmabuf->fourcc, (long long unsigned) dmabuf->modifier);
(char *) &dmabuf->fourcc, dmabuf->modifier);
*external = TRUE;
return texture_id;
}
@ -2159,9 +2170,13 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
g_return_val_if_fail (dmabuf != NULL, FALSE);
if (egl_display == EGL_NO_DISPLAY || !display->have_egl_dma_buf_export)
{
GDK_DISPLAY_DEBUG (display, DMABUF,
"Can't export dmabufs from GL, missing EGL or EGL_EXT_image_dma_buf_export");
return 0;
}
GDK_DEBUG (DMABUF, "Exporting GL texture to dmabuf");
GDK_DISPLAY_DEBUG (display, DMABUF, "Exporting GL texture to dmabuf");
i = 0;
attribs[i++] = EGL_IMAGE_PRESERVED_KHR;
@ -2177,7 +2192,8 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
if (image == EGL_NO_IMAGE)
{
GDK_DEBUG (DMABUF, "Creating EGLImage for dmabuf failed: %#x", eglGetError ());
GDK_DISPLAY_DEBUG (display, DMABUF,
"Creating EGLImage for dmabuf failed: %#x", eglGetError ());
return FALSE;
}
@ -2187,13 +2203,15 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
&n_planes,
&modifier))
{
GDK_DEBUG (DMABUF, "eglExportDMABUFImageQueryMESA failed: %#x", eglGetError ());
GDK_DISPLAY_DEBUG (display, DMABUF,
"eglExportDMABUFImageQueryMESA failed: %#x", eglGetError ());
goto out;
}
if (n_planes < 1 || n_planes > GDK_DMABUF_MAX_PLANES)
{
GDK_DEBUG (DMABUF, "dmabufs with %d planes are not supported", n_planes);
GDK_DISPLAY_DEBUG (display, DMABUF,
"dmabufs with %d planes are not supported", n_planes);
goto out;
}
@ -2227,7 +2245,7 @@ gdk_gl_context_export_dmabuf (GdkGLContext *self,
dmabuf->planes[i].offset = (int) offsets[i];
}
GDK_DEBUG (DMABUF,
GDK_DISPLAY_DEBUG (display, DMABUF,
"Exported GL texture to dmabuf (format: %.4s:%#" G_GINT64_MODIFIER "x, planes: %d)",
(char *)&fourcc, modifier, n_planes);

View File

@ -814,7 +814,9 @@ gsk_gl_driver_import_dmabuf_texture (GskGLDriver *self,
if (width > max_texture_size || height > max_texture_size)
{
GDK_DEBUG (DMABUF, "Can't import dmabuf bigger than MAX_TEXTURE_SIZE (%d)", max_texture_size);
GDK_DISPLAY_DEBUG (gdk_gl_context_get_display (context), DMABUF,
"Can't import dmabuf bigger than MAX_TEXTURE_SIZE (%d)",
max_texture_size);
return 0;
}