From 09977d687dd89998cbed881f0f523fa01359040d Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 30 Jan 2023 16:31:21 +0100 Subject: [PATCH] frontents/va: Use PIPE_USAGE_STAGING for coded buffer Coded buffer will only be read on CPU, setting PIPE_USAGE_STAGING instead of PIPE_USAGE_STREAM makes the CPU reads much faster. On 6700XT this reduces the CPU copy by around 3ms to 0.3 ms on average while under high GPU load - real-time game streaming. Signed-off-by: David Rosca Reviewed-by: Ruijing Dong Part-of: --- src/gallium/frontends/va/picture_h264_enc.c | 2 +- src/gallium/frontends/va/picture_hevc_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/va/picture_h264_enc.c b/src/gallium/frontends/va/picture_h264_enc.c index 5159cdd8a0f..79e23d4cc53 100644 --- a/src/gallium/frontends/va/picture_h264_enc.c +++ b/src/gallium/frontends/va/picture_h264_enc.c @@ -53,7 +53,7 @@ vlVaHandleVAEncPictureParameterBufferTypeH264(vlVaDriver *drv, vlVaContext *cont coded_buf = handle_table_get(drv->htab, h264->coded_buf); if (!coded_buf->derived_surface.resource) coded_buf->derived_surface.resource = pipe_buffer_create(drv->pipe->screen, PIPE_BIND_VERTEX_BUFFER, - PIPE_USAGE_STREAM, coded_buf->size); + PIPE_USAGE_STAGING, coded_buf->size); context->coded_buf = coded_buf; if (context->desc.h264enc.is_ltr) diff --git a/src/gallium/frontends/va/picture_hevc_enc.c b/src/gallium/frontends/va/picture_hevc_enc.c index 44429c2df5d..5826d75868f 100644 --- a/src/gallium/frontends/va/picture_hevc_enc.c +++ b/src/gallium/frontends/va/picture_hevc_enc.c @@ -56,7 +56,7 @@ vlVaHandleVAEncPictureParameterBufferTypeHEVC(vlVaDriver *drv, vlVaContext *cont if (!coded_buf->derived_surface.resource) coded_buf->derived_surface.resource = pipe_buffer_create(drv->pipe->screen, PIPE_BIND_VERTEX_BUFFER, - PIPE_USAGE_STREAM, coded_buf->size); + PIPE_USAGE_STAGING, coded_buf->size); context->coded_buf = coded_buf; context->desc.h265enc.pic.log2_parallel_merge_level_minus2 = h265->log2_parallel_merge_level_minus2;