forked from bartvdbraak/blender
Fix T38501: blender crashes right after adding image texture to material
in cycles Also fix very similar problem in half-float SSE conversion.
This commit is contained in:
parent
2f01be2b2f
commit
7096529704
@ -75,17 +75,15 @@ ccl_device void kernel_film_convert_to_half_float(KernelGlobals *kg,
|
|||||||
|
|
||||||
float exposure = kernel_data.film.exposure;
|
float exposure = kernel_data.film.exposure;
|
||||||
|
|
||||||
if(exposure == 1.0f) {
|
ccl_align(16) float4 rgba_in = *in;
|
||||||
float4_store_half(out, in, sample_scale);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
float4 rgba = *in;
|
|
||||||
rgba.x *= exposure;
|
|
||||||
rgba.y *= exposure;
|
|
||||||
rgba.z *= exposure;
|
|
||||||
|
|
||||||
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
|
CCL_NAMESPACE_END
|
||||||
|
@ -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)
|
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__)
|
#ifdef __KERNEL_CPU__
|
||||||
union { float4 rgba; __m128 m128; } r = { kernel_tex_image_interp(id, x, y) };
|
ccl_align(16) float4 r = kernel_tex_image_interp(id, x, y);
|
||||||
#elif defined(__KERNEL_CPU__)
|
|
||||||
float4 r = kernel_tex_image_interp(id, x, y);
|
|
||||||
#else
|
#else
|
||||||
float4 r;
|
float4 r;
|
||||||
|
|
||||||
@ -236,21 +234,20 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __KERNEL_SSE2__
|
#ifdef __KERNEL_SSE2__
|
||||||
if(use_alpha && r.rgba.w != 1.0f && r.rgba.w != 0.0f) {
|
__m128 &r_m128 = (__m128&)r;
|
||||||
float alpha = r.rgba.w;
|
if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
|
||||||
r.m128 = _mm_div_ps(r.m128, _mm_set1_ps(alpha));
|
float alpha = r.w;
|
||||||
|
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));
|
||||||
r.rgba.w = alpha;
|
r.w = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(srgb) {
|
if(srgb) {
|
||||||
float alpha = r.rgba.w;
|
float alpha = r.w;
|
||||||
r.m128 = color_srgb_to_scene_linear(r.m128);
|
r_m128 = color_srgb_to_scene_linear(r_m128);
|
||||||
r.rgba.w = alpha;
|
r.w = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.rgba;
|
|
||||||
#else
|
#else
|
||||||
if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
|
if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
|
||||||
float invw = 1.0f/r.w;
|
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.y = color_srgb_to_scene_linear(r.y);
|
||||||
r.z = color_srgb_to_scene_linear(r.z);
|
r.z = color_srgb_to_scene_linear(r.z);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user