nvcodec: Peer direct access support

If support direct access each other, use device to device memory copy
without staging host memory

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1633>
This commit is contained in:
Seungha Yang 2019-10-16 22:21:05 +09:00 committed by GStreamer Merge Bot
parent d16a9237c3
commit b1ac8bafc9
2 changed files with 8 additions and 4 deletions

View file

@ -2450,10 +2450,12 @@ gst_nv_base_enc_handle_frame (GstVideoEncoder * enc, GstVideoCodecFrame * frame)
gst_is_cuda_memory (mem)) {
GstCudaMemory *cmem = GST_CUDA_MEMORY_CAST (mem);
/* FIXME: enhance CUDA memory copy over multiple-gpu */
if (cmem->context == nvenc->cuda_ctx ||
gst_cuda_context_get_handle (cmem->context) ==
gst_cuda_context_get_handle (nvenc->cuda_ctx)) {
gst_cuda_context_get_handle (nvenc->cuda_ctx) ||
(gst_cuda_context_can_access_peer (cmem->context, nvenc->cuda_ctx) &&
gst_cuda_context_can_access_peer (nvenc->cuda_ctx,
cmem->context))) {
use_device_memory = TRUE;
in_map_flags |= GST_MAP_CUDA;
}

View file

@ -1151,10 +1151,12 @@ gst_nvdec_copy_device_to_memory (GstNvDec * nvdec,
gst_is_cuda_memory (mem)) {
GstCudaMemory *cmem = GST_CUDA_MEMORY_CAST (mem);
/* FIXME: enhance CUDA memory copy over multiple-gpu */
if (cmem->context == nvdec->cuda_ctx ||
gst_cuda_context_get_handle (cmem->context) ==
gst_cuda_context_get_handle (nvdec->cuda_ctx)) {
gst_cuda_context_get_handle (nvdec->cuda_ctx) ||
(gst_cuda_context_can_access_peer (cmem->context, nvdec->cuda_ctx) &&
gst_cuda_context_can_access_peer (nvdec->cuda_ctx,
cmem->context))) {
cuda_mem = cmem;
}
}