diff options
author | Martijn Berger <martijn.berger@gmail.com> | 2015-03-29 23:12:22 +0300 |
---|---|---|
committer | Martijn Berger <martijn.berger@gmail.com> | 2015-03-29 23:12:40 +0300 |
commit | f01456aaa4a87cd76feaef50ec822340197f9eda (patch) | |
tree | 5e4147b31def6462158b2ecd269df55ea1679c53 /intern/cycles | |
parent | 70d9c013257906d3e894907b92e693d1ccebd7fd (diff) |
Optionally use c++11 stuff instead of boost in cycles where possible. We do and continue to depend on boost though
Reviewers: dingto, sergey
Reviewed By: sergey
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1185
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/CMakeLists.txt | 21 | ||||
-rw-r--r-- | intern/cycles/SConscript | 12 | ||||
-rw-r--r-- | intern/cycles/device/device.h | 4 | ||||
-rw-r--r-- | intern/cycles/device/device_task.h | 10 | ||||
-rw-r--r-- | intern/cycles/render/image.h | 6 | ||||
-rw-r--r-- | intern/cycles/render/session.h | 4 | ||||
-rw-r--r-- | intern/cycles/util/util_foreach.h | 8 | ||||
-rw-r--r-- | intern/cycles/util/util_function.h | 25 | ||||
-rw-r--r-- | intern/cycles/util/util_map.h | 27 | ||||
-rw-r--r-- | intern/cycles/util/util_progress.h | 8 | ||||
-rw-r--r-- | intern/cycles/util/util_set.h | 12 | ||||
-rw-r--r-- | intern/cycles/util/util_task.h | 2 | ||||
-rw-r--r-- | intern/cycles/util/util_thread.h | 21 |
13 files changed, 129 insertions, 31 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 2ba6af48d0d..c4cadfe0bf7 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -152,6 +152,27 @@ add_definitions( -DWITH_MULTI ) +TEST_UNORDERED_MAP_SUPPORT() +if(HAVE_STD_UNORDERED_MAP_HEADER) + if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) + add_definitions(-DCYCLES_STD_UNORDERED_MAP) + else() + if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) + add_definitions(-DCYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) + else() + add_definitions(-DCYCLES_NO_UNORDERED_MAP) + message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") + endif() + endif() +else() + if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) + add_definitions(-DCYCLES_TR1_UNORDERED_MAP) + else() + add_definitions(-DCYCLES_NO_UNORDERED_MAP) + message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") + endif() +endif() + # Logging capabilities using GLog library. if(WITH_CYCLES_LOGGING) add_definitions(-DWITH_CYCLES_LOGGING) diff --git a/intern/cycles/SConscript b/intern/cycles/SConscript index 9cbdb93ce85..79e14ab9a58 100644 --- a/intern/cycles/SConscript +++ b/intern/cycles/SConscript @@ -47,6 +47,18 @@ cxxflags = Split(env['CXXFLAGS']) defs += env['BF_GL_DEFINITIONS'] +if env['WITH_UNORDERED_MAP_SUPPORT']: + if env['UNORDERED_MAP_HEADER'] == 'unordered_map': + if env['UNORDERED_MAP_NAMESPACE'] == 'std': + defs.append('CYCLES_STD_UNORDERED_MAP') + elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1': + defs.append('CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE') + elif env['UNORDERED_MAP_NAMESPACE'] == 'std::tr1': + defs.append('CYCLES_TR1_UNORDERED_MAP') +else: + print("-- Replacing unordered_map/set with map/set (warning: slower!)") + defs.append('CYCLES_NO_UNORDERED_MAP') + defs.append('CCL_NAMESPACE_BEGIN=namespace ccl {') defs.append('CCL_NAMESPACE_END=}') diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 18fc707beab..7eb3f6c822b 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -72,8 +72,8 @@ public: /* Device */ struct DeviceDrawParams { - boost::function<void(void)> bind_display_space_shader_cb; - boost::function<void(void)> unbind_display_space_shader_cb; + function<void(void)> bind_display_space_shader_cb; + function<void(void)> unbind_display_space_shader_cb; }; class Device { diff --git a/intern/cycles/device/device_task.h b/intern/cycles/device/device_task.h index 84945bcf9a5..0c23d8971e0 100644 --- a/intern/cycles/device/device_task.h +++ b/intern/cycles/device/device_task.h @@ -57,11 +57,11 @@ public: void update_progress(RenderTile *rtile); - boost::function<bool(Device *device, RenderTile&)> acquire_tile; - boost::function<void(void)> update_progress_sample; - boost::function<void(RenderTile&)> update_tile_sample; - boost::function<void(RenderTile&)> release_tile; - boost::function<bool(void)> get_cancel; + function<bool(Device *device, RenderTile&)> acquire_tile; + function<void(void)> update_progress_sample; + function<void(RenderTile&)> update_tile_sample; + function<void(RenderTile&)> release_tile; + function<bool(void)> get_cancel; bool need_finish_queue; bool integrator_branched; diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index 2f5dcb6efd5..1045b4532e4 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -73,9 +73,9 @@ public: bool need_update; - boost::function<void(const string &filename, void *data, bool &is_float, int &width, int &height, int &depth, int &channels)> builtin_image_info_cb; - boost::function<bool(const string &filename, void *data, unsigned char *pixels)> builtin_image_pixels_cb; - boost::function<bool(const string &filename, void *data, float *pixels)> builtin_image_float_pixels_cb; + function<void(const string &filename, void *data, bool &is_float, int &width, int &height, int &depth, int &channels)> builtin_image_info_cb; + function<bool(const string &filename, void *data, unsigned char *pixels)> builtin_image_pixels_cb; + function<bool(const string &filename, void *data, float *pixels)> builtin_image_float_pixels_cb; struct Image { string filename; diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h index c77652d3722..8b108b0940f 100644 --- a/intern/cycles/render/session.h +++ b/intern/cycles/render/session.h @@ -125,8 +125,8 @@ public: TileManager tile_manager; Stats stats; - boost::function<void(RenderTile&)> write_render_tile_cb; - boost::function<void(RenderTile&)> update_render_tile_cb; + function<void(RenderTile&)> write_render_tile_cb; + function<void(RenderTile&)> update_render_tile_cb; Session(const SessionParams& params); ~Session(); diff --git a/intern/cycles/util/util_foreach.h b/intern/cycles/util/util_foreach.h index 065bd33ebd2..4f7337107b3 100644 --- a/intern/cycles/util/util_foreach.h +++ b/intern/cycles/util/util_foreach.h @@ -19,8 +19,12 @@ /* Use Boost to get nice foreach() loops for STL data structures. */ -#include <boost/foreach.hpp> -#define foreach BOOST_FOREACH +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +# define foreach(x, y) for(x : y) +#else +# include <boost/foreach.hpp> +# define foreach BOOST_FOREACH +#endif #endif /* __UTIL_FOREACH_H__ */ diff --git a/intern/cycles/util/util_function.h b/intern/cycles/util/util_function.h index 7a312efaad7..83c07ae06a8 100644 --- a/intern/cycles/util/util_function.h +++ b/intern/cycles/util/util_function.h @@ -17,14 +17,31 @@ #ifndef __UTIL_FUNCTION_H__ #define __UTIL_FUNCTION_H__ -#include <boost/bind.hpp> -#include <boost/function.hpp> +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +# include <functional> +#else +# include <boost/bind.hpp> +# include <boost/function.hpp> +#endif CCL_NAMESPACE_BEGIN +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +# define function_bind std::bind +using std::function; +using std::placeholders::_1; +using std::placeholders::_2; +using std::placeholders::_3; +using std::placeholders::_4; +using std::placeholders::_5; +using std::placeholders::_6; +using std::placeholders::_7; +using std::placeholders::_8; +using std::placeholders::_9; +#else using boost::function; -#define function_bind boost::bind - +# define function_bind boost::bind +#endif CCL_NAMESPACE_END #endif /* __UTIL_FUNCTION_H__ */ diff --git a/intern/cycles/util/util_map.h b/intern/cycles/util/util_map.h index 54d6a8d6424..46c2885f8b0 100644 --- a/intern/cycles/util/util_map.h +++ b/intern/cycles/util/util_map.h @@ -18,13 +18,38 @@ #define __UTIL_MAP_H__ #include <map> -#include <boost/tr1/unordered_map.hpp> + +#if defined(CYCLES_TR1_UNORDERED_MAP) +# include <tr1/unordered_map> +#endif + +#if defined(CYCLES_STD_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) +# include <unordered_map> +#endif + +#if !defined(CYCLES_NO_UNORDERED_MAP) && !defined(CYCLES_TR1_UNORDERED_MAP) && \ + !defined(CYCLES_STD_UNORDERED_MAP) && !defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) // NOLINT +# error One of: CYCLES_NO_UNORDERED_MAP, CYCLES_TR1_UNORDERED_MAP,\ + CYCLES_STD_UNORDERED_MAP, CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE must be defined! // NOLINT +#endif + CCL_NAMESPACE_BEGIN using std::map; using std::pair; + +#if defined(CYCLES_NO_UNORDERED_MAP) +typedef std::map unordered_map; +#endif + +#if defined(CYCLES_TR1_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) using std::tr1::unordered_map; +#endif + +#if defined(CYCLES_STD_UNORDERED_MAP) +using std::unordered_map; +#endif CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h index 0ff48630a81..963987487ed 100644 --- a/intern/cycles/util/util_progress.h +++ b/intern/cycles/util/util_progress.h @@ -110,7 +110,7 @@ public: return cancel_message; } - void set_cancel_callback(boost::function<void(void)> function) + void set_cancel_callback(function<void(void)> function) { cancel_cb = function; } @@ -275,7 +275,7 @@ public: } } - void set_update_callback(boost::function<void(void)> function) + void set_update_callback(function<void(void)> function) { update_cb = function; } @@ -283,8 +283,8 @@ public: protected: thread_mutex progress_mutex; thread_mutex update_mutex; - boost::function<void(void)> update_cb; - boost::function<void(void)> cancel_cb; + function<void(void)> update_cb; + function<void(void)> cancel_cb; int tile; /* counter for rendered tiles */ int sample; /* counter of rendered samples, global for all tiles */ diff --git a/intern/cycles/util/util_set.h b/intern/cycles/util/util_set.h index 73a2bf19899..b3cb8dd8af5 100644 --- a/intern/cycles/util/util_set.h +++ b/intern/cycles/util/util_set.h @@ -18,13 +18,19 @@ #define __UTIL_SET_H__ #include <set> -#include <boost/tr1/unordered_set.hpp> - +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +# include <unordered_set> +#else +# include <boost/tr1/unordered_set.hpp> +#endif CCL_NAMESPACE_BEGIN using std::set; +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +using std::unordered_set; +#else using std::tr1::unordered_set; - +#endif CCL_NAMESPACE_END #endif /* __UTIL_SET_H__ */ diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index 8fac12e9987..debcff3b776 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -27,7 +27,7 @@ class Task; class TaskPool; class TaskScheduler; -typedef boost::function<void(void)> TaskRunFunction; +typedef function<void(void)> TaskRunFunction; /* Task * diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h index fbbb9b42e31..9c19235d41d 100644 --- a/intern/cycles/util/util_thread.h +++ b/intern/cycles/util/util_thread.h @@ -17,7 +17,14 @@ #ifndef __UTIL_THREAD_H__ #define __UTIL_THREAD_H__ -#include <boost/thread.hpp> +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +# include <thread> +# include <mutex> +# include <condition_variable> +# include <functional> +#else +# include <boost/thread.hpp> +#endif #include <pthread.h> #include <queue> @@ -25,18 +32,24 @@ CCL_NAMESPACE_BEGIN +#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) +typedef std::mutex thread_mutex; +typedef std::unique_lock<std::mutex> thread_scoped_lock; +typedef std::condition_variable thread_condition_variable; +#else /* use boost for mutexes */ - typedef boost::mutex thread_mutex; typedef boost::mutex::scoped_lock thread_scoped_lock; typedef boost::condition_variable thread_condition_variable; +#endif /* own pthread based implementation, to avoid boost version conflicts with * dynamically loaded blender plugins */ class thread { public: - thread(boost::function<void(void)> run_cb_) + thread(function<void(void)> run_cb_) + { joined = false; run_cb = run_cb_; @@ -63,7 +76,7 @@ public: } protected: - boost::function<void(void)> run_cb; + function<void(void)> run_cb; pthread_t pthread_id; bool joined; }; |