diff --git a/gdk/gdkdmabuf.c b/gdk/gdkdmabuf.c index 968970bd16..78d222e112 100644 --- a/gdk/gdkdmabuf.c +++ b/gdk/gdkdmabuf.c @@ -559,11 +559,10 @@ gdk_dmabuf_get_direct_downloader (void) * * 1. Disallow any dmabuf format that we do not know. * - * 1. Reject the INVALID modifier, accept the LINEAR one. + * 2. Ignore non-linear modifiers. * - * 2. Ignore all other modifiers. - * - * 3. Try and fix various inconsistencies between V4L and Mesa, like NV12. + * 3. Try and fix various inconsistencies between V4L and Mesa + * for linear modifiers, like the e.g. single-plane NV12. * * *** WARNING *** * @@ -592,14 +591,6 @@ gdk_dmabuf_sanitize (GdkDmabuf *dest, return FALSE; } - if (src->modifier == DRM_FORMAT_MOD_INVALID) - { - g_set_error (error, - GDK_DMABUF_ERROR, GDK_DMABUF_ERROR_UNSUPPORTED_FORMAT, - "GTK does not support the INVALID modifier."); - return FALSE; - } - info = get_drm_format_info (src->fourcc); if (info == NULL) diff --git a/gdk/gdkdmabufegl.c b/gdk/gdkdmabufegl.c index 392889ad6c..79a74531c8 100644 --- a/gdk/gdkdmabufegl.c +++ b/gdk/gdkdmabufegl.c @@ -113,6 +113,12 @@ gdk_dmabuf_egl_downloader_collect_formats (const GdkDmabufDownloader *downloader if (external_only[j]) gdk_dmabuf_formats_builder_add_format (external, fourccs[i], modifiers[j]); } + + /* Accept implicit modifiers as long as we accept the format at all. + * This is a bit of a crapshot, but unfortunately needed for a bunch + * of drivers. + */ + gdk_dmabuf_formats_builder_add_format (formats, fourccs[i], DRM_FORMAT_MOD_INVALID); } g_free (modifiers); diff --git a/gdk/gdkdmabufformats.c b/gdk/gdkdmabufformats.c index abde2c495e..744f141e80 100644 --- a/gdk/gdkdmabufformats.c +++ b/gdk/gdkdmabufformats.c @@ -37,6 +37,10 @@ * The list of supported formats is sorted by preference, * with the best formats coming first. * + * The list may contains (format, modfier) pairs where the modifier + * is `DMA_FORMAT_MOD_INVALID`, indicating that **_implicit modifiers_** + * may be used with this format. + * * See [class@Gdk.DmabufTextureBuilder] for more information * about DMA buffers. * diff --git a/gdk/gdkdmabufformatsbuilder.c b/gdk/gdkdmabufformatsbuilder.c index 7987c05701..6d29bf71e2 100644 --- a/gdk/gdkdmabufformatsbuilder.c +++ b/gdk/gdkdmabufformatsbuilder.c @@ -22,9 +22,6 @@ #include "gdkdmabufformatsprivate.h" -#ifdef HAVE_DMABUF -#include -#endif #define GDK_ARRAY_NAME gdk_dmabuf_formats_builder #define GDK_ARRAY_TYPE_NAME GdkDmabufFormatsBuilder @@ -121,12 +118,6 @@ gdk_dmabuf_formats_builder_add_format (GdkDmabufFormatsBuilder *self, guint32 fourcc, guint64 modifier) { -#ifdef HAVE_DMABUF - g_return_if_fail (modifier != DRM_FORMAT_MOD_INVALID); -#else - g_return_if_reached (); -#endif - gdk_dmabuf_formats_builder_append (self, &(GdkDmabufFormat) { fourcc, modifier }); } diff --git a/gdk/gdkdmabuftexturebuilder.c b/gdk/gdkdmabuftexturebuilder.c index a27699d5e4..305612df7e 100644 --- a/gdk/gdkdmabuftexturebuilder.c +++ b/gdk/gdkdmabuftexturebuilder.c @@ -29,8 +29,6 @@ #include #ifdef HAVE_DMABUF #include -#else -#define DRM_FORMAT_MOD_INVALID ((1ULL << 56) - 1) #endif @@ -90,6 +88,10 @@ struct _GdkDmabufTextureBuilderClass * characters. Additionally, each DMA buffer has a **_modifier_**, which is a 64-bit integer * that describes driver-specific details of the memory layout, such as tiling or compression. * + * For historical reasons, some producers of dma-bufs don't provide an explicit modifier, but + * instead return `DMA_FORMAT_MOD_INVALID` to indicate that their modifier is **_impliict_**. + * GTK tries to accomodate this situation by accepting `DMA_FORMAT_MOD_INVALID` as modifier. + * * The operation of `GdkDmabufTextureBuilder` is quite simple: Create a texture builder, * set all the necessary properties, and then call [method@Gdk.DmabufTextureBuilder.build] * to create the new texture. @@ -611,13 +613,6 @@ gdk_dmabuf_texture_builder_set_modifier (GdkDmabufTextureBuilder *self, guint64 modifier) { g_return_if_fail (GDK_IS_DMABUF_TEXTURE_BUILDER (self)); - if (modifier == DRM_FORMAT_MOD_INVALID) - { - g_critical ("GTK does not support the INVALID modifier. " - "If you use code that produces it, it should include " - "instructions how to transform it into a regular modifier."); - return; - } if (self->dmabuf.modifier == modifier) return;