From bd44dcb63229a86e649d60561fb80f7ad6c3fd09 Mon Sep 17 00:00:00 2001 From: "Sv. Lockal" Date: Tue, 11 Feb 2014 17:39:55 +0400 Subject: Better fix for T38501: blender crashes right after adding image texture to 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 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'intern') diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index 6dd44303ac2..bc76ea1e662 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -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; } -- cgit v1.2.3