diff options
author | Sv. Lockal <lockalsash@gmail.com> | 2014-02-10 17:19:26 +0400 |
---|---|---|
committer | Sv. Lockal <lockalsash@gmail.com> | 2014-02-10 17:19:26 +0400 |
commit | 7096529704989286f30d645fae54e40c8335ec5e (patch) | |
tree | 852c89a45ea6c75e49fc16f1b7b191bacd03649c /intern | |
parent | 2f01be2b2fe563f634c9f653260940b2a9a78d6d (diff) |
Fix T38501: blender crashes right after adding image texture to material
in cycles
Also fix very similar problem in half-float SSE conversion.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/kernel_film.h | 16 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_image.h | 27 |
2 files changed, 19 insertions, 24 deletions
diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h index b4118666491..cbd875e994c 100644 --- a/intern/cycles/kernel/kernel_film.h +++ b/intern/cycles/kernel/kernel_film.h @@ -75,17 +75,15 @@ ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg, float exposure = kernel_data.film.exposure; - if(exposure == 1.0f) { - float4_store_half(out, in, sample_scale); - } - else { - float4 rgba = *in; - rgba.x *= exposure; - rgba.y *= exposure; - rgba.z *= exposure; + ccl_align(16) float4 rgba_in = *in; - float4_store_half(out, &rgba, sample_scale); + if(exposure != 1.0f) { + rgba_in.x *= exposure; + rgba_in.y *= exposure; + rgba_in.z *= exposure; } + + float4_store_half(out, &rgba_in, sample_scale); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h index 2687e03e843..6dd44303ac2 100644 --- a/intern/cycles/kernel/svm/svm_image.h +++ b/intern/cycles/kernel/svm/svm_image.h @@ -112,10 +112,8 @@ 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) { -#if defined(__KERNEL_CPU__) && defined(__KERNEL_SSE2__) - union { float4 rgba; __m128 m128; } r = { kernel_tex_image_interp(id, x, y) }; -#elif defined(__KERNEL_CPU__) - float4 r = kernel_tex_image_interp(id, x, y); +#ifdef __KERNEL_CPU__ + ccl_align(16) float4 r = kernel_tex_image_interp(id, x, y); #else float4 r; @@ -236,21 +234,20 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, #endif #ifdef __KERNEL_SSE2__ - if(use_alpha && r.rgba.w != 1.0f && r.rgba.w != 0.0f) { - float alpha = r.rgba.w; - r.m128 = _mm_div_ps(r.m128, _mm_set1_ps(alpha)); + __m128 &r_m128 = (__m128&)r; + if(use_alpha && r.w != 1.0f && r.w != 0.0f) { + float alpha = r.w; + 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)); - r.rgba.w = alpha; + r_m128 = _mm_min_ps(r_m128, _mm_set1_ps(1.0f)); + r.w = alpha; } if(srgb) { - float alpha = r.rgba.w; - r.m128 = color_srgb_to_scene_linear(r.m128); - r.rgba.w = alpha; + float alpha = r.w; + r_m128 = color_srgb_to_scene_linear(r_m128); + r.w = alpha; } - - return r.rgba; #else if(use_alpha && r.w != 1.0f && r.w != 0.0f) { float invw = 1.0f/r.w; @@ -270,9 +267,9 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, r.y = color_srgb_to_scene_linear(r.y); r.z = color_srgb_to_scene_linear(r.z); } +#endif return r; -#endif } #endif |