Better fix for T38501: blender crashes right after adding image texture to
authorSv. Lockal <lockalsash@gmail.com>
Tue, 11 Feb 2014 13:39:55 +0000 (17:39 +0400)
committerSv. Lockal <lockalsash@gmail.com>
Tue, 11 Feb 2014 13:48:23 +0000 (17:48 +0400)
material in cycles

Buggy MSVC 2008 in 32-bit mode ignores stack align attribute for float3.
Now it uses reference to __m128, which is always aligned.

intern/cycles/kernel/svm/svm_image.h

index 6dd44303ac2ceb88193763f279f5d84fbc0cf1e8..bc76ea1e6622f52afc15fbe074f9f365f50bd600 100644 (file)
@@ -113,7 +113,13 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
 ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
 {
 #ifdef __KERNEL_CPU__
-       ccl_align(16) float4 r = kernel_tex_image_interp(id, x, y);
+#ifdef __KERNEL_SSE2__
+       __m128 r_m128;
+       float4 &r = (float4 &)r_m128;
+       r = kernel_tex_image_interp(id, x, y);
+#else
+       float4 r = kernel_tex_image_interp(id, x, y);
+#endif
 #else
        float4 r;
 
@@ -234,9 +240,9 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
 #endif
 
 #ifdef __KERNEL_SSE2__
-       __m128 &r_m128 = (__m128&)r;
-       if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
-               float alpha = r.w;
+       float alpha = r.w;
+
+       if(use_alpha && alpha != 1.0f && alpha != 0.0f) {
                r_m128 = _mm_div_ps(r_m128, _mm_set1_ps(alpha));
                if(id >= TEX_NUM_FLOAT_IMAGES)
                        r_m128 = _mm_min_ps(r_m128, _mm_set1_ps(1.0f));
@@ -244,7 +250,6 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
        }
 
        if(srgb) {
-               float alpha = r.w;
                r_m128 = color_srgb_to_scene_linear(r_m128);
                r.w = alpha;
        }