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
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2014-02-04 19:04:07 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-02-04 19:07:50 +0400
commit28e6d05e0952bf96eec0320231178c883e0b8079 (patch)
tree7dfda1019692f0402eb3e23d77b2ad494966cb2f /intern
parent30b5aef6789a2cf39020151b00410bd1d8f1c3d7 (diff)
Fix cycles crash with float image textures on CPU without AVX support.
The AVX kernel functions for reading image textures could be get used from non-AVX kernels. These are C++ class methods and need to be marked for inlining, all other functions are static so they don't leak into other kernels.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/kernel_compat_cpu.h18
-rw-r--r--intern/cycles/util/util_types.h6
2 files changed, 15 insertions, 9 deletions
diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index ce597a87315..b213e91274d 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -37,20 +37,20 @@ CCL_NAMESPACE_BEGIN
* pointer lookup. */
template<typename T> struct texture {
- T fetch(int index)
+ ccl_always_inline T fetch(int index)
{
kernel_assert(index >= 0 && index < width);
return data[index];
}
#if 0
- __m128 fetch_m128(int index)
+ ccl_always_inline __m128 fetch_m128(int index)
{
kernel_assert(index >= 0 && index < width);
return ((__m128*)data)[index];
}
- __m128i fetch_m128i(int index)
+ ccl_always_inline __m128i fetch_m128i(int index)
{
kernel_assert(index >= 0 && index < width);
return ((__m128i*)data)[index];
@@ -62,18 +62,18 @@ template<typename T> struct texture {
};
template<typename T> struct texture_image {
- float4 read(float4 r)
+ ccl_always_inline float4 read(float4 r)
{
return r;
}
- float4 read(uchar4 r)
+ ccl_always_inline float4 read(uchar4 r)
{
float f = 1.0f/255.0f;
return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
}
- int wrap_periodic(int x, int width)
+ ccl_always_inline int wrap_periodic(int x, int width)
{
x %= width;
if(x < 0)
@@ -81,19 +81,19 @@ template<typename T> struct texture_image {
return x;
}
- int wrap_clamp(int x, int width)
+ ccl_always_inline int wrap_clamp(int x, int width)
{
return clamp(x, 0, width-1);
}
- float frac(float x, int *ix)
+ ccl_always_inline float frac(float x, int *ix)
{
int i = float_to_int(x) - ((x < 0.0f)? 1: 0);
*ix = i;
return x - (float)i;
}
- float4 interp(float x, float y, bool periodic = true)
+ ccl_always_inline float4 interp(float x, float y, bool periodic = true)
{
if(!data)
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index 45038488c14..66aab766667 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -39,6 +39,7 @@
#define ccl_constant
#if defined(_WIN32) && !defined(FREE_WINDOWS)
+
#define ccl_device_inline static __forceinline
#ifdef __KERNEL_64_BIT__
#define ccl_align(...) __declspec(align(__VA_ARGS__))
@@ -46,13 +47,18 @@
#define ccl_align(...) /* not support for function arguments (error C2719) */
#endif
#define ccl_may_alias
+#define ccl_always_inline __forceinline
+
#else
+
#define ccl_device_inline static inline __attribute__((always_inline))
#ifndef FREE_WINDOWS64
#define __forceinline inline __attribute__((always_inline))
#endif
#define ccl_align(...) __attribute__((aligned(__VA_ARGS__)))
#define ccl_may_alias __attribute__((__may_alias__))
+#define ccl_always_inline __attribute__((always_inline))
+
#endif
#endif