From 612b5416af9dfea25d0593cee242ea84ed47d244 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 19 Oct 2023 18:53:27 +0200 Subject: [PATCH] dmabuf: Init the dmabuf subsystem before creating texture We did not do that, so when the dmabuf building looked at the list of downloaders, it was empty and the result was an error. That's not good. --- gdk/gdkdisplay.c | 14 +++++++------- gdk/gdkdisplayprivate.h | 2 ++ gdk/gdkdmabuftexture.c | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index a601bd4c37..1bfc2d2a8a 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -1866,12 +1866,12 @@ gdk_display_add_dmabuf_downloader (GdkDisplay *display, * using the relevant EGL extensions, and download it into a memory * texture, possibly doing format conversion with shaders (in GSK). */ -static void -init_dmabuf_formats (GdkDisplay *display) +void +gdk_display_init_dmabuf (GdkDisplay *self) { GdkDmabufFormatsBuilder *builder; - if (display->dmabuf_formats != NULL) + if (self->dmabuf_formats != NULL) return; builder = gdk_dmabuf_formats_builder_new (); @@ -1879,13 +1879,13 @@ init_dmabuf_formats (GdkDisplay *display) #ifdef HAVE_LINUX_DMA_BUF_H if (!GDK_DEBUG_CHECK (DMABUF_DISABLE)) { - gdk_display_prepare_gl (display, NULL); + gdk_display_prepare_gl (self, NULL); - gdk_display_add_dmabuf_downloader (display, gdk_dmabuf_get_direct_downloader (), builder); + gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_direct_downloader (), builder); } #endif - display->dmabuf_formats = gdk_dmabuf_formats_builder_free_to_formats (builder); + self->dmabuf_formats = gdk_dmabuf_formats_builder_free_to_formats (builder); } /** @@ -1904,7 +1904,7 @@ init_dmabuf_formats (GdkDisplay *display) GdkDmabufFormats * gdk_display_get_dmabuf_formats (GdkDisplay *display) { - init_dmabuf_formats (display); + gdk_display_init_dmabuf (display); return display->dmabuf_formats; } diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index d581c58425..e1e871a3fb 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -211,6 +211,8 @@ gulong _gdk_display_get_next_serial (GdkDisplay *display void _gdk_display_pause_events (GdkDisplay *display); void _gdk_display_unpause_events (GdkDisplay *display); +void gdk_display_init_dmabuf (GdkDisplay *self); + GdkVulkanContext * gdk_display_create_vulkan_context (GdkDisplay *self, GError **error); diff --git a/gdk/gdkdmabuftexture.c b/gdk/gdkdmabuftexture.c index 82fae1cc01..74db20c36a 100644 --- a/gdk/gdkdmabuftexture.c +++ b/gdk/gdkdmabuftexture.c @@ -140,6 +140,8 @@ gdk_dmabuf_texture_new_from_builder (GdkDmabufTextureBuilder *builder, display = gdk_dmabuf_texture_builder_get_display (builder); dmabuf = gdk_dmabuf_texture_builder_get_dmabuf (builder); + gdk_display_init_dmabuf (display); + for (i = 0; display->dmabuf_downloaders[i] != NULL; i++) { if (local_error && g_error_matches (local_error, GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT))