summaryrefslogtreecommitdiffstats
path: root/video/out/hwdec
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2022-02-27 11:28:21 +0100
committerNiklas Haas <github-daiK1o@haasn.dev>2022-03-03 13:06:05 +0100
commitbb434a60ed801723c8e3becae019352935539e50 (patch)
treeeb7ac7755d24675a27d7c5c4c16f020545a8ea86 /video/out/hwdec
parente2c02a4ce3af792251839307c42c85aa34bdd125 (diff)
downloadmpv-bb434a60ed801723c8e3becae019352935539e50.tar.bz2
mpv-bb434a60ed801723c8e3becae019352935539e50.tar.xz
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.
Diffstat (limited to 'video/out/hwdec')
-rw-r--r--video/out/hwdec/hwdec_cuda.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/video/out/hwdec/hwdec_cuda.c b/video/out/hwdec/hwdec_cuda.c
index 895fb07d61..0fe0f7bda8 100644
--- a/video/out/hwdec/hwdec_cuda.c
+++ b/video/out/hwdec/hwdec_cuda.c
@@ -253,12 +253,18 @@ static int mapper_map(struct ra_hwdec_mapper *mapper)
if (p_owner->do_full_sync)
CHECK_CU(cu->cuStreamSynchronize(0));
+ // fall through
error:
- eret = CHECK_CU(cu->cuCtxPopCurrent(&dummy));
- if (eret < 0)
- return eret;
- return ret;
+ // 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;
+
+ return ret;
}
const struct ra_hwdec_driver ra_hwdec_cuda = {