From 95efe82982a69b7526401c5b1c8b99c8df36663a Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 5 Sep 2019 12:38:28 -0400 Subject: [PATCH] simple-dmabuf-egl: Allow QueryDmaBufModifiers to report no modifiers Some drivers expose the extension so they can expose eglQueryDmaBufFormatsEXT, but don't support any modifiers. Treat this the same as if the extension wasn't present. --- clients/simple-dmabuf-egl.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/clients/simple-dmabuf-egl.c b/clients/simple-dmabuf-egl.c index 35a2d043..8bc2e421 100644 --- a/clients/simple-dmabuf-egl.c +++ b/clients/simple-dmabuf-egl.c @@ -1232,26 +1232,32 @@ display_update_supported_modifiers_for_egl(struct display *d) int num_egl_modifiers = 0; EGLBoolean ret; int i; + bool try_modifiers = d->egl.has_dma_buf_import_modifiers; + + if (try_modifiers) { + ret = d->egl.query_dma_buf_modifiers(d->egl.display, + BUFFER_FORMAT, + 0, /* max_modifiers */ + NULL, /* modifiers */ + NULL, /* external_only */ + &num_egl_modifiers); + if (ret == EGL_FALSE) { + fprintf(stderr, "Failed to query num EGL modifiers for format\n"); + goto error; + } + } + + if (!num_egl_modifiers) + try_modifiers = false; /* If EGL doesn't support modifiers, don't use them at all. */ - if (!d->egl.has_dma_buf_import_modifiers) { + if (!try_modifiers) { d->modifiers_count = 0; free(d->modifiers); d->modifiers = NULL; return true; } - ret = d->egl.query_dma_buf_modifiers(d->egl.display, - BUFFER_FORMAT, - 0, /* max_modifiers */ - NULL, /* modifiers */ - NULL, /* external_only */ - &num_egl_modifiers); - if (ret == EGL_FALSE || num_egl_modifiers == 0) { - fprintf(stderr, "Failed to query num EGL modifiers for format\n"); - goto error; - } - egl_modifiers = zalloc(num_egl_modifiers * sizeof(*egl_modifiers)); ret = d->egl.query_dma_buf_modifiers(d->egl.display,