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
This commit is contained in:
Jonas Ådahl 2019-09-12 21:41:17 +02:00
parent 3dd8861fbf
commit b9fe9c736a
2 changed files with 47 additions and 0 deletions

View File

@ -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)

View File

@ -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 */