[mutter] renderer/native: Use modifier-aware GBM API
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] renderer/native: Use modifier-aware GBM API
- Date: Wed, 24 Jan 2018 03:45:27 +0000 (UTC)
commit c0d9b08ef9bf2be865aad9bf1bc74ba24c655d9f
Author: Daniel Stone <daniels collabora com>
Date: Thu Aug 3 15:06:08 2017 +0100
renderer/native: Use modifier-aware GBM API
Newer versions of GBM support buffer modifiers, including multi-plane
buffers. Use this new API to explicitly pull the information from GBM,
and feed it to drmModeAddFB2WithModifiers.
https://bugzilla.gnome.org/show_bug.cgi?id=785779
configure.ac | 2 +-
src/backends/native/meta-renderer-native.c | 47 +++++++++++++++++++++------
2 files changed, 37 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4234814..7399f74 100644
--- a/configure.ac
+++ b/configure.ac
@@ -266,7 +266,7 @@ AC_SUBST(XWAYLAND_PATH)
PKG_CHECK_MODULES(MUTTER, $MUTTER_PC_MODULES)
-MUTTER_NATIVE_BACKEND_MODULES="libdrm >= 2.4.83 libsystemd libinput >= 1.4 gudev-1.0 gbm >= 10.3"
+MUTTER_NATIVE_BACKEND_MODULES="libdrm >= 2.4.83 libsystemd libinput >= 1.4 gudev-1.0 gbm >= 17.1"
AC_ARG_ENABLE(native-backend,
AS_HELP_STRING([--disable-native-backend], [disable mutter native (KMS) backend]),,
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 968b9d4..2e59161 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1283,24 +1283,49 @@ gbm_get_next_fb_id (MetaGpuKms *gpu_kms,
uint32_t handles[4] = { 0, };
uint32_t strides[4] = { 0, };
uint32_t offsets[4] = { 0, };
+ uint64_t modifiers[4] = { 0, };
+ int i;
/* Now we need to set the CRTC to whatever is the front buffer */
next_bo = gbm_surface_lock_front_buffer (gbm_surface);
- strides[0] = gbm_bo_get_stride (next_bo);
- handles[0] = gbm_bo_get_handle (next_bo).u32;
+ for (i = 0; i < gbm_bo_get_plane_count (next_bo); i++)
+ {
+ strides[i] = gbm_bo_get_stride_for_plane (next_bo, i);
+ handles[i] = gbm_bo_get_handle_for_plane (next_bo, i).u32;
+ offsets[i] = gbm_bo_get_offset (next_bo, i);
+ modifiers[i] = gbm_bo_get_modifier (next_bo);
+ }
kms_fd = meta_gpu_kms_get_fd (gpu_kms);
- if (drmModeAddFB2 (kms_fd,
- gbm_bo_get_width (next_bo),
- gbm_bo_get_height (next_bo),
- gbm_bo_get_format (next_bo),
- handles,
- strides,
- offsets,
- &next_fb_id,
- 0))
+ if (modifiers[0] != DRM_FORMAT_MOD_INVALID)
+ {
+ if (drmModeAddFB2WithModifiers (kms_fd,
+ gbm_bo_get_width (next_bo),
+ gbm_bo_get_height (next_bo),
+ gbm_bo_get_format (next_bo),
+ handles,
+ strides,
+ offsets,
+ modifiers,
+ &next_fb_id,
+ DRM_MODE_FB_MODIFIERS))
+ {
+ g_warning ("Failed to create new back buffer handle: %m");
+ gbm_surface_release_buffer (gbm_surface, next_bo);
+ return FALSE;
+ }
+ }
+ else if (drmModeAddFB2 (kms_fd,
+ gbm_bo_get_width (next_bo),
+ gbm_bo_get_height (next_bo),
+ gbm_bo_get_format (next_bo),
+ handles,
+ strides,
+ offsets,
+ &next_fb_id,
+ 0))
{
if (drmModeAddFB (kms_fd,
gbm_bo_get_width (next_bo),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]