dmabuf: Redo format collection
Arrange for the following tranches to be collected With GL: - Regular EGL formats - Mmap formats (that aren't included already And with GLES: - Regular EGL formats - External EGL formats - Mmap formats (that aren't included already Also, move the debug spew for formats from the downloaders to the display, so we can print them properly sorted, and in their tranches. The only thing we don't have anymore here is the downloader name.
This commit is contained in:
@@ -2004,6 +2004,7 @@ gdk_display_init_dmabuf (GdkDisplay *self)
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
gdk_display_add_dmabuf_downloader (self, gdk_dmabuf_get_egl_downloader (self, builder));
|
||||
gdk_dmabuf_formats_builder_next_priority (builder);
|
||||
#endif
|
||||
|
||||
gdk_dmabuf_formats_builder_add_formats (builder,
|
||||
@@ -2016,6 +2017,29 @@ gdk_display_init_dmabuf (GdkDisplay *self)
|
||||
GDK_DISPLAY_DEBUG (self, DMABUF,
|
||||
"Initialized support for %zu dmabuf formats",
|
||||
gdk_dmabuf_formats_get_n_formats (self->dmabuf_formats));
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
if (GDK_DISPLAY_DEBUG_CHECK (self, DMABUF))
|
||||
{
|
||||
for (gsize i = 0; i < gdk_dmabuf_formats_get_n_formats (self->dmabuf_formats); i++)
|
||||
{
|
||||
guint32 fourcc;
|
||||
guint64 modifier;
|
||||
|
||||
gdk_dmabuf_formats_get_format (self->dmabuf_formats, i, &fourcc, &modifier);
|
||||
|
||||
gdk_debug_message (" %.4s:%#" G_GINT64_MODIFIER "x%s",
|
||||
(char *) &fourcc,
|
||||
modifier,
|
||||
gdk_dmabuf_formats_contains (self->egl_external_formats, fourcc, modifier) ? " (external)" : "");
|
||||
|
||||
if (i + 1 < gdk_dmabuf_formats_get_n_formats (self->dmabuf_formats) &&
|
||||
gdk_dmabuf_formats_next_priority (self->dmabuf_formats, i) == i + 1)
|
||||
gdk_debug_message ("------");
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1965,10 +1965,6 @@ gdk_dmabuf_get_mmap_formats (void)
|
||||
if (!supported_formats[i].download)
|
||||
continue;
|
||||
|
||||
GDK_DEBUG (DMABUF,
|
||||
"mmap dmabuf format %.4s:%#0" G_GINT64_MODIFIER "x",
|
||||
(char *) &supported_formats[i].fourcc, (guint64) DRM_FORMAT_MOD_LINEAR);
|
||||
|
||||
gdk_dmabuf_formats_builder_add_format (builder,
|
||||
supported_formats[i].fourcc,
|
||||
DRM_FORMAT_MOD_LINEAR);
|
||||
|
||||
@@ -93,24 +93,17 @@ gdk_dmabuf_egl_downloader_collect_formats (GdkDisplay *display,
|
||||
|
||||
for (int j = 0; j < num_modifiers; j++)
|
||||
{
|
||||
/* All linear formats we support are already added my the mmap downloader.
|
||||
* We don't add external formats, unless we can use them (via GLES)
|
||||
*/
|
||||
if (modifiers[j] != DRM_FORMAT_MOD_LINEAR &&
|
||||
(!external_only[j] || gdk_gl_context_get_use_es (context)))
|
||||
if (!external_only[j])
|
||||
{
|
||||
GDK_DISPLAY_DEBUG (display, DMABUF,
|
||||
"%s EGL dmabuf format %.4s:%#" G_GINT64_MODIFIER "x",
|
||||
external_only[j] ? "external " : "",
|
||||
(char *) &fourccs[i],
|
||||
modifiers[j]);
|
||||
|
||||
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], modifiers[j]);
|
||||
all_external = FALSE;
|
||||
}
|
||||
if (external_only[j])
|
||||
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]);
|
||||
else
|
||||
all_external = FALSE;
|
||||
{
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Accept implicit modifiers as long as we accept the format at all.
|
||||
@@ -120,9 +113,9 @@ gdk_dmabuf_egl_downloader_collect_formats (GdkDisplay *display,
|
||||
* As an extra wrinkle, treat the implicit modifier as 'external only'
|
||||
* if all formats with the same fourcc are 'external only'.
|
||||
*/
|
||||
if (!all_external || gdk_gl_context_get_use_es (context))
|
||||
if (!all_external)
|
||||
gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], DRM_FORMAT_MOD_INVALID);
|
||||
if (all_external)
|
||||
else if (gdk_gl_context_get_use_es (context))
|
||||
gdk_dmabuf_formats_builder_add_format (external, fourccs[i], DRM_FORMAT_MOD_INVALID);
|
||||
}
|
||||
|
||||
@@ -149,6 +142,7 @@ GdkDmabufDownloader *
|
||||
gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
GdkDmabufFormatsBuilder *builder)
|
||||
{
|
||||
GdkGLContext *context;
|
||||
GdkDmabufFormatsBuilder *formats;
|
||||
GdkDmabufFormatsBuilder *external;
|
||||
gboolean retval = FALSE;
|
||||
@@ -163,6 +157,8 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
return NULL;
|
||||
|
||||
previous = gdk_gl_context_get_current ();
|
||||
context = gdk_display_get_gl_context (display);
|
||||
|
||||
formats = gdk_dmabuf_formats_builder_new ();
|
||||
external = gdk_dmabuf_formats_builder_new ();
|
||||
|
||||
@@ -172,6 +168,11 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
display->egl_external_formats = gdk_dmabuf_formats_builder_free_to_formats (external);
|
||||
|
||||
gdk_dmabuf_formats_builder_add_formats (builder, display->egl_dmabuf_formats);
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
{
|
||||
gdk_dmabuf_formats_builder_next_priority (builder);
|
||||
gdk_dmabuf_formats_builder_add_formats (builder, display->egl_external_formats);
|
||||
}
|
||||
|
||||
if (!retval)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user