From 8c8985390d02cd87cfd07c953b00ad3940064ee9 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Fri, 8 Sep 2023 14:58:43 -0400 Subject: [PATCH] Revert "frontends/va: Also map VAImageBufferType for reading" 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 Part-of: --- src/gallium/frontends/va/buffer.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/gallium/frontends/va/buffer.c b/src/gallium/frontends/va/buffer.c index bff3bf4..ca0f79d 100644 --- a/src/gallium/frontends/va/buffer.c +++ b/src/gallium/frontends/va/buffer.c @@ -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); -- 2.7.4