cuda: Enable x86 NVMM support again
It was broken since memory copy helper function was moved to gst-libs. Also, adding "cuda-nvmm" and "cuda-nvmm-include-path" build options to en/disable NVMM support in gstcuda library Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6978>
This commit is contained in:
parent
6fb0c7b928
commit
afb62e98c7
@ -20,15 +20,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/video/video.h>
|
||||
#include <nvbufsurface.h>
|
||||
#include <gst/cuda/cuda-prelude.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_CAPS_FEATURE_MEMORY_CUDA_NVMM_MEMORY "memory:NVMM"
|
||||
|
||||
GST_CUDA_API
|
||||
gboolean gst_cuda_nvmm_init_once (void);
|
||||
|
||||
GST_CUDA_API
|
||||
GstBufferPool * gst_cuda_nvmm_buffer_pool_new (void);
|
||||
|
||||
G_END_DECLS
|
@ -21,16 +21,29 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstcudanvmm.h"
|
||||
#include "gstcudanvmm-private.h"
|
||||
#include <gmodule.h>
|
||||
#include <string.h>
|
||||
#include "gstcuda-private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (gst_cuda_nvmm_debug);
|
||||
#define GST_CAT_DEFAULT gst_cuda_nvmm_debug
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
#define GST_CAT_DEFAULT ensure_debug_category()
|
||||
static GstDebugCategory *
|
||||
ensure_debug_category (void)
|
||||
{
|
||||
static GstDebugCategory *cat = nullptr;
|
||||
|
||||
GST_CUDA_CALL_ONCE_BEGIN {
|
||||
cat = _gst_debug_category_new ("cudanvmm", 0, "cudanvmm");
|
||||
} GST_CUDA_CALL_ONCE_END;
|
||||
|
||||
return cat;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define LOAD_SYMBOL(name) G_STMT_START { \
|
||||
if (!g_module_symbol (module, G_STRINGIFY (name), (gpointer *) &vtable->name)) { \
|
||||
GST_ERROR ("Failed to load symbol '%s', %s", G_STRINGIFY (name), g_module_error()); \
|
||||
GST_INFO ("Failed to load symbol '%s', %s", G_STRINGIFY (name), g_module_error()); \
|
||||
goto error; \
|
||||
} \
|
||||
} G_STMT_END;
|
||||
@ -79,12 +92,10 @@ gboolean
|
||||
gst_cuda_nvmm_init_once (void)
|
||||
{
|
||||
static gboolean loaded = FALSE;
|
||||
static gsize load_once = 0;
|
||||
|
||||
if (g_once_init_enter (&load_once)) {
|
||||
GST_CUDA_CALL_ONCE_BEGIN {
|
||||
loaded = gst_cuda_nvmm_load_library ();
|
||||
g_once_init_leave (&load_once, 1);
|
||||
}
|
||||
} GST_CUDA_CALL_ONCE_END;
|
||||
|
||||
return loaded;
|
||||
}
|
@ -39,8 +39,9 @@
|
||||
#include <sddl.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#include "gstcudanvmm.h"
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
#include "gstcudanvmm-private.h"
|
||||
#include <nvbufsurface.h>
|
||||
#endif
|
||||
|
||||
#include "gstcudamemory.h"
|
||||
@ -784,7 +785,7 @@ map_buffer_and_fill_copy2d (GstBuffer * buf, const GstVideoInfo * info,
|
||||
gboolean buffer_mapped = FALSE;
|
||||
guint i;
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (copy_type == GST_CUDA_BUFFER_COPY_NVMM) {
|
||||
NvBufSurface *surface;
|
||||
NvBufSurfaceParams *surface_params;
|
||||
|
@ -3,6 +3,7 @@ cuda_sources = files([
|
||||
'gstcudacontext.cpp',
|
||||
'gstcudaloader.cpp',
|
||||
'gstcudamemory.cpp',
|
||||
'gstcudanvmm.cpp',
|
||||
'gstcudanvrtc.cpp',
|
||||
'gstcudastream.cpp',
|
||||
'gstcudautils.cpp',
|
||||
@ -26,6 +27,9 @@ gstcuda_stub_dep = declare_dependency(
|
||||
include_directories: cuda_stubinc
|
||||
)
|
||||
|
||||
have_nvbufsurface_h = false
|
||||
gstcuda_nvmm_inc = []
|
||||
|
||||
gstcuda_platform_dep = []
|
||||
if host_system not in ['windows', 'linux']
|
||||
subdir_done()
|
||||
@ -80,6 +84,21 @@ if host_system == 'windows'
|
||||
'-Wno-redundant-decls',
|
||||
])
|
||||
endif
|
||||
else
|
||||
nvmm_opt = get_option('cuda-nvmm')
|
||||
if not nvmm_opt.disabled()
|
||||
nvmm_inc_opt = get_option('cuda-nvmm-include-path')
|
||||
if nvmm_inc_opt != ''
|
||||
gstcuda_nvmm_inc = [include_directories(nvmm_inc_opt)]
|
||||
endif
|
||||
|
||||
have_nvbufsurface_h = cc.has_header('nvbufsurface.h',
|
||||
include_directories: gstcuda_nvmm_inc,
|
||||
required: nvmm_opt)
|
||||
endif
|
||||
if have_nvbufsurface_h
|
||||
extra_args += ['-DHAVE_CUDA_NVMM']
|
||||
endif
|
||||
endif
|
||||
|
||||
pkg_name = 'gstreamer-cuda-' + api_version
|
||||
@ -87,7 +106,7 @@ gstcuda= library('gstcuda-' + api_version,
|
||||
cuda_sources,
|
||||
c_args : gst_plugins_bad_args + extra_args,
|
||||
cpp_args : gst_plugins_bad_args + extra_args,
|
||||
include_directories : [configinc, libsinc, cuda_stubinc],
|
||||
include_directories : [configinc, libsinc, cuda_stubinc] + gstcuda_nvmm_inc,
|
||||
version : libversion,
|
||||
soversion : soversion,
|
||||
install : true,
|
||||
|
@ -213,6 +213,10 @@ option('aja-include-dir', type : 'string', value : '',
|
||||
option('aja-lib-dir', type : 'string', value : '',
|
||||
description : 'Directory where AJA NTV2 library is located')
|
||||
|
||||
# CUDA library options
|
||||
option('cuda-nvmm', type : 'feature', value : 'auto', description : 'Enable NVMM support in cuda library')
|
||||
option('cuda-nvmm-include-path', type : 'string', value : '', description : 'Include path for NVMM support in cuda library')
|
||||
|
||||
# D3D11/D3D12 HLSL library options
|
||||
option('d3d-hlsl-precompile', type : 'feature', value : 'auto', description : 'Enable buildtime HLSL compile for d3d11/d3d12 library/plugin')
|
||||
|
||||
|
@ -42,8 +42,9 @@
|
||||
#include "gstcudamemorycopy.h"
|
||||
#include "gstcudaformat.h"
|
||||
#include <gst/cuda/gstcuda-private.h>
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#include "gstcudanvmm.h"
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
#include <gst/cuda/gstcudanvmm-private.h>
|
||||
#include <nvbufsurface.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CUDA_GST_GL
|
||||
@ -272,7 +273,7 @@ create_transform_caps (GstCaps * caps, gboolean to_cuda)
|
||||
/* SRC -> SINK of cudadownload or SINK -> SRC of cudaupload */
|
||||
ret = gst_caps_copy (caps);
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (gst_cuda_nvmm_init_once ()) {
|
||||
new_caps = _set_caps_features (caps,
|
||||
GST_CAPS_FEATURE_MEMORY_CUDA_NVMM_MEMORY);
|
||||
@ -289,7 +290,7 @@ create_transform_caps (GstCaps * caps, gboolean to_cuda)
|
||||
/* SINK -> SRC of cudadownload or SRC -> SINK of cudaupload */
|
||||
ret = gst_caps_ref (caps);
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (gst_cuda_nvmm_init_once ()) {
|
||||
new_caps = _set_caps_features (caps,
|
||||
GST_CAPS_FEATURE_MEMORY_CUDA_NVMM_MEMORY);
|
||||
@ -529,7 +530,7 @@ gst_cuda_memory_copy_propose_allocation (GstBaseTransform * trans,
|
||||
|
||||
pool = gst_d3d11_buffer_pool_new (self->d3d11_device);
|
||||
#endif
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
} else if (features && gst_caps_features_contains (features,
|
||||
GST_CAPS_FEATURE_MEMORY_CUDA_NVMM_MEMORY) &&
|
||||
gst_cuda_nvmm_init_once ()) {
|
||||
@ -618,7 +619,7 @@ gst_cuda_memory_copy_decide_allocation (GstBaseTransform * trans,
|
||||
#ifdef G_OS_WIN32
|
||||
gboolean need_d3d11 = FALSE;
|
||||
#endif
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
gboolean need_nvmm = FALSE;
|
||||
#endif
|
||||
|
||||
@ -652,7 +653,7 @@ gst_cuda_memory_copy_decide_allocation (GstBaseTransform * trans,
|
||||
need_d3d11 = TRUE;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
else if (features && gst_caps_features_contains (features,
|
||||
GST_CAPS_FEATURE_MEMORY_CUDA_NVMM_MEMORY) &&
|
||||
gst_cuda_nvmm_init_once ()) {
|
||||
@ -673,7 +674,7 @@ gst_cuda_memory_copy_decide_allocation (GstBaseTransform * trans,
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (need_nvmm) {
|
||||
/* XXX: Always create new pool to set config option */
|
||||
gst_clear_object (&pool);
|
||||
@ -705,7 +706,7 @@ gst_cuda_memory_copy_decide_allocation (GstBaseTransform * trans,
|
||||
pool = gst_d3d11_buffer_pool_new (self->d3d11_device);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
else if (need_nvmm) {
|
||||
guint gpu_id = 0;
|
||||
GST_DEBUG_OBJECT (self, "create nvmm pool");
|
||||
@ -859,7 +860,7 @@ gst_cuda_memory_copy_set_info (GstCudaBaseTransform * btrans,
|
||||
gst_clear_object (&self->d3d11_device);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (gst_cuda_nvmm_init_once ()) {
|
||||
if (in_features && gst_caps_features_contains (in_features,
|
||||
GST_CAPS_FEATURE_MEMORY_CUDA_NVMM_MEMORY)) {
|
||||
@ -1160,7 +1161,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank)
|
||||
};
|
||||
GstCaps *sys_caps;
|
||||
GstCaps *cuda_caps;
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
GstCaps *nvmm_caps = NULL;
|
||||
#endif
|
||||
#ifdef HAVE_CUDA_GST_GL
|
||||
@ -1183,7 +1184,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank)
|
||||
cuda_caps =
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
||||
(GST_CAPS_FEATURE_MEMORY_CUDA_MEMORY, GST_CUDA_FORMATS));
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (gst_cuda_nvmm_init_once ()) {
|
||||
nvmm_caps =
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
|
||||
@ -1209,7 +1210,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank)
|
||||
upload_sink_caps =
|
||||
gst_caps_merge (upload_sink_caps, gst_caps_copy (d3d11_caps));
|
||||
#endif
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (nvmm_caps) {
|
||||
upload_sink_caps = gst_caps_merge (upload_sink_caps,
|
||||
gst_caps_copy (nvmm_caps));
|
||||
@ -1219,7 +1220,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank)
|
||||
gst_caps_merge (upload_sink_caps, gst_caps_copy (cuda_caps));
|
||||
|
||||
upload_src_caps = gst_caps_copy (cuda_caps);
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (nvmm_caps) {
|
||||
upload_src_caps = gst_caps_merge (upload_src_caps,
|
||||
gst_caps_copy (nvmm_caps));
|
||||
@ -1228,7 +1229,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank)
|
||||
upload_src_caps = gst_caps_merge (upload_src_caps, gst_caps_copy (sys_caps));
|
||||
|
||||
download_sink_caps = gst_caps_copy (cuda_caps);
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (nvmm_caps) {
|
||||
download_sink_caps = gst_caps_merge (download_sink_caps,
|
||||
gst_caps_copy (nvmm_caps));
|
||||
@ -1244,7 +1245,7 @@ gst_cuda_memory_copy_register (GstPlugin * plugin, guint rank)
|
||||
#ifdef G_OS_WIN32
|
||||
download_src_caps = gst_caps_merge (download_src_caps, d3d11_caps);
|
||||
#endif
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#ifdef HAVE_CUDA_NVMM
|
||||
if (nvmm_caps) {
|
||||
download_src_caps = gst_caps_merge (download_src_caps, nvmm_caps);
|
||||
}
|
||||
|
@ -27,10 +27,6 @@ nvcodec_sources = [
|
||||
'plugin.c',
|
||||
]
|
||||
|
||||
nvmm_sources = [
|
||||
'gstcudanvmm.c',
|
||||
]
|
||||
|
||||
nvcodec_win32_sources = [
|
||||
'gstcudaipcclient_win32.cpp',
|
||||
'gstcudaipcserver_win32.cpp',
|
||||
@ -61,18 +57,9 @@ if gstgl_dep.found()
|
||||
endif
|
||||
|
||||
if host_system == 'linux'
|
||||
have_nvmm = false
|
||||
if cc.has_header('nvbufsurface.h')
|
||||
have_nvmm = true
|
||||
elif cc.has_header('/opt/nvidia/deepstream/deepstream/sources/includes/nvbufsurface.h')
|
||||
# XXX: Should add an option for SDK path??
|
||||
have_nvmm = true
|
||||
plugin_incdirs += [include_directories('/opt/nvidia/deepstream/deepstream/sources/includes')]
|
||||
endif
|
||||
|
||||
if have_nvmm
|
||||
extra_args += ['-DHAVE_NVCODEC_NVMM']
|
||||
nvcodec_sources += nvmm_sources
|
||||
if have_nvbufsurface_h
|
||||
extra_args += ['-DHAVE_CUDA_NVMM']
|
||||
plugin_incdirs += gstcuda_nvmm_inc
|
||||
endif
|
||||
|
||||
gio_unix_dep = dependency('gio-unix-2.0', required : get_option('nvcodec'))
|
||||
|
@ -40,9 +40,7 @@
|
||||
#include "gstnvdecoder.h"
|
||||
#include "gstcudamemorycopy.h"
|
||||
#include "gstcudaconvertscale.h"
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
#include "gstcudanvmm.h"
|
||||
#endif
|
||||
#include <gst/cuda/gstcudanvmm-private.h>
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <gst/d3d11/gstd3d11.h>
|
||||
@ -62,10 +60,6 @@ GST_DEBUG_CATEGORY (gst_nvdec_debug);
|
||||
GST_DEBUG_CATEGORY (gst_nvenc_debug);
|
||||
GST_DEBUG_CATEGORY (gst_nv_decoder_debug);
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
GST_DEBUG_CATEGORY (gst_cuda_nvmm_debug);
|
||||
#endif
|
||||
|
||||
#define GST_CAT_DEFAULT gst_nvcodec_debug
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
@ -135,10 +129,6 @@ plugin_init (GstPlugin * plugin)
|
||||
GST_DEBUG_CATEGORY_INIT (gst_nvenc_debug, "nvenc", 0, "nvenc");
|
||||
GST_DEBUG_CATEGORY_INIT (gst_nv_decoder_debug, "nvdecoder", 0, "nvdecoder");
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
GST_DEBUG_CATEGORY_INIT (gst_cuda_nvmm_debug, "cudanvmm", 0, "cudanvmm");
|
||||
#endif
|
||||
|
||||
if (!gst_cuda_load_library ()) {
|
||||
gst_plugin_add_status_warning (plugin,
|
||||
"CUDA library \"" CUDA_LIBNAME "\" was not found.");
|
||||
@ -354,12 +344,8 @@ plugin_init (GstPlugin * plugin)
|
||||
"cudaipcsrc", GST_RANK_NONE, GST_TYPE_CUDA_IPC_SRC);
|
||||
|
||||
gst_cuda_memory_init_once ();
|
||||
|
||||
#ifdef HAVE_NVCODEC_NVMM
|
||||
if (gst_cuda_nvmm_init_once ()) {
|
||||
if (gst_cuda_nvmm_init_once ())
|
||||
GST_INFO ("Enable NVMM support");
|
||||
}
|
||||
#endif
|
||||
|
||||
g_object_set_data_full (G_OBJECT (plugin),
|
||||
"plugin-nvcodec-shutdown", (gpointer) "shutdown-data",
|
||||
|
Loading…
x
Reference in New Issue
Block a user