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 <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2021-04-20 19:56:30 -03:00 committed by Daniel Stone
parent 1b403263d4
commit bdb37b30b3

View File

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