[vlc-commits] nvdec: wait copies before releasing the CUDA frame
Quentin Chateau
git at videolan.org
Tue Mar 24 10:01:54 CET 2020
vlc | branch: master | Quentin Chateau <quentin.chateau at deepskycorp.com> | Mon Mar 23 18:11:41 2020 +0100| [9cebbfcef20a708e908d3e61a91367a024082e55] | committer: Steve Lhomme
nvdec: wait copies before releasing the CUDA frame
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9cebbfcef20a708e908d3e61a91367a024082e55
---
modules/hw/nvdec/nvdec.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index d2ec909fbc..76aec6a246 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -489,13 +489,18 @@ static int CUDAAPI HandlePictureDisplay(void *p_opaque, CUVIDPARSERDISPINFO *p_d
.WidthInBytes = i_pitch,
.Height = plane.i_visible_lines,
};
- result = CALL_CUDA_DEC(cuMemcpy2D, &cu_cpy);
+ result = CALL_CUDA_DEC(cuMemcpy2DAsync, &cu_cpy, 0);
if (result != VLC_SUCCESS)
goto error;
srcY += p_sys->decoderHeight;
}
}
+ // Wait until copies are finished
+ result = CALL_CUDA_DEC(cuStreamSynchronize, 0);
+ if (unlikely(result != VLC_SUCCESS))
+ goto error;
+
// Release surface on GPU
result = CALL_CUVID(cuvidUnmapVideoFrame, p_sys->cudecoder, frameDevicePtr);
if (unlikely(result != VLC_SUCCESS))
@@ -522,7 +527,13 @@ static int CUDAAPI HandlePictureDisplay(void *p_opaque, CUVIDPARSERDISPINFO *p_d
error:
if (frameDevicePtr)
+ {
+ // Synchronize stream to wait for potentitally pending copies
+ // then unmap the frame.
+ // No need to check for errors, there is nothing we can do anyway
+ CALL_CUDA_DEC(cuStreamSynchronize, 0);
CALL_CUVID(cuvidUnmapVideoFrame, p_sys->cudecoder, frameDevicePtr);
+ }
CALL_CUDA_DEC(cuCtxPopCurrent, NULL);
if (p_pic)
picture_Release(p_pic);
More information about the vlc-commits
mailing list