From f96ad5d71c067c4263c1af1552d02637e76d9c01 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Mon, 25 Oct 2021 15:53:21 -0500 Subject: [PATCH] panfrost: Support planar formats for scanout While panfrost doesn't directly support planar formats, we can get here from GBM. This happens, for example, when weston is trying to use a BO for direct scanout. Walk the list of planes to find the right one. Signed-off-by: Derek Foreman Reviewed-by: Daniel Stone Reviewed-by: Simon Ser Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 18c43ea7e47..84120be64a0 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -135,8 +135,21 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen, unsigned usage) { struct panfrost_device *dev = pan_device(pscreen); - struct panfrost_resource *rsrc = (struct panfrost_resource *) pt; - struct renderonly_scanout *scanout = rsrc->scanout; + struct panfrost_resource *rsrc; + struct renderonly_scanout *scanout; + struct pipe_resource *cur = pt; + + /* Even though panfrost doesn't support multi-planar formats, we + * can get here through GBM, which does. Walk the list of planes + * to find the right one. + */ + for (int i = 0; i < handle->plane; i++) { + cur = cur->next; + if (!cur) + return false; + } + rsrc = pan_resource(cur); + scanout = rsrc->scanout; handle->modifier = rsrc->image.layout.modifier; rsrc->modifier_constant = true;