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.
This commit is contained in:
Sv. Lockal
2014-02-11 17:39:55 +04:00
parent 0a50757a59
commit bd44dcb632

View 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) ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
{ {
#ifdef __KERNEL_CPU__ #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 #else
float4 r; float4 r;
@@ -234,9 +240,9 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
#endif #endif
#ifdef __KERNEL_SSE2__ #ifdef __KERNEL_SSE2__
__m128 &r_m128 = (__m128&)r; float alpha = r.w;
if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
float alpha = r.w; if(use_alpha && alpha != 1.0f && alpha != 0.0f) {
r_m128 = _mm_div_ps(r_m128, _mm_set1_ps(alpha)); r_m128 = _mm_div_ps(r_m128, _mm_set1_ps(alpha));
if(id >= TEX_NUM_FLOAT_IMAGES) if(id >= TEX_NUM_FLOAT_IMAGES)
r_m128 = _mm_min_ps(r_m128, _mm_set1_ps(1.0f)); 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) { if(srgb) {
float alpha = r.w;
r_m128 = color_srgb_to_scene_linear(r_m128); r_m128 = color_srgb_to_scene_linear(r_m128);
r.w = alpha; r.w = alpha;
} }