[Bf-blender-cvs] [77b7e1f] master: Deduplicate CUDA and OpenCL wranglers

Sergey Sharybin noreply at git.blender.org
Tue Aug 5 09:58:55 CEST 2014


Commit: 77b7e1fe9abb882b7bd1d60f5273e03f079d8a54
Author: Sergey Sharybin
Date:   Tue Aug 5 13:57:50 2014 +0600
Branches: master
https://developer.blender.org/rB77b7e1fe9abb882b7bd1d60f5273e03f079d8a54

Deduplicate CUDA and OpenCL wranglers

For now it was mainly about OpenCL wrangler being duplicated
between Cycles and Compositor, but with OpenSubdiv work those
wranglers were gonna to be duplicated just once again.

This commit makes it so Cycles and Compositor uses wranglers
from this repositories:

  - https://github.com/CudaWrangler/cuew
  - https://github.com/OpenCLWrangler/clew

This repositories are based on the wranglers we used before
and they'll be likely continued maintaining by us plus some
more players in the market.

Pretty much straightforward change with some tricks in the
CMake/SCons to make this libs being passed to the linker
after all other libraries in order to make OpenSubdiv linked
against those wranglers in the future.

For those who're worrying about Cycles being less standalone,
it's not truth, it's rather more flexible now and in the future
different wranglers might be used in Cycles. For now it'll
just mean those libs would need to be put into Cycles repository
together with some other libs from Blender such as mikkspace.

This is mainly platform maintenance commit, should not be any
changes to the user space.

Reviewers: juicyfruit, dingto, campbellbarton

Reviewed By: juicyfruit, dingto, campbellbarton

Differential Revision: https://developer.blender.org/D707

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

M	SConstruct
M	build_files/cmake/macros.cmake
M	extern/CMakeLists.txt
M	extern/SConscript
A	extern/clew/CMakeLists.txt
A	extern/clew/SConscript
A	extern/clew/include/clew.h
A	extern/clew/src/clew.c
A	extern/cuew/CMakeLists.txt
A	extern/cuew/LICENSE
A	extern/cuew/README
A	extern/cuew/SConscript
A	extern/cuew/auto/cuda_errors.py
A	extern/cuew/auto/cuda_extra.py
A	extern/cuew/auto/cuew_gen.py
A	extern/cuew/auto/cuew_gen.sh
A	extern/cuew/auto/stdlib.h
A	extern/cuew/include/cuew.h
A	extern/cuew/src/cuew.c
M	intern/CMakeLists.txt
M	intern/SConscript
M	intern/cycles/SConscript
M	intern/cycles/app/CMakeLists.txt
M	intern/cycles/device/CMakeLists.txt
M	intern/cycles/device/device.cpp
M	intern/cycles/device/device_cuda.cpp
M	intern/cycles/device/device_intern.h
M	intern/cycles/device/device_opencl.cpp
M	intern/cycles/util/CMakeLists.txt
D	intern/cycles/util/util_cuda.cpp
D	intern/cycles/util/util_cuda.h
D	intern/cycles/util/util_opencl.cpp
D	intern/cycles/util/util_opencl.h
D	intern/opencl/CMakeLists.txt
D	intern/opencl/OCL_opencl.h
D	intern/opencl/SConscript
D	intern/opencl/intern/OCL_opencl.c
D	intern/opencl/intern/clew.c
D	intern/opencl/intern/clew.h
M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/SConscript
M	source/blender/compositor/intern/COM_NodeOperation.h
M	source/blender/compositor/intern/COM_OpenCLDevice.cpp
M	source/blender/compositor/intern/COM_OpenCLDevice.h
M	source/blender/compositor/intern/COM_WorkScheduler.cpp
M	source/blender/compositor/intern/COM_compositor.cpp
M	source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
M	source/blenderplayer/CMakeLists.txt

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

diff --git a/SConstruct b/SConstruct
index 7c874fb..329f51f 100644
--- a/SConstruct
+++ b/SConstruct
@@ -70,7 +70,7 @@ quickdebug = None
 
 ##### BEGIN SETUP #####
 
-B.possible_types = ['core', 'player', 'player2', 'intern', 'extern']
+B.possible_types = ['core', 'player', 'player2', 'intern', 'extern', 'system']
 
 B.binarykind = ['blender' , 'blenderplayer']
 ##################################
@@ -815,7 +815,7 @@ SConscript(B.root_build_dir+'/extern/SConscript')
 # libraries to give as objects to linking phase
 mainlist = []
 for tp in B.possible_types:
