frontends/va: Also map VAImageBufferType for reading
authorDavid Rosca <nowrep@gmail.com>
Sun, 30 Jul 2023 12:06:11 +0000 (14:06 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 1 Aug 2023 15:36:04 +0000 (15:36 +0000)
VAImageBufferType can be used for both reading and writing,
so map it as such.

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

src/gallium/frontends/va/buffer.c

index 6a8ca44..6d40add 100644 (file)
@@ -131,6 +131,7 @@ 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,
@@ -149,9 +150,19 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff)
       else
          map_func = drv->pipe->texture_map;
 
-      *pbuff = map_func(drv->pipe, resource, 0,
-                        buf->type == VAEncCodedBufferType ?
-                        PIPE_MAP_READ : PIPE_MAP_WRITE,
+      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,
                         &box, &buf->derived_surface.transfer);
       mtx_unlock(&drv->mutex);