Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSv. Lockal <lockalsash@gmail.com>2014-02-10 17:19:26 +0400
committerSv. Lockal <lockalsash@gmail.com>2014-02-10 17:19:26 +0400
commit7096529704989286f30d645fae54e40c8335ec5e (patch)
tree852c89a45ea6c75e49fc16f1b7b191bacd03649c /intern/cycles/kernel/svm
parent2f01be2b2fe563f634c9f653260940b2a9a78d6d (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/cycles/kernel/svm')
-rw-r--r--intern/cycles/kernel/svm/svm_image.h27
1 files changed, 12 insertions, 15 deletions
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