-    if (not tp == 'player') and (not tp == 'player2'):
+    if (not tp == 'player') and (not tp == 'player2') and (not tp == 'system'):
         mainlist += B.create_blender_liblist(env, tp)
 
 if B.arguments.get('BF_PRIORITYLIST', '0')=='1':
@@ -826,6 +826,11 @@ creob = B.creator(env)
 thestatlibs, thelibincs = B.setup_staticlibs(env)
 thesyslibs = B.setup_syslibs(env)
 
+# Hack to pass OSD libraries to linker before extern_{clew,cuew}
+for x in B.create_blender_liblist(env, 'system'):
+    thesyslibs.append(os.path.basename(x))
+    thelibincs.append(os.path.dirname(x))
+
 if 'blender' in B.targets or not env['WITH_BF_NOBLENDER']:
     env.BlenderProg(B.root_build_dir, "blender", creob + mainlist + thestatlibs + dobj, thesyslibs, [B.root_build_dir+'/lib'] + thelibincs, 'blender')
 if env['WITH_BF_PLAYER']:
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index f896fb9..9f7779e 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -411,6 +411,12 @@ macro(setup_liblinks
 	endif()
 
 	target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS})
+
+	# We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
+	if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
+		target_link_libraries(blender "extern_clew")
+		target_link_libraries(blender "extern_cuew")
+	endif()
 endmacro()
 
 macro(SETUP_BLENDER_SORTED_LIBS)
diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index eda5b5b..8d85551 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -70,6 +70,11 @@ if(WITH_LZMA)
 	add_subdirectory(lzma)
 endif()
 
+if(WITH_CYCLES OR WITH_COMPOSITOR)
+	add_subdirectory(clew)
+	add_subdirectory(cuew)
+endif()
+
 if(WITH_MOD_BOOLEAN)
 	add_subdirectory(carve)
 endif()
diff --git a/extern/SConscript b/extern/SConscript
index 041aa34..714dfd2 100644
--- a/extern/SConscript
+++ b/extern/SConscript
@@ -20,6 +20,10 @@ if env['WITH_BF_ELTOPO']:
 if env['WITH_BF_BULLET']:
     SConscript(['bullet2/src/SConscript'])
 
+if env['WITH_BF_COMPOSITOR'] or env['WITH_BF_CYCLES']:
+    SConscript (['clew/SConscript'])
+    SConscript (['cuew/SConscript'])
+
 if env['WITH_BF_OPENJPEG'] and env['BF_OPENJPEG_LIB'] == '':
     SConscript(['libopenjpeg/SConscript'])
 
diff --git a/intern/opencl/CMakeLists.txt b/extern/clew/CMakeLists.txt
similarity index 86%
copy from intern/opencl/CMakeLists.txt
copy to extern/clew/CMakeLists.txt
index 03855cf..f75e933 100644
--- a/intern/opencl/CMakeLists.txt
+++ b/extern/clew/CMakeLists.txt
@@ -25,6 +25,7 @@
 
 set(INC
 	.
+	include
 )
 
 set(INC_SYS
@@ -32,11 +33,10 @@ set(INC_SYS
 )
 
 set(SRC
-	OCL_opencl.h
-	intern/clew.h
-	intern/clew.c
-	intern/OCL_opencl.c
+	include/clew.h
+	src/clew.c
 )
 
+add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS)
 
