From bdb37b30b350c2ead57992eecc4f77b4ebe4b9d3 Mon Sep 17 00:00:00 2001 From: Leandro Ribeiro Date: Tue, 20 Apr 2021 19:56:30 -0300 Subject: [PATCH] gl-renderer: always add DRM_FORMAT_MOD_INVALID to EGL formats EGL implementations have no way to tell that implicit modifiers are not supported. So Weston must consider that implicit modifiers are supported. Always add DRM_FORMAT_MOD_INVALID to formats that we query from EGL. The implication is that clients using dmabuf extension may pick DRM_FORMAT_MOD_INVALID to allocate their buffers, and so these buffers will not be directly imported to KMS and placed in planes. See commit "backend-drm: do not import dmabuf buffers with no modifiers to KMS" for more details. But we should not avoid advertising DRM_FORMAT_MOD_INVALID in the dmabuf protocol just because we hope that the client don't choose it, it's not our choice. Signed-off-by: Leandro Ribeiro --- libweston/renderer-gl/gl-renderer.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/libweston/renderer-gl/gl-renderer.c b/libweston/renderer-gl/gl-renderer.c index 3b8a2932..3769c721 100644 --- a/libweston/renderer-gl/gl-renderer.c +++ b/libweston/renderer-gl/gl-renderer.c @@ -2810,16 +2810,21 @@ populate_supported_formats(struct weston_compositor *ec, goto out; } + /* Always add DRM_FORMAT_MOD_INVALID, as EGL implementations + * support implicit modifiers. */ + ret = weston_drm_format_add_modifier(fmt, DRM_FORMAT_MOD_INVALID); + if (ret < 0) + goto out; + gl_renderer_query_dmabuf_modifiers(ec, formats[i], &modifiers, &num_modifiers); - if (num_modifiers == 0) { - ret = weston_drm_format_add_modifier(fmt, DRM_FORMAT_MOD_INVALID); - if (ret < 0) - goto out; + if (num_modifiers == 0) continue; - } for (j = 0; j < num_modifiers; j++) { + /* Skip MOD_INVALID, as it has already been added. */ + if (modifiers[j] == DRM_FORMAT_MOD_INVALID) + continue; ret = weston_drm_format_add_modifier(fmt, modifiers[j]); if (ret < 0) { free(modifiers);