render/egl: improve DMA-BUF format/modifier logging

For each format and modifier, log supported usage. Log a
human-readable format/modifier string.
This commit is contained in:
Simon Ser 2022-09-07 10:47:48 +02:00
parent 1266f7424f
commit 4ad79d05ca
2 changed files with 28 additions and 17 deletions

View File

@ -107,7 +107,7 @@ wayland_server = dependency('wayland-server',
) )
drm = dependency('libdrm', drm = dependency('libdrm',
version: '>=2.4.112', version: '>=2.4.113',
fallback: 'libdrm', fallback: 'libdrm',
default_options: [ default_options: [
'intel=false', 'intel=false',

View File

@ -99,6 +99,13 @@ static int get_egl_dmabuf_formats(struct wlr_egl *egl, int **formats);
static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, int format, static int get_egl_dmabuf_modifiers(struct wlr_egl *egl, int format,
uint64_t **modifiers, EGLBoolean **external_only); uint64_t **modifiers, EGLBoolean **external_only);
static void log_modifier(uint64_t modifier, bool external_only) {
char *mod_name = drmGetFormatModifierName(modifier);
wlr_log(WLR_DEBUG, " %s (0x%016"PRIX64"): ✓ texture %s render",
mod_name ? mod_name : "<unknown>", modifier, external_only ? "" : "");
free(mod_name);
}
static void init_dmabuf_formats(struct wlr_egl *egl) { static void init_dmabuf_formats(struct wlr_egl *egl) {
int *formats; int *formats;
int formats_len = get_egl_dmabuf_formats(egl, &formats); int formats_len = get_egl_dmabuf_formats(egl, &formats);
@ -106,6 +113,8 @@ static void init_dmabuf_formats(struct wlr_egl *egl) {
return; return;
} }
wlr_log(WLR_DEBUG, "Supported DMA-BUF formats:");
bool has_modifiers = false; bool has_modifiers = false;
for (int i = 0; i < formats_len; i++) { for (int i = 0; i < formats_len; i++) {
uint32_t fmt = formats[i]; uint32_t fmt = formats[i];
@ -144,27 +153,29 @@ static void init_dmabuf_formats(struct wlr_egl *egl) {
} }
} }
if (wlr_log_get_verbosity() >= WLR_DEBUG) {
char *fmt_name = drmGetFormatName(fmt);
wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")",
fmt_name ? fmt_name : "<unknown>", fmt);
free(fmt_name);
log_modifier(DRM_FORMAT_MOD_INVALID, false);
if (modifiers_len == 0) {
log_modifier(DRM_FORMAT_MOD_LINEAR, false);
}
for (int j = 0; j < modifiers_len; j++) {
log_modifier(modifiers[j], external_only[j]);
}
}
free(modifiers); free(modifiers);
free(external_only); free(external_only);
} }
free(formats);
char *str_formats = malloc(formats_len * 5 + 1);
if (str_formats == NULL) {
goto out;
}
for (int i = 0; i < formats_len; i++) {
snprintf(&str_formats[i*5], (formats_len - i) * 5 + 1, "%.4s ",
(char*)&formats[i]);
}
wlr_log(WLR_DEBUG, "Supported DMA-BUF formats: %s", str_formats);
wlr_log(WLR_DEBUG, "EGL DMA-BUF format modifiers %s",
has_modifiers ? "supported" : "unsupported");
free(str_formats);
egl->has_modifiers = has_modifiers; egl->has_modifiers = has_modifiers;
wlr_log(WLR_DEBUG, "EGL DMA-BUF format modifiers %s",
out: has_modifiers ? "supported" : "unsupported");
free(formats);
} }
static struct wlr_egl *egl_create(void) { static struct wlr_egl *egl_create(void) {