From b992930ebe0c7e59a09cba831cfd9041b3f9dbb4 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 30 Nov 2023 20:22:41 +0100 Subject: [PATCH] render/allocator/gbm: use gbm_bo_create_with_modifiers2() if available The flags are not really used now but will be exposed soon. --- render/allocator/gbm.c | 14 ++++++++++---- render/allocator/meson.build | 3 +++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/render/allocator/gbm.c b/render/allocator/gbm.c index 25ddbbae4..2ce7b2fd2 100644 --- a/render/allocator/gbm.c +++ b/render/allocator/gbm.c @@ -97,20 +97,26 @@ static struct wlr_gbm_buffer *create_buffer(struct wlr_gbm_allocator *alloc, bool has_modifier = true; uint64_t fallback_modifier = DRM_FORMAT_MOD_INVALID; - struct gbm_bo *bo = gbm_bo_create_with_modifiers(gbm_device, width, height, + uint32_t flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; + struct gbm_bo *bo; +#if HAVE_GBM_BO_CREATE_WITH_MODIFIERS2 + bo = gbm_bo_create_with_modifiers2(gbm_device, width, height, + format->format, format->modifiers, format->len, flags); +#else + bo = gbm_bo_create_with_modifiers(gbm_device, width, height, format->format, format->modifiers, format->len); +#endif if (bo == NULL) { - uint32_t usage = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; if (format->len == 1 && format->modifiers[0] == DRM_FORMAT_MOD_LINEAR) { - usage |= GBM_BO_USE_LINEAR; + flags |= GBM_BO_USE_LINEAR; fallback_modifier = DRM_FORMAT_MOD_LINEAR; } else if (!wlr_drm_format_has(format, DRM_FORMAT_MOD_INVALID)) { // If the format doesn't accept an implicit modifier, bail out. wlr_log(WLR_ERROR, "gbm_bo_create_with_modifiers failed"); return NULL; } - bo = gbm_bo_create(gbm_device, width, height, format->format, usage); + bo = gbm_bo_create(gbm_device, width, height, format->format, flags); has_modifier = false; } if (bo == NULL) { diff --git a/render/allocator/meson.build b/render/allocator/meson.build index 730a2a41b..a23941b97 100644 --- a/render/allocator/meson.build +++ b/render/allocator/meson.build @@ -22,4 +22,7 @@ if gbm.found() has = cc.has_function('gbm_bo_get_fd_for_plane', dependencies: [gbm]) internal_config.set10('HAVE_GBM_BO_GET_FD_FOR_PLANE', has) + + has = cc.has_function('gbm_bo_create_with_modifiers2', dependencies: [gbm]) + internal_config.set10('HAVE_GBM_BO_CREATE_WITH_MODIFIERS2', has) endif