From a502f4fc133d7e8b2804fe60ea56a82dac46b95f Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 15 Feb 2023 15:18:52 +0100 Subject: [PATCH] radeonsi/video: use specific PIPE_BIND_ value for video buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 13cb41f6662 PIPE_BIND_SHARED was used to allocate driver internal video buffers. These buffers are never shared, but the intent was to get non-suballocated buffers and SHARED was used as an indirect flag. This commit switches to PIPE_BIND_CUSTOM which isn't used anywhere else, and is now translated as "no suballocation". The main benefit here is that this allows these buffers to set use_reusable_pool to true reducing the CPU overhead a lot. For instance, running the following command on my system: ffmpeg -hwaccel vaapi -hwaccel_output_format vaapi \ -i tears_of_steel_1080p.mov -an -c:v h264_vaapi output.mp4 takes 35 sec with this commit vs 45 sec without. Reviewed-by: Marek Olšák Reviewed-by: Boyuan Zhang Part-of: --- src/gallium/drivers/radeonsi/radeon_video.c | 4 ++-- src/gallium/drivers/radeonsi/si_buffer.c | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/radeonsi/radeon_video.c b/src/gallium/drivers/radeonsi/radeon_video.c index 2e7037ec021..378e2798dbf 100644 --- a/src/gallium/drivers/radeonsi/radeon_video.c +++ b/src/gallium/drivers/radeonsi/radeon_video.c @@ -62,7 +62,7 @@ bool si_vid_create_buffer(struct pipe_screen *screen, struct rvid_buffer *buffer * able to move buffers around individually, so request a * non-sub-allocated buffer. */ - buffer->res = si_resource(pipe_buffer_create(screen, PIPE_BIND_SHARED, usage, size)); + buffer->res = si_resource(pipe_buffer_create(screen, PIPE_BIND_CUSTOM, usage, size)); return buffer->res != NULL; } @@ -73,7 +73,7 @@ bool si_vid_create_tmz_buffer(struct pipe_screen *screen, struct rvid_buffer *bu { memset(buffer, 0, sizeof(*buffer)); buffer->usage = usage; - buffer->res = si_resource(pipe_buffer_create(screen, PIPE_BIND_SHARED | PIPE_BIND_PROTECTED, + buffer->res = si_resource(pipe_buffer_create(screen, PIPE_BIND_CUSTOM | PIPE_BIND_PROTECTED, usage, size)); return buffer->res != NULL; } diff --git a/src/gallium/drivers/radeonsi/si_buffer.c b/src/gallium/drivers/radeonsi/si_buffer.c index 7a07a84d362..b6cbbfa2856 100644 --- a/src/gallium/drivers/radeonsi/si_buffer.c +++ b/src/gallium/drivers/radeonsi/si_buffer.c @@ -106,6 +106,12 @@ void si_init_resource_fields(struct si_screen *sscreen, struct si_resource *res, else res->flags |= RADEON_FLAG_NO_INTERPROCESS_SHARING; + /* PIPE_BIND_CUSTOM is used by si_vid_create_buffer which wants + * non-suballocated buffers. + */ + if (res->b.b.bind & PIPE_BIND_CUSTOM) + res->flags |= RADEON_FLAG_NO_SUBALLOC; + if (res->b.b.bind & PIPE_BIND_PROTECTED || /* Force scanout/depth/stencil buffer allocation to be encrypted */ (sscreen->debug_flags & DBG(TMZ) &&