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.
This commit is contained in:
Benjamin Otte 2023-10-19 18:53:27 +02:00
parent 7325121c63
commit 612b5416af
3 changed files with 11 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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))