[Bf-blender-cvs] [3dabaa5] decklink: nVidia's DVP library is now linked at runtime.

Benoit Bolsee noreply at git.blender.org
Tue Apr 7 11:07:23 CEST 2015


Commit: 3dabaa598224b8e635c04ca36fc53d64cb6c64ff
Author: Benoit Bolsee
Date:   Tue Apr 7 11:00:13 2015 +0200
Branches: decklink
https://developer.blender.org/rB3dabaa598224b8e635c04ca36fc53d64cb6c64ff

nVidia's DVP library is now linked at runtime.

The DVP library allows direct memory transfer with the GPU to send or
receive textures. It's used in bge.Texture.VideoDeckLink to sent a
captured video stream efficiently to the GPU, only for Windows.
The user will need to download the SDK version 10.3.1 from BlackMagicDesign
and copy dvp.dll where blender can find it (e.g. next to blender.exe)

===================================================================

M	CMakeLists.txt
M	build_files/cmake/macros.cmake
M	intern/CMakeLists.txt
A	intern/gpudirect/CMakeLists.txt
A	intern/gpudirect/dvpapi.cpp
A	intern/gpudirect/dvpapi.h
M	source/blenderplayer/CMakeLists.txt
M	source/creator/CMakeLists.txt
M	source/gameengine/VideoTexture/CMakeLists.txt
M	source/gameengine/VideoTexture/VideoDeckLink.cpp
M	source/gameengine/VideoTexture/VideoDeckLink.h

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d20d4b..fc7fa86 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1351,8 +1351,6 @@ elseif(WIN32)
 			)
 		endif()
 
