Revert "frontends/va: Also map VAImageBufferType for reading"
authorLeo Liu <leo.liu@amd.com>
Fri, 8 Sep 2023 18:58:43 +0000 (14:58 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 12 Sep 2023 18:40:30 +0000 (18:40 +0000)
This reverts commit 12a4f2c1328f31954f9bf70d255f9d3e7bb010d4.

With PIPE_MAP_READ_WRITE and derived image, the encoder will copy
to and from staging buffer for each frame, which caused performance
degradation, even worse than putImage.

Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25128>

src/gallium/frontends/va/buffer.c

index bff3bf4..ca0f79d 100644 (file)
@@ -135,7 +135,6 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff)
    if (buf->derived_surface.resource) {
       struct pipe_resource *resource;
       struct pipe_box box;
-      unsigned usage;
       void *(*map_func)(struct pipe_context *,
              struct pipe_resource *resource,
              unsigned level,
@@ -154,19 +153,11 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff)
       else
          map_func = drv->pipe->texture_map;
 
-      switch (buf->type) {
-      case VAEncCodedBufferType:
-         usage = PIPE_MAP_READ;
-         break;
-      case VAImageBufferType:
-         usage = PIPE_MAP_READ_WRITE;
-         break;
-      default:
-         usage = PIPE_MAP_WRITE;
-         break;
-      }
-
-      *pbuff = map_func(drv->pipe, resource, 0, usage,
+      /* For VAImageBufferType, use PIPE_MAP_WRITE for now,
+       * PIPE_MAP_READ_WRITE degradate perf with two copies when map/unmap. */
+      *pbuff = map_func(drv->pipe, resource, 0,
+                        buf->type == VAEncCodedBufferType ?
+                        PIPE_MAP_READ : PIPE_MAP_WRITE,
                         &box, &buf->derived_surface.transfer);
       mtx_unlock(&drv->mutex);