Commit: 28e6d05e0952bf96eec0320231178c883e0b8079
Author: Brecht Van Lommel
Date:   Tue Feb 4 16:04:07 2014 +0100
https://developer.blender.org/rB28e6d05e0952bf96eec0320231178c883e0b8079

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.

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

M       intern/cycles/kernel/kernel_compat_cpu.h
M       intern/cycles/util/util_types.h

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

diff --git a/intern/cycles/kernel/kernel_compat_cpu.h 
b/intern/cycles/kernel/kernel_compat_cpu.h
index ce597a8..b213e91 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 4503848..66aab76 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

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to