-		set(NVIDIA_GPUDIRECT_INCLUDE_DIRS ${LIBDIR}/NVIDIA_GPUDirect/include)
-
 		if(WITH_CODEC_FFMPEG)
 			set(FFMPEG_INCLUDE_DIRS
 				${LIBDIR}/ffmpeg/include
@@ -1373,15 +1371,6 @@ elseif(WIN32)
 			endif()
 		endif()
 
-		if(WITH_DECKLINK)
-			set(NVIDIA_GPUDIRECT_LIBRARIES
-				${LIBDIR}/NVIDIA_GPUDirect/lib/dvp.lib
-			)
-			set(NVIDIA_GPUDIRECT_LIBPATH
-				${LIBDIR}/NVIDIA_GPUDirect/lib
-			)
-		endif()
-
 		if(WITH_IMAGE_OPENEXR)
 			set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
 			set(OPENEXR_VERSION "2.1")
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 235c3ac..eed013c 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -284,9 +284,6 @@ macro(SETUP_LIBDIRS)
 	if(WITH_MEM_JEMALLOC)
 		link_directories(${JEMALLOC_LIBPATH})
 	endif()
-	if(WITH_DECKLINK)
-		link_directories(${NVIDIA_GPUDIRECT_LIBPATH})
-	endif()
 	if(WIN32 AND NOT UNIX)
 		link_directories(${PTHREADS_LIBPATH})
 	endif()
@@ -385,9 +382,6 @@ macro(setup_liblinks
 	if(WITH_CODEC_FFMPEG)
 		target_link_libraries(${target} ${FFMPEG_LIBRARIES})
 	endif()
-	if(WIN32 AND WITH_DECKLINK)
-		target_link_libraries(${target} ${NVIDIA_GPUDIRECT_LIBRARIES})
-	endif()
 	if(WITH_OPENCOLLADA)
 		if(WIN32 AND NOT UNIX)
 			file_list_suffix(OPENCOLLADA_LIBRARIES_DEBUG "${OPENCOLLADA_LIBRARIES}" "_d")
@@ -661,7 +655,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
 	endif()
 
 	if(WIN32)
-		list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink)
+		list(APPEND BLENDER_SORTED_LIBS bf_intern_decklink bf_intern_gpudirect)
 	endif()
 
 	foreach(SORTLIB ${BLENDER_SORTED_LIBS})
diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index 76c0ee2..dc915c3 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -82,7 +82,9 @@ if(WITH_OPENNL)
 endif()
 
 # only windows needs utf16 converter
+# gpudirect is a runtime interface to the nVidia's DVP driver, only for windows
 if(WIN32)
 	add_subdirectory(utfconv)
+	add_subdirectory(gpudirect)
 endif()
 
diff --git a/intern/gpudirect/CMakeLists.txt b/intern/gpudirect/CMakeLists.txt
new file mode 100644
index 0000000..4c37946
--- /dev/null
+++ b/intern/gpudirect/CMakeLists.txt
@@ -0,0 +1,41 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2012, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Benoit Bolsee.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	.
+	../../source/blender/blenlib
+)
+
+set(INC_SYS
+	${GLEW_INCLUDE_PATH}
+)
+
+set(SRC
+	dvpapi.cpp
+	dvpapi.h
+)
+
+
+blender_add_lib(bf_intern_gpudirect "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/gpudirect/dvpapi.cpp b/intern/gpudirect/dvpapi.cpp
new file mode 100644
index 0000000..bd507aa
--- /dev/null
+++ b/intern/gpudirect/dvpapi.cpp
@@ -0,0 +1,142 @@
+/*
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* Contributor(s): Benoit Bolsee
+*
+* ***** END GPL LICENSE BLOCK *****
+*/
+
+/** \file gpudirect/dvpapi.c
+*  \ingroup gpudirect
+*/
+
+#ifdef WIN32
+
+#include <stdlib.h>
+#include "dvpapi.h"
+
+extern "C" {
+#include "BLI_dynlib.h"
+}
+
+#define KDVPAPI_Name "dvp.dll"
+
+typedef DVPStatus (DVPAPIENTRY * PFNDVPINITGLCONTEXT) (uint32_t flags);
+typedef DVPStatus (DVPAPIENTRY * PFNDVPCLOSEGLCONTEXT) (void);
+typedef DVPStatus (DVPAPIENTRY * PFNDVPGETLIBRARYVERSION)(uint32_t *major, uint32_t *minor);
+
+static uint32_t __dvpMajorVersion = 0;
+static uint32_t __dvpMinorVersion = 0;
+static PFNDVPGETLIBRARYVERSION __dvpGetLibrayVersion = NULL;
+static PFNDVPINITGLCONTEXT __dvpInitGLContext = NULL;
+static PFNDVPCLOSEGLCONTEXT __dvpCloseGLContext = NULL;
+PFNDVPBEGIN __dvpBegin = NULL;
+PFNDVPEND __dvpEnd = NULL;
+PFNDVPCREATEBUFFER __dvpCreateBuffer = NULL;
+PFNDVPDESTROYBUFFER __dvpDestroyBuffer = NULL;
+PFNDVPFREEBUFFER __dvpFreeBuffer = NULL;
+PFNDVPMEMCPYLINED __dvpMemcpyLined = NULL;
+PFNDVPMEMCPY __dvpMemcpy = NULL;
+PFNDVPIMPORTSYNCOBJECT __dvpImportSyncObject = NULL;
+PFNDVPFREESYNCOBJECT __dvpFreeSyncObject = NULL;
+PFNDVPMAPBUFFERENDAPI __dvpMapBufferEndAPI = NULL;
+PFNDVPMAPBUFFERWAITDVP __dvpMapBufferWaitDVP = NULL;
+PFNDVPMAPBUFFERENDDVP __dvpMapBufferEndDVP = NULL;
+PFNDVPMAPBUFFERWAITAPI __dvpMapBufferWaitAPI = NULL;
+PFNDVPBINDTOGLCTX __dvpBindToGLCtx = NULL;
+PFNDVPGETREQUIREDCONSTANTSGLCTX __dvpGetRequiredConstantsGLCtx = NULL;
+PFNDVPCREATEGPUTEXTUREGL __dvpCreateGPUTextureGL = NULL;
+PFNDVPUNBINDFROMGLCTX __dvpUnbindFromGLCtx = NULL;
+
+static DynamicLibrary *__dvpLibrary = NULL;
+
+DVPStatus dvpGetLibrayVersion(uint32_t *major, uint32_t *minor)
+{
+	if (!__dvpLibrary)
+		return DVP_STATUS_ERROR;
+	*major = __dvpMajorVersion;
+	*minor = __dvpMinorVersion;
+	return DVP_STATUS_OK;
+}
+
+DVPStatus dvpInitGLContext(uint32_t flags)
+{
+	DVPStatus status;
+	if (!__dvpLibrary)
+    {
+		__dvpLibrary = BLI_dynlib_open(KDVPAPI_Name);
+		if (!__dvpLibrary)
+		{
+			return DVP_STATUS_ERROR;
+		}
+//		"?dvpInitGLContext@@YA?AW4DVPStatus@@I at Z";
+		__dvpInitGLContext = (PFNDVPINITGLCONTEXT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpInitGLContext@@YA?AW4DVPStatus@@I at Z");
+		__dvpCloseGLContext = (PFNDVPCLOSEGLCONTEXT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpCloseGLContext@@YA?AW4DVPStatus@@XZ");
+		__dvpGetLibrayVersion = (PFNDVPGETLIBRARYVERSION)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpGetLibrayVersion@@YA?AW4DVPStatus@@PEAI0 at Z");
+		__dvpBegin = (PFNDVPBEGIN)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpBegin@@YA?AW4DVPStatus@@XZ");
+		__dvpEnd = (PFNDVPEND)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpEnd@@YA?AW4DVPStatus@@XZ");
+		__dvpCreateBuffer = (PFNDVPCREATEBUFFER)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpCreateBuffer@@YA?AW4DVPStatus@@PEAUDVPSysmemBufferDescRec@@PEA_K at Z");
+		__dvpDestroyBuffer = (PFNDVPDESTROYBUFFER)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpDestroyBuffer@@YA?AW4DVPStatus@@_K at Z");
+		__dvpFreeBuffer = (PFNDVPFREEBUFFER)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpFreeBuffer@@YA?AW4DVPStatus@@_K at Z");
+		__dvpMemcpyLined = (PFNDVPMEMCPYLINED)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMemcpyLined@@YA?AW4DVPStatus@@_K0I000III at Z");
+		__dvpMemcpy = (PFNDVPMEMCPY)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMemcpy2D@@YA?AW4DVPStatus@@_K0I000IIIII at Z");
+		__dvpImportSyncObject = (PFNDVPIMPORTSYNCOBJECT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpImportSyncObject@@YA?AW4DVPStatus@@PEAUDVPSyncObjectDescRec@@PEA_K at Z");
+		__dvpFreeSyncObject = (PFNDVPFREESYNCOBJECT)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpFreeSyncObject@@YA?AW4DVPStatus@@_K at Z");
+		__dvpMapBufferEndAPI = (PFNDVPMAPBUFFERENDAPI)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferEndAPI@@YA?AW4DVPStatus@@_K at Z");
+		__dvpMapBufferWaitDVP = (PFNDVPMAPBUFFERWAITDVP)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferWaitDVP@@YA?AW4DVPStatus@@_K at Z");
+		__dvpMapBufferEndDVP = (PFNDVPMAPBUFFERENDDVP)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferEndDVP@@YA?AW4DVPStatus@@_K at Z");
+		__dvpMapBufferWaitAPI = (PFNDVPMAPBUFFERWAITAPI)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpMapBufferWaitAPI@@YA?AW4DVPStatus@@_K at Z");
+		__dvpBindToGLCtx = (PFNDVPBINDTOGLCTX)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpBindToGLCtx@@YA?AW4DVPStatus@@_K at Z");
+		__dvpGetRequiredConstantsGLCtx = (PFNDVPGETREQUIREDCONSTANTSGLCTX)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpGetRequiredConstantsGLCtx@@YA?AW4DVPStatus@@PEAI00000 at Z");
+		__dvpCreateGPUTextureGL = (PFNDVPCREATEGPUTEXTUREGL)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpCreateGPUTextureGL@@YA?AW4DVPStatus@@IPEA_K at Z");
+		__dvpUnbindFromGLCtx = (PFNDVPUNBINDFROMGLCTX)BLI_dynlib_find_symbol(__dvpLibrary, "?dvpUnbindFromGLCtx@@YA?AW4DVPStatus@@_K at Z");
+		if (!__dvpInitGLContext ||
+			!__dvpCloseGLContext ||
+			!__dvpGetLibrayVersion ||
+			!__dvpBegin ||
+			!__dvpEnd ||
+			!__dvpCreateBuffer ||
+			!__dvpDestroyBuffer ||
+			!__dvpFreeBuffer ||
+			!__dvpMemcpyLined ||
+			!__dvpMemcpy ||
+			!__dvpImportSyncObject ||
+			!__dvpFreeSyncObject ||
+			!__dvpMapBufferEndAPI ||
+			!__dvpMapBufferWaitDVP ||
+			!__dvpMapBufferEndDVP ||
+			!__dvpMapBufferWaitAPI ||
+			!__dvpBindToGLCtx ||
+			!__dvpGetRequiredConstantsGLCtx ||
+			!__dvpCreateGPUTextureGL ||
+			!__dvpUnbindFromGLCtx)
+		   return DVP_STATUS_ERROR;
+		// check that the library version is what we want
+		if ((status = __dvpGetLibrayVersion(&__dvpMajorVersion, &__dvpMinorVersion)) != DVP_STATUS_OK)
+			return status;
+		if (__dvpMajorVersion != DVP_MAJOR_VERSION || __dvpMinorVersion < DVP_MINOR_VERSION)
+			return DVP_STATUS_ERROR;
+    }
+    return (!__dvpInitGLContext) ? DVP_STATUS_ERROR : __dvpInitGLContext(flags);
+}
+
+DVPStatus dvpCloseGLContext(void)
+{
+   return (!__dvpCloseGLContext) ? DVP_STATUS_

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list