[PATCH weston v9 62/62] [XXX] compositor-drm: Support modifiers with GBM
Daniel Stone
daniels at collabora.com
Fri Mar 3 23:06:13 UTC 2017
Use the extended GBM allocator interface to support modifiers and
multi-planar BOs.
XXX: Depends on bwidawsk's 'modifiers' tree.
Signed-off-by: Daniel Stone <daniels at collabora.com>
---
configure.ac | 4 ++++
libweston/compositor-drm.c | 52 +++++++++++++++++++++++++++++++++++++++-------
libweston/meson.build | 7 ++++++-
3 files changed, 54 insertions(+), 9 deletions(-)
v9: New. Same caveat/conditions as the drmModeGetPlane2 patch.
diff --git a/configure.ac b/configure.ac
index 773f5ac..b29db1c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -217,6 +217,10 @@ if test x$enable_drm_compositor = xyes; then
PKG_CHECK_MODULES(DRM_COMPOSITOR_GETPLANE2, [libdrm >= 2.4.74],
[AC_DEFINE([HAVE_DRM_GETPLANE2], 1, [libdrm supports GetPlane2])],
[AC_MSG_WARN([libdrm does not support GetPlane2])])
+ # XXX: Will be 17.1 ... ?
+ PKG_CHECK_MODULES(DRM_COMPOSITOR_GBM_MODIFIERS, [gbm >= 13.1.0],
+ [AC_DEFINE([HAVE_GBM_MODIFIERS], 1, [GBM supports modifiers])],
+ [AC_MSG_WARN([GBM does not support modifiers])])
fi
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 755f4f8..d68d66f 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -1027,6 +1027,9 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
bool is_opaque, enum drm_fb_type type)
{
struct drm_fb *fb = gbm_bo_get_user_data(bo);
+#ifdef HAVE_GBM_MODIFIERS
+ int i;
+#endif
if (fb) {
assert(fb->type == type);
@@ -1043,10 +1046,21 @@ drm_fb_get_from_bo(struct gbm_bo *bo, struct drm_backend *backend,
fb->width = gbm_bo_get_width(bo);
fb->height = gbm_bo_get_height(bo);
+ fb->format = pixel_format_get_info(gbm_bo_get_format(bo));
+ fb->size = 0;
+
+#ifdef HAVE_GBM_MODIFIERS
+ fb->modifier = gbm_bo_get_modifier(bo);
+ for (i = 0; i < gbm_bo_get_plane_count(bo); i++) {
+ fb->strides[i] = gbm_bo_get_stride_for_plane(bo, i);
+ fb->handles[i] = gbm_bo_get_handle_for_plane(bo, i).u32;
+ fb->offsets[i] = gbm_bo_get_offset(bo, i);
+ }
+#else
fb->strides[0] = gbm_bo_get_stride(bo);
fb->handles[0] = gbm_bo_get_handle(bo).u32;
- fb->format = pixel_format_get_info(gbm_bo_get_format(bo));
- fb->size = fb->strides[0] * fb->height;
+#endif
+
fb->fd = backend->drm.fd;
if (!fb->format) {
@@ -4039,13 +4053,35 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b)
fallback_format_for(output->gbm_format),
};
int n_formats = 1;
+ struct weston_mode *mode = output->base.current_mode;
+ struct drm_plane *plane = output->scanout_plane;
+ unsigned int i;
+
+ for (i = 0; i < plane->count_formats; i++) {
+ if (plane->formats[i].format == output->gbm_format)
+ break;
+ }
+
+ if (i == plane->count_formats) {
+ /* XXX: better error message */
+ weston_log("can't use format for output\n");
+ return -1;
+ }
+
+#ifdef HAVE_GBM_MODIFIERS
+ output->gbm_surface =
+ gbm_surface_create_with_modifiers(b->gbm,
+ mode->width,
+ mode->height,
+ output->gbm_format,
+ plane->formats[i].modifiers,
+ plane->formats[i].count_modifiers);
+#else
+ output->gbm_surface =
+ gbm_surface_create(b->gbm, mode->width, mode->height, format[0],
+ GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT);
+#endif
- output->gbm_surface = gbm_surface_create(b->gbm,
- output->base.current_mode->width,
- output->base.current_mode->height,
- format[0],
- GBM_BO_USE_SCANOUT |
- GBM_BO_USE_RENDERING);
if (!output->gbm_surface) {
weston_log("failed to create gbm surface\n");
return -1;
diff --git a/libweston/meson.build b/libweston/meson.build
index f139356..8125fba 100644
--- a/libweston/meson.build
+++ b/libweston/meson.build
@@ -153,7 +153,12 @@ if get_option('backend_drm')
]
if get_option('renderer_gl')
- deps_drm += dependency('gbm')
+ dep_gbm = dependency('gbm')
+ # XXX: Will be 17.1 ... ?
+ if dep_gbm.version().version_compare('>= 13.1')
+ config_h.set('HAVE_GBM_MODIFIERS', '1')
+ endif
+ deps_drm += dep_gbm
endif
if get_option('backend_drm_screencast_vaapi')
--
2.9.3
More information about the wayland-devel
mailing list