-blender_add_lib(bf_intern_opencl "${SRC}" "${INC}" "${INC_SYS}")
+blender_add_lib(extern_clew "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/opencl/SConscript b/extern/clew/SConscript
similarity index 83%
copy from intern/opencl/SConscript
copy to extern/clew/SConscript
index 41a6d72..14a03c7 100644
--- a/intern/opencl/SConscript
+++ b/extern/clew/SConscript
@@ -27,8 +27,9 @@
 
 Import ('env')
 
-sources = env.Glob('intern/*.c')
+sources = env.Glob('src/clew.c')
 
-incs = '.'
+incs = 'include'
+defs = ['CL_USE_DEPRECATED_OPENCL_1_1_APIS']
 
-env.BlenderLib ( 'bf_intern_opencl', sources, Split(incs), libtype=['core','player'], priority = [192,192] )
+env.BlenderLib ('extern_clew', sources, Split(incs), defines=defs, libtype=['system'], priority = [999])
diff --git a/extern/clew/include/clew.h b/extern/clew/include/clew.h
new file mode 100644
index 0000000..624fdb2
--- /dev/null
+++ b/extern/clew/include/clew.h
@@ -0,0 +1,2759 @@
+#ifndef CLEW_HPP_INCLUDED
+#define CLEW_HPP_INCLUDED
+
+//////////////////////////////////////////////////////////////////////////
+//  Copyright (c) 2009-2011 Organic Vectory B.V., KindDragon
+//  Written by George van Venrooij
+//
+//  Distributed under the MIT License.
+//////////////////////////////////////////////////////////////////////////
+
+//! \file clew.h
+//! \brief OpenCL run-time loader header
+//!
+//! This file contains a copy of the contents of CL.H and CL_PLATFORM.H from the 
+//! official OpenCL spec. The purpose of this code is to load the OpenCL dynamic
+//! library at run-time and thus allow the executable to function on many
+//! platforms regardless of the vendor of the OpenCL driver actually installed.
+//! Some of the techniques used here were inspired by work done in the GLEW
+//! library (http://glew.sourceforge.net/)
+
+//  Run-time dynamic linking functionality based on concepts used in GLEW
+#ifdef  __OPENCL_CL_H
+#error cl.h included before clew.h
+#endif
+
+#ifdef  __OPENCL_CL_PLATFORM_H
+#error cl_platform.h included before clew.h
+#endif
+
+//  Prevent cl.h inclusion
+#define __OPENCL_CL_H
+//  Prevent cl_platform.h inclusion
+#define __CL_PLATFORM_H
+
+/*******************************************************************************
+* Copyright (c) 2008-2010 The Khronos Group Inc.
+*
+* Permission is hereby granted, free of charge, to any person obtaining a
+* copy of this software and/or associated documentation files (the
+* "Materials"), to deal in the Materials without restriction, including
+* without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Materials, and to
+* permit persons to whom the Materials are furnished to do so, subject to
+* the following conditions:
+*
+* The above copyright notice and this permission notice shall be included
+* in all copies or substantial portions of the Materials.
+*
+* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+******************************************************************************/
+#ifdef __APPLE__
+    /* Contains #defines for AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER below */
+    #include <AvailabilityMacros.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32)
+    #define CL_API_ENTRY
+    #define CL_API_CALL     __stdcall
+    #define CL_CALLBACK     __stdcall
+#else
+    #define CL_API_ENTRY
+    #define CL_API_CALL
+    #define CL_CALLBACK
+#endif
+
+#ifdef __APPLE__
+    #define CL_EXTENSION_WEAK_LINK                  __attribute__((weak_import))       
+    #define CL_API_SUFFIX__VERSION_1_0              AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+    #define CL_EXT_SUFFIX__VERSION_1_0              CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+    #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED   CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+	#define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED   CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
+	#define CL_API_SUFFIX__VERSION_1_1              CL_EXTENSION_WEAK_LINK
+	#define CL_EXT_SUFFIX__VERSION_1_1              CL_EXTENSION_WEAK_LINK
+	#define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED   CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+	#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED   CL_EXTENSION_WEAK_LINK AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
+	#define CL_API_SUFFIX__VERSION_1_2              CL_EXTENSION_WEAK_LINK
+	#define CL_EXT_SUFFIX__VERSION_1_2              CL_EXTENSION_WEAK_LINK
+#else
+    #define CL_EXTENSION_WEAK_LINK
+    #define CL_API_SUFFIX__VERSION_1_0
+    #define CL_EXT_SUFFIX__VERSION_1_0
+    #define CL_API_SUFFIX__VERSION_1_1
+    #define CL_EXT_SUFFIX__VERSION_1_1
+    #define CL_API_SUFFIX__VERSION_1_2
+    #define CL_EXT_SUFFIX__VERSION_1_2
+
+    #if defined(__GNUC__)
+        #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
+            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+        #else
+            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED __attribute__((deprecated))
+            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+        #endif
+
+        #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
+            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+        #else
+            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED __attribute__((deprecated))
+            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+        #endif
+    #elif defined(_WIN32)
+        #ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
+            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+        #else
+            #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+            #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED __declspec(deprecated)
+        #endif
+
+        #ifdef CL_USE_DEPRECATED_OPENCL_1_1_APIS
+            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED
+        #else
+            #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+            #define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED __declspec(deprecated)
+        #endif
+    #else
+        #define CL_EXT_SUFFIX__VERSION_1_0_DEPRECATED
+        #define CL_EXT_PREFIX__VERSION_1_0_DEPRECATED
+
+        #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
+        #define CL_EXT_PREFIX__VERSIO

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list