panfrost: Support planar formats for scanout
authorDerek Foreman <derek.foreman@collabora.com>
Mon, 25 Oct 2021 20:53:21 +0000 (15:53 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 26 Oct 2021 12:19:10 +0000 (12:19 +0000)
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 <derek.foreman@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13039>

src/gallium/drivers/panfrost/pan_resource.c

index 18c43ea..84120be 100644 (file)
@@ -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;