Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_aligned_malloc.cpp2
-rw-r--r--intern/cycles/util/util_atomic.h36
-rw-r--r--intern/cycles/util/util_cache.h2
-rw-r--r--intern/cycles/util/util_foreach.h8
-rw-r--r--intern/cycles/util/util_function.h27
-rw-r--r--intern/cycles/util/util_guarded_allocator.h1
-rw-r--r--intern/cycles/util/util_half.h30
-rw-r--r--intern/cycles/util/util_hash.h2
-rw-r--r--intern/cycles/util/util_map.h27
-rw-r--r--intern/cycles/util/util_math.h13
-rw-r--r--intern/cycles/util/util_math_fast.h10
-rw-r--r--intern/cycles/util/util_optimization.h23
-rw-r--r--intern/cycles/util/util_progress.h12
-rw-r--r--intern/cycles/util/util_set.h12
-rw-r--r--intern/cycles/util/util_simd.h6
-rw-r--r--intern/cycles/util/util_string.cpp17
-rw-r--r--intern/cycles/util/util_string.h2
-rw-r--r--intern/cycles/util/util_system.cpp19
-rw-r--r--intern/cycles/util/util_task.cpp2
-rw-r--r--intern/cycles/util/util_task.h2
-rw-r--r--intern/cycles/util/util_thread.h21
-rw-r--r--intern/cycles/util/util_time.cpp2
-rw-r--r--intern/cycles/util/util_transform.cpp16
-rw-r--r--intern/cycles/util/util_transform.h34
-rw-r--r--intern/cycles/util/util_types.h18
-rw-r--r--intern/cycles/util/util_view.cpp3
26 files changed, 254 insertions, 93 deletions
diff --git a/intern/cycles/util/util_aligned_malloc.cpp b/intern/cycles/util/util_aligned_malloc.cpp
index 9ff857e3543..b161a55c15e 100644
--- a/intern/cycles/util/util_aligned_malloc.cpp
+++ b/intern/cycles/util/util_aligned_malloc.cpp
@@ -55,7 +55,7 @@ void *util_aligned_malloc(size_t size, int alignment)
return malloc(size);
#elif defined(__FreeBSD__) || defined(__NetBSD__)
void *result;
- if (posix_memalign(&result, alignment, size)) {
+ if(posix_memalign(&result, alignment, size)) {
/* Non-zero means allocation error
* either no allocation or bad alignment value.
*/
diff --git a/intern/cycles/util/util_atomic.h b/intern/cycles/util/util_atomic.h
index 7bbd97b8667..1d1e2963348 100644
--- a/intern/cycles/util/util_atomic.h
+++ b/intern/cycles/util/util_atomic.h
@@ -17,17 +17,49 @@
#ifndef __UTIL_ATOMIC_H__
#define __UTIL_ATOMIC_H__
+#ifndef __KERNEL_GPU__
+
/* Using atomic ops header from Blender. */
#include "atomic_ops.h"
ATOMIC_INLINE void atomic_update_max_z(size_t *maximum_value, size_t value)
{
size_t prev_value = *maximum_value;
- while (prev_value < value) {
- if (atomic_cas_z(maximum_value, prev_value, value) != prev_value) {
+ while(prev_value < value) {
+ if(atomic_cas_z(maximum_value, prev_value, value) != prev_value) {
break;
}
}
}
+#else /* __KERNEL_GPU__ */
+
+#ifdef __KERNEL_OPENCL__
+
+/* Float atomics implementation credits:
+ * http://suhorukov.blogspot.in/2011/12/opencl-11-atomic-operations-on-floating.html
+ */
+ccl_device_inline void atomic_add_float(volatile ccl_global float *source,
+ const float operand)
+{
+ union {
+ unsigned int int_value;
+ float float_value;
+ } new_value;
+ union {
+ unsigned int int_value;
+ float float_value;
+ } prev_value;
+ do {
+ prev_value.float_value = *source;
+ new_value.float_value = prev_value.float_value + operand;
+ } while(atomic_cmpxchg((volatile ccl_global unsigned int *)source,
+ prev_value.int_value,
+ new_value.int_value) != prev_value.int_value);
+}
+
+#endif /* __KERNEL_OPENCL__ */
+
+#endif /* __KERNEL_GPU__ */
+
#endif /* __UTIL_ATOMIC_H__ */
diff --git a/intern/cycles/util/util_cache.h b/intern/cycles/util/util_cache.h
index 9d001a6f1ff..343fa36817d 100644
--- a/intern/cycles/util/util_cache.h
+++ b/intern/cycles/util/util_cache.h
@@ -105,7 +105,7 @@ public:
return false;
}
- if(!size)
+ if((size == 0) || (size % sizeof(T)) != 0)
return false;
data.resize(size/sizeof(T));
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..6d0f0b444a9 100644
--- a/intern/cycles/util/util_function.h
+++ b/intern/cycles/util/util_function.h
@@ -17,14 +17,33 @@
#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
+# define function_null nullptr
+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
+# define function_null NULL
+#endif
CCL_NAMESPACE_END
#endif /* __UTIL_FUNCTION_H__ */
diff --git a/intern/cycles/util/util_guarded_allocator.h b/intern/cycles/util/util_guarded_allocator.h
index 263199417c4..c4edb172eb8 100644
--- a/intern/cycles/util/util_guarded_allocator.h
+++ b/intern/cycles/util/util_guarded_allocator.h
@@ -53,6 +53,7 @@ public:
{
util_guarded_mem_alloc(n * sizeof(T));
#ifdef WITH_BLENDER_GUARDEDALLOC
+ (void)hint;
return (T*)MEM_mallocN(n * sizeof(T), "Cycles Alloc");
#else
return std::allocator<T>::allocate(n, hint);
diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h
index 76941569bd2..f4bac9888a5 100644
--- a/intern/cycles/util/util_half.h
+++ b/intern/cycles/util/util_half.h
@@ -56,7 +56,7 @@ ccl_device_inline void float4_store_half(half *h, float4 f, float scale)
* assumes no negative, no nan, no inf, and sets denormal to 0 */
union { uint i; float f; } in;
float fscale = f[i] * scale;
- in.f = (fscale > 0.0f)? ((fscale < 65500.0f)? fscale: 65500.0f): 0.0f;
+ in.f = (fscale > 0.0f)? ((fscale < 65504.0f)? fscale: 65504.0f): 0.0f;
int x = in.i;
int absolute = x & 0x7FFFFFFF;
@@ -68,20 +68,20 @@ ccl_device_inline void float4_store_half(half *h, float4 f, float scale)
}
#else
/* same as above with SSE */
- const ssef mm_scale = ssef(scale);
- const ssei mm_38800000 = ssei(0x38800000);
- const ssei mm_7FFF = ssei(0x7FFF);
- const ssei mm_7FFFFFFF = ssei(0x7FFFFFFF);
- const ssei mm_C8000000 = ssei(0xC8000000);
-
- ssef mm_fscale = load4f(f) * mm_scale;
- ssei x = cast(min(max(mm_fscale, ssef(0.0f)), ssef(65500.0f)));
- ssei absolute = x & mm_7FFFFFFF;
- ssei Z = absolute + mm_C8000000;
- ssei result = andnot(absolute < mm_38800000, Z);
- ssei rh = (result >> 13) & mm_7FFF;
-
- _mm_storel_pi((__m64*)h, _mm_castsi128_ps(_mm_packs_epi32(rh, rh)));
+ ssef fscale = load4f(f) * scale;
+ ssef x = min(max(fscale, 0.0f), 65504.0f);
+
+#ifdef __KERNEL_AVX2__
+ ssei rpack = _mm_cvtps_ph(x, 0);
+#else
+ ssei absolute = cast(x) & 0x7FFFFFFF;
+ ssei Z = absolute + 0xC8000000;
+ ssei result = andnot(absolute < 0x38800000, Z);
+ ssei rshift = (result >> 13) & 0x7FFF;
+ ssei rpack = _mm_packs_epi32(rshift, rshift);
+#endif
+
+ _mm_storel_pi((__m64*)h, _mm_castsi128_ps(rpack));
#endif
}
diff --git a/intern/cycles/util/util_hash.h b/intern/cycles/util/util_hash.h
index bbbedc22a47..3ff2802b46d 100644
--- a/intern/cycles/util/util_hash.h
+++ b/intern/cycles/util/util_hash.h
@@ -53,7 +53,7 @@ static inline uint hash_string(const char *str)
{
uint i = 0, c;
- while ((c = *str++))
+ while((c = *str++))
i = i * 37 + c;
return i;
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_math.h b/intern/cycles/util/util_math.h
index a4d49681a38..2262f8fdbb7 100644
--- a/intern/cycles/util/util_math.h
+++ b/intern/cycles/util/util_math.h
@@ -175,6 +175,15 @@ ccl_device_inline float clamp(float a, float mn, float mx)
#endif
+#ifndef __KERNEL_CUDA__
+
+ccl_device_inline float saturate(float a)
+{
+ return clamp(a, 0.0f, 1.0f);
+}
+
+#endif
+
ccl_device_inline int float_to_int(float f)
{
return (int)f;
@@ -1461,9 +1470,9 @@ ccl_device_inline float2 map_to_tube(const float3 co)
{
float len, u, v;
len = sqrtf(co.x * co.x + co.y * co.y);
- if (len > 0.0f) {
+ if(len > 0.0f) {
u = (1.0f - (atan2f(co.x / len, co.y / len) / M_PI_F)) * 0.5f;
- v = (co.x + 1.0f) * 0.5f;
+ v = (co.z + 1.0f) * 0.5f;
}
else {
u = v = 0.0f;
diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h
index 4ad81e9c015..c1a1be603f4 100644
--- a/intern/cycles/util/util_math_fast.h
+++ b/intern/cycles/util/util_math_fast.h
@@ -360,7 +360,7 @@ ccl_device float fast_log2f(float x)
{
/* NOTE: clamp to avoid special cases and make result "safe" from large
* negative values/nans. */
- clamp(x, FLT_MIN, FLT_MAX);
+ x = clamp(x, FLT_MIN, FLT_MAX);
unsigned bits = __float_as_uint(x);
int exponent = (int)(bits >> 23) - 127;
float f = __uint_as_float((bits & 0x007FFFFF) | 0x3f800000) - 1.0f;
@@ -402,7 +402,7 @@ ccl_device float fast_logb(float x)
{
/* Don't bother with denormals. */
x = fabsf(x);
- clamp(x, FLT_MIN, FLT_MAX);
+ x = clamp(x, FLT_MIN, FLT_MAX);
unsigned bits = __float_as_uint(x);
return (int)(bits >> 23) - 127;
}
@@ -410,7 +410,7 @@ ccl_device float fast_logb(float x)
ccl_device float fast_exp2f(float x)
{
/* Clamp to safe range for final addition. */
- clamp(x, -126.0f, 126.0f);
+ x = clamp(x, -126.0f, 126.0f);
/* Range reduction. */
int m = (int)x; x -= m;
x = 1.0f - (1.0f - x); /* Crush denormals (does not affect max ulps!). */
@@ -539,7 +539,7 @@ ccl_device float fast_safe_powf(float x, float y)
* bsdf_microfaset.h.
*/
-ccl_device float fast_erff(float x)
+ccl_device_inline float fast_erff(float x)
{
/* Examined 1082130433 values of erff on [0,4]: 1.93715e-06 max error. */
/* Abramowitz and Stegun, 7.1.28. */
@@ -570,7 +570,7 @@ ccl_device_inline float fast_erfcf(float x)
return 1.0f - fast_erff(x);
}
-ccl_device float fast_ierff(float x)
+ccl_device_inline float fast_ierff(float x)
{
/* From: Approximating the erfinv function by Mike Giles. */
/* To avoid trouble at the limit, clamp input to 1-eps. */
diff --git a/intern/cycles/util/util_optimization.h b/intern/cycles/util/util_optimization.h
index b230bb1a627..c951c35fc76 100644
--- a/intern/cycles/util/util_optimization.h
+++ b/intern/cycles/util/util_optimization.h
@@ -102,28 +102,7 @@
#ifdef _MSC_VER
#include <intrin.h>
#else
-
-#ifdef __KERNEL_SSE2__
-#include <xmmintrin.h> /* SSE 1 */
-#include <emmintrin.h> /* SSE 2 */
-#endif
-
-#ifdef __KERNEL_SSE3__
-#include <pmmintrin.h> /* SSE 3 */
-#endif
-
-#ifdef __KERNEL_SSSE3__
-#include <tmmintrin.h> /* SSSE 3 */
-#endif
-
-#ifdef __KERNEL_SSE41__
-#include <smmintrin.h> /* SSE 4.1 */
-#endif
-
-#ifdef __KERNEL_AVX__
-#include <immintrin.h> /* AVX */
-#endif
-
+#include <x86intrin.h>
#endif
#else
diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h
index 0ff48630a81..13fce655734 100644
--- a/intern/cycles/util/util_progress.h
+++ b/intern/cycles/util/util_progress.h
@@ -44,12 +44,12 @@ public:
substatus = "";
sync_status = "";
sync_substatus = "";
- update_cb = NULL;
+ update_cb = function_null;
cancel = false;
cancel_message = "";
error = false;
error_message = "";
- cancel_cb = NULL;
+ cancel_cb = function_null;
}
Progress(Progress& progress)
@@ -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_simd.h b/intern/cycles/util/util_simd.h
index 625f26c1316..7c15199d4e1 100644
--- a/intern/cycles/util/util_simd.h
+++ b/intern/cycles/util/util_simd.h
@@ -133,7 +133,7 @@ __forceinline int clz(const int x)
#if defined(__KERNEL_AVX2__)
return _lzcnt_u32(x);
#else
- if (UNLIKELY(x == 0)) return 32;
+ if(UNLIKELY(x == 0)) return 32;
return 31 - __bsr(x);
#endif
}
@@ -286,7 +286,7 @@ __forceinline int clz(const int x)
#if defined(__KERNEL_AVX2__)
return _lzcnt_u32(x);
#else
- if (UNLIKELY(x == 0)) return 32;
+ if(UNLIKELY(x == 0)) return 32;
return 31 - __bsr(x);
#endif
}
@@ -358,7 +358,7 @@ __forceinline __m128i _mm_mullo_epi32( __m128i value, __m128i input ) {
char* _r = (char*)(&rvalue + 1);
char* _v = (char*)(& value + 1);
char* _i = (char*)(& input + 1);
- for ( ssize_t i = -16 ; i != 0 ; i += 4 ) *((int32*)(_r + i)) = *((int32*)(_v + i))* *((int32*)(_i + i));
+ for( ssize_t i = -16 ; i != 0 ; i += 4 ) *((int32*)(_r + i)) = *((int32*)(_v + i))* *((int32*)(_i + i));
return rvalue;
}
diff --git a/intern/cycles/util/util_string.cpp b/intern/cycles/util/util_string.cpp
index 8675ff3679d..66856dd8331 100644
--- a/intern/cycles/util/util_string.cpp
+++ b/intern/cycles/util/util_string.cpp
@@ -105,5 +105,22 @@ string string_strip(const string& s)
}
+void string_replace(string& haystack, const string& needle, const string& other)
+{
+ size_t i;
+
+ while((i = haystack.find(needle)) != string::npos)
+ haystack.replace(i, needle.length(), other);
+}
+
+string string_remove_trademark(const string &s)
+{
+ string result = s;
+ string_replace(result, "(TM)", "");
+ string_replace(result, "(R)", "");
+
+ return string_strip(result);
+}
+
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_string.h b/intern/cycles/util/util_string.h
index fa1671fd1ee..6cb8d8df1e1 100644
--- a/intern/cycles/util/util_string.h
+++ b/intern/cycles/util/util_string.h
@@ -40,8 +40,10 @@ string string_printf(const char *format, ...) PRINTF_ATTRIBUTE;
bool string_iequals(const string& a, const string& b);
void string_split(vector<string>& tokens, const string& str, const string& separators = "\t ");
+void string_replace(string& haystack, const string& needle, const string& other);
bool string_endswith(const string& s, const char *end);
string string_strip(const string& s);
+string string_remove_trademark(const string& s);
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp
index 7206455debd..cc88320b68e 100644
--- a/intern/cycles/util/util_system.cpp
+++ b/intern/cycles/util/util_system.cpp
@@ -16,6 +16,7 @@
#include "util_system.h"
#include "util_types.h"
+#include "util_string.h"
#ifdef _WIN32
#if(!defined(FREE_WINDOWS))
@@ -75,14 +76,6 @@ static void __cpuid(int data[4], int selector)
}
#endif
-static void replace_string(string& haystack, const string& needle, const string& other)
-{
- size_t i;
-
- while((i = haystack.find(needle)) != string::npos)
- haystack.replace(i, needle.length(), other);
-}
-
string system_cpu_brand_string()
{
char buf[48];
@@ -98,10 +91,7 @@ string system_cpu_brand_string()
string brand = buf;
/* make it a bit more presentable */
- replace_string(brand, "(TM)", "");
- replace_string(brand, "(R)", "");
-
- brand = string_strip(brand);
+ brand = string_remove_trademark(brand);
return brand;
}
@@ -127,6 +117,7 @@ struct CPUCapabilities {
bool sse42;
bool sse4a;
bool avx;
+ bool f16c;
bool avx2;
bool xop;
bool fma3;
@@ -202,6 +193,8 @@ static CPUCapabilities& system_cpu_capabilities()
caps.avx = (xcr_feature_mask & 0x6) == 0x6;
}
+ caps.f16c = (result[2] & ((int)1 << 29)) != 0;
+
__cpuid(result, 0x00000007);
caps.bmi1 = (result[1] & ((int)1 << 3)) != 0;
caps.bmi2 = (result[1] & ((int)1 << 8)) != 0;
@@ -242,7 +235,7 @@ bool system_cpu_support_avx()
bool system_cpu_support_avx2()
{
CPUCapabilities& caps = system_cpu_capabilities();
- return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3 && caps.sse41 && caps.avx && caps.avx2 && caps.fma3 && caps.bmi1 && caps.bmi2;
+ return caps.sse && caps.sse2 && caps.sse3 && caps.ssse3 && caps.sse41 && caps.avx && caps.f16c && caps.avx2 && caps.fma3 && caps.bmi1 && caps.bmi2;
}
#else
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index e43b26ddfe2..d56553d1d4a 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -237,7 +237,7 @@ bool TaskScheduler::thread_wait_pop(Entry& entry)
return true;
}
-void TaskScheduler::thread_run(int thread_id)
+void TaskScheduler::thread_run(int /*thread_id*/)
{
Entry entry;
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;
};
diff --git a/intern/cycles/util/util_time.cpp b/intern/cycles/util/util_time.cpp
index 9668b0f9882..964f9f1a7af 100644
--- a/intern/cycles/util/util_time.cpp
+++ b/intern/cycles/util/util_time.cpp
@@ -71,7 +71,7 @@ void time_sleep(double t)
/* get microseconds */
int us = (int)(t * 1e6);
- if (us > 0)
+ if(us > 0)
usleep(us);
}
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index 0a1c09ae3d5..acaca69464c 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -46,9 +46,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "util_math.h"
#include "util_transform.h"
+#include "util_boundbox.h"
+#include "util_math.h"
+
CCL_NAMESPACE_BEGIN
/* Transform Inverse */
@@ -271,5 +273,15 @@ void transform_motion_decompose(DecompMotionTransform *decomp, const MotionTrans
decomp->post_y = post.y;
}
-CCL_NAMESPACE_END
+Transform transform_from_viewplane(BoundBox2D& viewplane)
+{
+ return
+ transform_scale(1.0f / (viewplane.right - viewplane.left),
+ 1.0f / (viewplane.top - viewplane.bottom),
+ 1.0f) *
+ transform_translate(-viewplane.left,
+ -viewplane.bottom,
+ 0.0f);
+}
+CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h
index ac97fa53084..0b87db0a379 100644
--- a/intern/cycles/util/util_transform.h
+++ b/intern/cycles/util/util_transform.h
@@ -449,6 +449,8 @@ ccl_device void transform_motion_interpolate(Transform *tfm, const DecompMotionT
#ifndef __KERNEL_GPU__
+class BoundBox2D;
+
ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransform& B)
{
return (A.pre == B.pre && A.post == B.post);
@@ -456,7 +458,39 @@ ccl_device_inline bool operator==(const MotionTransform& A, const MotionTransfor
float4 transform_to_quat(const Transform& tfm);
void transform_motion_decompose(DecompMotionTransform *decomp, const MotionTransform *motion, const Transform *mid);
+Transform transform_from_viewplane(BoundBox2D& viewplane);
+
+#endif
+
+/* TODO(sergey): This is only for until we've got OpenCL 2.0
+ * on all devices we consider supported. It'll be replaced with
+ * generic address space.
+ */
+#ifdef __KERNEL_OPENCL__
+
+#define OPENCL_TRANSFORM_ADDRSPACE_GLUE(a, b) a ## b
+#define OPENCL_TRANSFORM_ADDRSPACE_DECLARE(function) \
+ccl_device_inline float3 OPENCL_TRANSFORM_ADDRSPACE_GLUE(function, _addrspace)( \
+ ccl_addr_space const Transform *t, const float3 a) \
+{ \
+ Transform private_tfm = *t; \
+ return function(&private_tfm, a); \
+}
+
+OPENCL_TRANSFORM_ADDRSPACE_DECLARE(transform_point)
+OPENCL_TRANSFORM_ADDRSPACE_DECLARE(transform_direction)
+OPENCL_TRANSFORM_ADDRSPACE_DECLARE(transform_direction_transposed)
+
+# undef OPENCL_TRANSFORM_ADDRSPACE_DECLARE
+# undef OPENCL_TRANSFORM_ADDRSPACE_GLUE
+# define transform_point_auto transform_point_addrspace
+# define transform_direction_auto transform_direction_addrspace
+# define transform_direction_transposed_auto transform_direction_transposed_addrspace
+#else
+# define transform_point_auto transform_point
+# define transform_direction_auto transform_direction
+# define transform_direction_transposed_auto transform_direction_transposed
#endif
CCL_NAMESPACE_END
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index df61b6ead21..187675e74bf 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -481,18 +481,32 @@ enum InterpolationType {
# define UNLIKELY(x) (x)
#endif
+#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800))
+# define HAS_CPP11_FEATURES
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+# if defined(HAS_CPP11_FEATURES)
+/* Some magic to be sure we don't have reference in the type. */
+template<typename T> static inline T decltype_helper(T x) { return x; }
+# define TYPEOF(x) decltype(decltype_helper(x))
+# else
+# define TYPEOF(x) typeof(x)
+# endif
+#endif
+
/* Causes warning:
* incompatible types when assigning to type 'Foo' from type 'Bar'
* ... the compiler optimizes away the temp var */
#ifdef __GNUC__
#define CHECK_TYPE(var, type) { \
- typeof(var) *__tmp; \
+ TYPEOF(var) *__tmp; \
__tmp = (type *)NULL; \
(void)__tmp; \
} (void)0
#define CHECK_TYPE_PAIR(var_a, var_b) { \
- typeof(var_a) *__tmp; \
+ TYPEOF(var_a) *__tmp; \
__tmp = (typeof(var_b) *)NULL; \
(void)__tmp; \
} (void)0
diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp
index e77ebb2fe3e..9b5cd22fb4a 100644
--- a/intern/cycles/util/util_view.cpp
+++ b/intern/cycles/util/util_view.cpp
@@ -98,7 +98,7 @@ void view_display_help()
glColor3f(0.8f, 0.8f, 0.8f);
view_display_text(x1+20, y2-20, "Cycles Renderer");
- view_display_text(x1+20, y2-40, "(C) 2011-2014 Blender Foundation");
+ view_display_text(x1+20, y2-40, "(C) 2011-2015 Blender Foundation");
view_display_text(x1+20, y2-80, "Controls:");
view_display_text(x1+20, y2-100, "h: Info/Help");
view_display_text(x1+20, y2-120, "r: Reset");
@@ -110,6 +110,7 @@ void view_display_help()
view_display_text(x1+20, y2-230, "Left mouse: Move camera");
view_display_text(x1+20, y2-250, "Right mouse: Rotate camera");
view_display_text(x1+20, y2-270, "W/A/S/D: Move camera");
+ view_display_text(x1+20, y2-290, "0/1/2/3: Set max bounces");
glColor3f(1.0f, 1.0f, 1.0f);
}