0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

hwdec: release images as soon as possible after mapping

We don't need to hold on to buffers longer than necessary. Doesn't
matter for vo_gpu but greatly matters for vo_gpu_next, since it persists
hwdec mapped textures for longer periods.

Unfortunately, only provides benefits for hwdecs which do explicit
copies in their decode path, which currently just means cuda and
d3d11va.
This commit is contained in:
Niklas Haas 2022-02-27 11:28:21 +01:00 committed by Niklas Haas
parent e2c02a4ce3
commit bb434a60ed
3 changed files with 15 additions and 4 deletions

View File

@ -206,6 +206,9 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
.bottom = mapper->dst_params.h,
.back = 1,
}), D3D11_COPY_DISCARD);
// We no longer need the original texture after copying it.
mp_image_unrefp(&mapper->src);
} else {
D3D11_TEXTURE2D_DESC desc2d;
ID3D11Texture2D_GetDesc(tex, &desc2d);

View File

@ -186,6 +186,8 @@ void ra_hwdec_mapper_unmap(struct ra_hwdec_mapper *mapper)
{
if (mapper->driver->unmap)
mapper->driver->unmap(mapper);
// Clean up after the image if the mapper didn't already
mp_image_unrefp(&mapper->src);
}

View File

@ -253,7 +253,13 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
if (p_owner->do_full_sync)
CHECK_CU(cu->cuStreamSynchronize(0));
// fall through
error:
// Regardless of success or failure, we no longer need the source image,
// because this hwdec makes an explicit memcpy into the mapper textures
mp_image_unrefp(&mapper->src);
eret = CHECK_CU(cu->cuCtxPopCurrent(&dummy));
if (eret < 0)
return eret;