panfrost: Support parameter queries for main planes
authorRobert Mader <robert.mader@collabora.com>
Tue, 7 Nov 2023 23:18:41 +0000 (00:18 +0100)
committerEric Engestrom <eric@engestrom.ch>
Sat, 18 Nov 2023 21:18:18 +0000 (21:18 +0000)
In order to return correct offsets, strides and possibly other
parameters. This is relevant for formats like NV12 and P010 where
the second plane, when produced by the V4L2 decoder, uses the
same FD like the first one, but with an offset.

Analogous to 7a7e577d.

Also use the new helper to get the number of planes.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10094
Cc: mesa-stable
Reviewed-by: Italo Nicola <italonicola@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26109>
(cherry picked from commit 5f4253e096de76651d3bd2bbd447abb1e9cb624f)

.pick_status.json
src/gallium/drivers/panfrost/pan_resource.c

index aa884ec..6640f34 100644 (file)
         "description": "panfrost: Support parameter queries for main planes",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null,
         "notes": null
index 6f4b5c1..9abebde 100644 (file)
@@ -41,6 +41,7 @@
 #include "util/u_drm.h"
 #include "util/u_gen_mipmap.h"
 #include "util/u_memory.h"
+#include "util/u_resource.h"
 #include "util/u_surface.h"
 #include "util/u_transfer.h"
 #include "util/u_transfer_helper.h"
@@ -219,9 +220,8 @@ panfrost_resource_get_param(struct pipe_screen *pscreen,
                             enum pipe_resource_param param, unsigned usage,
                             uint64_t *value)
 {
-   struct panfrost_resource *rsrc = (struct panfrost_resource *)prsc;
-   struct pipe_resource *cur;
-   unsigned count;
+   struct panfrost_resource *rsrc =
+      (struct panfrost_resource *)util_resource_at_index(prsc, plane);
 
    switch (param) {
    case PIPE_RESOURCE_PARAM_STRIDE:
@@ -234,14 +234,7 @@ panfrost_resource_get_param(struct pipe_screen *pscreen,
       *value = rsrc->image.layout.modifier;
       return true;
    case PIPE_RESOURCE_PARAM_NPLANES:
-      /* Panfrost doesn't directly support multi-planar formats,
-       * but we should still handle this case for gbm users
-       * that might want to use resources shared with panfrost
-       * on video processing hardware that does.
-       */
-      for (count = 0, cur = prsc; cur; cur = cur->next)
-         count++;
-      *value = count;
+      *value = util_resource_num(prsc);
       return true;
    default:
       return false;