radeonsi/video: use specific PIPE_BIND_ value for video buffers

Since 13cb41f666 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 <marek.olsak@amd.com>
Reviewed-by: Boyuan Zhang <boyuan.zhang@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21416>
This commit is contained in:
Pierre-Eric Pelloux-Prayer
2023-02-15 15:18:52 +01:00
committed by Marge Bot
parent 635d62ba99
commit a502f4fc13
2 changed files with 8 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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) &&