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:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-05-03 12:22:27 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-05-03 12:22:48 +0300
commitcea0236026bf5c547534afe5a875255a1857ebab (patch)
tree4e34e5e65c8714cedc4515978f0346660fae4858
parente616cd5706ef359aaed481db2e4d31a3fe16cd3b (diff)
Cycles: Simplify code in SVM image by using new utility function
Can not measure any performance difference, so seems the code is identical and just shorter.
-rw-r--r--intern/cycles/kernel/svm/svm_image.h46
1 files changed, 11 insertions, 35 deletions
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 4b5e4ebac00..9d781b9cfec 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -32,13 +32,7 @@ CCL_NAMESPACE_BEGIN
ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y, uint srgb, uint use_alpha)
{
#ifdef __KERNEL_CPU__
-# ifdef __KERNEL_SSE2__
- ssef r_ssef;
- float4 &r = (float4 &)r_ssef;
- r = kernel_tex_image_interp(id, x, y);
-# else
float4 r = kernel_tex_image_interp(id, x, y);
-# endif
#elif defined(__KERNEL_OPENCL__)
float4 r = kernel_tex_image_interp(kg, id, x, y);
#else
@@ -152,7 +146,10 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
CUtexObject tex = kernel_tex_fetch(__bindless_mapping, id);
/* float4, byte4 and half4 */
const int texture_type = kernel_tex_type(id);
- if(texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 || texture_type == IMAGE_DATA_TYPE_HALF4) {
+ if(texture_type == IMAGE_DATA_TYPE_FLOAT4 ||
+ texture_type == IMAGE_DATA_TYPE_BYTE4 ||
+ texture_type == IMAGE_DATA_TYPE_HALF4)
+ {
r = kernel_tex_image_interp_float4(tex, x, y);
}
/* float, byte and half */
@@ -163,43 +160,22 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
# endif
#endif
-#ifdef __KERNEL_SSE2__
- float alpha = r.w;
+ const float alpha = r.w;
if(use_alpha && alpha != 1.0f && alpha != 0.0f) {
- r_ssef = r_ssef / ssef(alpha);
+ r /= alpha;
const int texture_type = kernel_tex_type(id);
- if(texture_type == IMAGE_DATA_TYPE_BYTE4 || texture_type == IMAGE_DATA_TYPE_BYTE) {
- r_ssef = min(r_ssef, ssef(1.0f));
+ if(texture_type == IMAGE_DATA_TYPE_BYTE4 ||
+ texture_type == IMAGE_DATA_TYPE_BYTE)
+ {
+ r = min(r, make_float4(1.0f, 1.0f, 1.0f, 1.0f));
}
r.w = alpha;
}
if(srgb) {
- r_ssef = color_srgb_to_scene_linear(r_ssef);
- r.w = alpha;
+ r = color_srgb_to_scene_linear(r);
}
-#else
- if(use_alpha && r.w != 1.0f && r.w != 0.0f) {
- float invw = 1.0f/r.w;
- r.x *= invw;
- r.y *= invw;
- r.z *= invw;
-
- const int texture_type = kernel_tex_type(id);
- if(texture_type == IMAGE_DATA_TYPE_BYTE4 || texture_type == IMAGE_DATA_TYPE_BYTE) {
- r.x = min(r.x, 1.0f);
- r.y = min(r.y, 1.0f);
- r.z = min(r.z, 1.0f);
- }
- }
-
- if(srgb) {
- r.x = color_srgb_to_scene_linear(r.x);
- r.y = color_srgb_to_scene_linear(r.y);
- r.z = color_srgb_to_scene_linear(r.z);
- }
-#endif
return r;
}