From b9fe9c736a3b7ef298bda5f785938275805a47f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 12 Sep 2019 21:41:17 +0200 Subject: [PATCH] onscreen/native: Add API to check whether buffer is scanout compatible While this is fairly incomplete, as to check things fully we need to use TEST_ONLY in atomic to try out a complete assignment on the device, but this works well enough for legacy non-modifier cases. https://gitlab.gnome.org/GNOME/mutter/merge_requests/798 --- src/backends/native/meta-renderer-native.c | 42 ++++++++++++++++++++++ src/backends/native/meta-renderer-native.h | 5 +++ 2 files changed, 47 insertions(+) diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index e4fd7c15c..50e606f7e 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -2220,6 +2220,48 @@ meta_renderer_native_create_dma_buf (CoglRenderer *cogl_renderer, return NULL; } +gboolean +meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen, + uint32_t drm_format, + uint64_t drm_modifier, + uint32_t stride) +{ + CoglOnscreenEGL *onscreen_egl = onscreen->winsys; + MetaOnscreenNative *onscreen_native = onscreen_egl->platform; + MetaDrmBuffer *fb; + struct gbm_bo *gbm_bo; + + if (onscreen_native->crtc->config->transform != META_MONITOR_TRANSFORM_NORMAL) + return FALSE; + + if (onscreen_native->secondary_gpu_state) + return FALSE; + + if (!onscreen_native->gbm.surface) + return FALSE; + + fb = onscreen_native->gbm.current_fb ? onscreen_native->gbm.current_fb + : onscreen_native->gbm.next_fb; + if (!fb) + return FALSE; + + if (!META_IS_DRM_BUFFER_GBM (fb)) + return FALSE; + + gbm_bo = meta_drm_buffer_gbm_get_bo (META_DRM_BUFFER_GBM (fb)); + + if (gbm_bo_get_format (gbm_bo) != drm_format) + return FALSE; + + if (gbm_bo_get_modifier (gbm_bo) != drm_modifier) + return FALSE; + + if (gbm_bo_get_stride (gbm_bo) != stride) + return FALSE; + + return TRUE; +} + static void meta_onscreen_native_direct_scanout (CoglOnscreen *onscreen, CoglScanout *scanout) diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h index 840ae1a40..3ea2c9cc0 100644 --- a/src/backends/native/meta-renderer-native.h +++ b/src/backends/native/meta-renderer-native.h @@ -57,4 +57,9 @@ void meta_renderer_native_finish_frame (MetaRendererNative *renderer_native); int64_t meta_renderer_native_get_frame_counter (MetaRendererNative *renderer_native); +gboolean meta_onscreen_native_is_buffer_scanout_compatible (CoglOnscreen *onscreen, + uint32_t drm_format, + uint64_t drm_modifier, + uint32_t stride); + #endif /* META_RENDERER_NATIVE_H */