Mesa (master): gallium/dri: fix dri2_from_planar for multiplanar images

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 29 12:13:21 UTC 2020


Module: Mesa
Branch: master
Commit: 13859c769f0e00291bda9bd60f0600c45ac17a03
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=13859c769f0e00291bda9bd60f0600c45ac17a03

Author: Philipp Zabel <p.zabel at pengutronix.de>
Date:   Thu Feb 14 18:40:57 2019 +0100

gallium/dri: fix dri2_from_planar for multiplanar images

Fix the gbm_dri_bo_get_handle_for_plane use case by allowing plane > 0
in dri2_from_planar for images with multiple planes in separate chained
texture resources.

Not all multiplanar resources are chained, though. The iris aux buffer
is a separate plane in the same resource.

Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7028>

---

 src/gallium/frontends/dri/dri2.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index 86ac38df1f4..3ed55866ad7 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -1379,18 +1379,28 @@ static __DRIimage *
 dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate)
 {
    __DRIimage *img;
+   struct pipe_resource *tex = image->texture;
+   int i;
 
    if (plane < 0) {
       return NULL;
    } else if (plane > 0) {
       uint64_t planes;
-      if (!dri2_resource_get_param(image, PIPE_RESOURCE_PARAM_NPLANES, 0,
-                                   &planes) ||
+      if (dri2_resource_get_param(image, PIPE_RESOURCE_PARAM_NPLANES, 0,
+                                  &planes) &&
           plane >= planes) {
          return NULL;
       }
    }
 
+   if (tex->next) {
+      for (i = 0; i < plane; i++) {
+         tex = tex->next;
+         if (!tex)
+            return NULL;
+      }
+   }
+
    if (image->dri_components == 0) {
       uint64_t modifier;
       if (!dri2_resource_get_param(image, PIPE_RESOURCE_PARAM_MODIFIER, 0,
@@ -1404,6 +1414,8 @@ dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate)
    if (img == NULL)
       return NULL;
 
+   pipe_resource_reference(&img->texture, tex);
+
    if (img->texture->screen->resource_changed)
       img->texture->screen->resource_changed(img->texture->screen,
                                              img->texture);



More information about the mesa-commit mailing list