From 8c1f94f0e711a40617ab63cd7c439cdc5466aec5 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Sat, 28 Sep 2019 07:57:11 -0700 Subject: vo_gpu: hwdec_cuda: Synchronise OpenGL Interop Previously, there appeared to be implicit synchronisation in the GL interop path, and we never observed any visual glitches. However, recently, I started seeing stuttering in the GL path and on closer examination it looked like read-before-write behaviour where GL would display an old frame again rather than the current one. After verifying that disabling hwdec made the problem go away, I tried adding a cuStreamSynchronize() after the memcpys and that also resolved the problem, so it's clearly sync related. cuStreamSynchronize() is a CPU sync and so more heavy-weight than you want, but it's the only tool we have. There is no mechanism defined for synchronising GL to CUDA (It looks like there is a way to synchronise CUDA to EGL but it appears one way and so wouldn't directly address this problem). Anyway, empirically, the output now looks the same as with hwdec off. --- video/out/hwdec/hwdec_cuda.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'video/out/hwdec/hwdec_cuda.c') diff --git a/video/out/hwdec/hwdec_cuda.c b/video/out/hwdec/hwdec_cuda.c index 3edc58c6eb..2a2b296ccd 100644 --- a/video/out/hwdec/hwdec_cuda.c +++ b/video/out/hwdec/hwdec_cuda.c @@ -249,6 +249,8 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) goto error; } } + if (p_owner->do_full_sync) + CHECK_CU(cu->cuStreamSynchronize(0)); error: eret = CHECK_CU(cu->cuCtxPopCurrent(&dummy)); -- cgit v1.2.3