From 7fd7dff26f4896bc71b7220c00e0abe1c2f6a21a Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 16 Mar 2018 09:11:06 +0100 Subject: egl: print supported dmabuf formats Useful for debugging dmabuf related problems e.g. when a client requests a certain and we fail to support it. --- render/egl.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'render') diff --git a/render/egl.c b/render/egl.c index 55809983..d60da2ab 100644 --- a/render/egl.c +++ b/render/egl.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -101,6 +102,26 @@ static bool check_egl_ext(const char *egl_exts, const char *ext) { return false; } +static void print_dmabuf_formats(struct wlr_egl *egl) { + /* Avoid log msg if extension is not present */ + if (!egl->egl_exts.dmabuf_import_modifiers) { + return; + } + + int *formats; + int num = wlr_egl_get_dmabuf_formats(egl, &formats); + if (num < 0) { + return; + } + + char str_formats[num * 5 + 1]; + for (int i = 0; i < num; i++) { + snprintf(&str_formats[i*5], (num - i) * 5 + 1, "%.4s ", (char*)&formats[i]); + } + wlr_log(L_INFO, "Supported dmabuf buffer formats: %s", str_formats); + free(formats); +} + bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, EGLint *config_attribs, EGLint visual_id) { if (!load_glapi()) { @@ -172,6 +193,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, egl->egl_exts.dmabuf_import_modifiers = check_egl_ext(egl->egl_exts_str, "EGL_EXT_image_dma_buf_import_modifiers") && eglQueryDmaBufFormatsEXT && eglQueryDmaBufModifiersEXT; + print_dmabuf_formats(egl); return true; -- cgit v1.2.3