From 9873ccb07145a882307e8302375319ef61ac2132 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sun, 18 Dec 2022 18:01:37 +0100 Subject: [PATCH] frontends/va: Map VAEncCodedBufferType buffer as PIPE_MAP_READ 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 Reviewed-by: Ruijing Dong Part-of: --- src/gallium/frontends/va/buffer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/va/buffer.c b/src/gallium/frontends/va/buffer.c index af035ef5f90..6a8ca44534c 100644 --- a/src/gallium/frontends/va/buffer.c +++ b/src/gallium/frontends/va/buffer.c @@ -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);