mirror of https://git.ffmpeg.org/ffmpeg.git
hwcontext_vulkan: wait and signal semaphores when transferring to CUDA
Same as when downloading. Not sure why this isn't done, probably because the CUDA code predates the sync mechanism we settled on.
This commit is contained in:
parent
89e3f5abb7
commit
b51b9bbd42
|
@ -3253,6 +3253,8 @@ static int vulkan_transfer_data_to_cuda(AVHWFramesContext *hwfc, AVFrame *dst,
|
||||||
AVCUDADeviceContext *cuda_dev = cuda_cu->hwctx;
|
AVCUDADeviceContext *cuda_dev = cuda_cu->hwctx;
|
||||||
AVCUDADeviceContextInternal *cu_internal = cuda_dev->internal;
|
AVCUDADeviceContextInternal *cu_internal = cuda_dev->internal;
|
||||||
CudaFunctions *cu = cu_internal->cuda_dl;
|
CudaFunctions *cu = cu_internal->cuda_dl;
|
||||||
|
CUDA_EXTERNAL_SEMAPHORE_WAIT_PARAMS s_w_par[AV_NUM_DATA_POINTERS] = { 0 };
|
||||||
|
CUDA_EXTERNAL_SEMAPHORE_SIGNAL_PARAMS s_s_par[AV_NUM_DATA_POINTERS] = { 0 };
|
||||||
|
|
||||||
ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_dev->cuda_ctx));
|
ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_dev->cuda_ctx));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -3268,6 +3270,13 @@ static int vulkan_transfer_data_to_cuda(AVHWFramesContext *hwfc, AVFrame *dst,
|
||||||
|
|
||||||
dst_int = dst_f->internal;
|
dst_int = dst_f->internal;
|
||||||
|
|
||||||
|
ret = CHECK_CU(cu->cuWaitExternalSemaphoresAsync(dst_int->cu_sem, s_w_par,
|
||||||
|
planes, cuda_dev->stream));
|
||||||
|
if (ret < 0) {
|
||||||
|
err = AVERROR_EXTERNAL;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < planes; i++) {
|
for (int i = 0; i < planes; i++) {
|
||||||
CUDA_MEMCPY2D cpy = {
|
CUDA_MEMCPY2D cpy = {
|
||||||
.dstMemoryType = CU_MEMORYTYPE_DEVICE,
|
.dstMemoryType = CU_MEMORYTYPE_DEVICE,
|
||||||
|
@ -3292,6 +3301,13 @@ static int vulkan_transfer_data_to_cuda(AVHWFramesContext *hwfc, AVFrame *dst,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = CHECK_CU(cu->cuSignalExternalSemaphoresAsync(dst_int->cu_sem, s_s_par,
|
||||||
|
planes, cuda_dev->stream));
|
||||||
|
if (ret < 0) {
|
||||||
|
err = AVERROR_EXTERNAL;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_CU(cu->cuCtxPopCurrent(&dummy));
|
CHECK_CU(cu->cuCtxPopCurrent(&dummy));
|
||||||
|
|
||||||
av_log(hwfc, AV_LOG_VERBOSE, "Transfered Vulkan image to CUDA!\n");
|
av_log(hwfc, AV_LOG_VERBOSE, "Transfered Vulkan image to CUDA!\n");
|
||||||
|
|
Loading…
Reference in New Issue