frontends/va: Map VAEncCodedBufferType buffer as PIPE_MAP_READ
authorDavid Rosca <nowrep@gmail.com>
Sun, 18 Dec 2022 17:01:37 +0000 (18:01 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 15 Feb 2023 14:26:31 +0000 (14:26 +0000)
VAEncCodedBufferType is used for reading back encoded data.
Mapping it for read instead of write speeds up reading
the data on CPU.

On radeonsi this will result in VRAM copy to staging buffer
in cached GTT, making the CPU read much faster.

Signed-off-by: David Rosca <nowrep@gmail.com>
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20376>

src/gallium/frontends/va/buffer.c

index af035ef..6a8ca44 100644 (file)
@@ -149,7 +149,9 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff)
       else
          map_func = drv->pipe->texture_map;
 
-      *pbuff = map_func(drv->pipe, resource, 0, PIPE_MAP_WRITE,
+      *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);