summaryrefslogtreecommitdiff
path: root/sys/nvcodec
diff options
context:
space:
mode:
authorSeungha Yang <seungha.yang@navercorp.com>2019-10-16 22:21:05 +0900
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-10-16 15:56:49 +0000
commitb1ac8bafc9d94a64f85c235735729e612918fcde (patch)
tree11c06bc8c0100d1ee87d6d161c1c91dd69a2f6ab /sys/nvcodec
parentd16a9237c33fdc6fc7f9a6c6a2f8add9d5793a8d (diff)
downloadgstreamer-plugins-bad-b1ac8bafc9d94a64f85c235735729e612918fcde.tar.gz
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>
Diffstat (limited to 'sys/nvcodec')
-rw-r--r--sys/nvcodec/gstnvbaseenc.c6
-rw-r--r--sys/nvcodec/gstnvdec.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/sys/nvcodec/gstnvbaseenc.c b/sys/nvcodec/gstnvbaseenc.c
index 2b780f1b4..34bbffa0e 100644
--- a/sys/nvcodec/gstnvbaseenc.c
+++ b/sys/nvcodec/gstnvbaseenc.c
@@ -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;
}
diff --git a/sys/nvcodec/gstnvdec.c b/sys/nvcodec/gstnvdec.c
index b67bdbecd..039ee13f3 100644
--- a/sys/nvcodec/gstnvdec.c
+++ b/sys/nvcodec/gstnvdec.c
@@ -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;
}
}