[Bf-blender-cvs] [6f9c839f444] master: Cycles: Fix OpenCL compilation failure after recent color changes

Sergey Sharybin noreply at git.blender.org
Wed May 3 14:13:59 CEST 2017


Commit: 6f9c839f444f92c4b0c336a6f5e31cb9660d7dbc
Author: Sergey Sharybin
Date:   Wed May 3 14:11:19 2017 +0200
Branches: master
https://developer.blender.org/rB6f9c839f444f92c4b0c336a6f5e31cb9660d7dbc

Cycles: Fix OpenCL compilation failure after recent color changes

It is really confusing to have some functions available in some devices
and not on another devices.

===================================================================

M	intern/cycles/blender/blender_curves.cpp
M	intern/cycles/blender/blender_mesh.cpp
M	intern/cycles/kernel/svm/svm_image.h
M	intern/cycles/util/util_color.h

===================================================================

diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index ed361cc971e..42b985305ea 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -776,17 +776,17 @@ static void ExportCurveTriangleVcol(ParticleCurveData *CData,
 
 			for(int curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
 				for(int section = 0; section < resol; section++) {
-					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
 					vertexindex++;
-					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
 					vertexindex++;
-					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
 					vertexindex++;
-					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
 					vertexindex++;
-					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
 					vertexindex++;
-					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear(CData->curve_vcol[curve]));
+					cdata[vertexindex] = color_float_to_byte(color_srgb_to_scene_linear_v3(CData->curve_vcol[curve]));
 					vertexindex++;
 				}
 			}
@@ -1004,7 +1004,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
 
 					for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++)
 						if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f))
-							fdata[i++] = color_srgb_to_scene_linear(CData.curve_vcol[curve]);
+							fdata[i++] = color_srgb_to_scene_linear_v3(CData.curve_vcol[curve]);
 				}
 			}
 		}
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 54571b1fea1..f13b9db7013 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -356,7 +356,7 @@ static void attr_create_vertex_color(Scene *scene,
 				int n = p->loop_total();
 				for(int i = 0; i < n; i++) {
 					float3 color = get_float3(l->data[p->loop_start() + i].color());
-					*(cdata++) = color_float_to_byte(color_srgb_to_scene_linear(color));
+					*(cdata++) = color_float_to_byte(color_srgb_to_scene_linear_v3(color));
 				}
 			}
 		}
@@ -380,11 +380,11 @@ static void attr_create_vertex_color(Scene *scene,
 				face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
 
 				uchar4 colors[4];
-				colors[0] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color1())));
-				colors[1] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color2())));
-				colors[2] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color3())));
+				colors[0] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color1())));
+				colors[1] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color2())));
+				colors[2] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color3())));
 				if(nverts[i] == 4) {
-					colors[3] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color4())));
+					colors[3] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color4())));
 				}
 
 				cdata[0] = colors[tri_a[0]];
diff --git a/intern/cycles/kernel/svm/svm_image.h b/intern/cycles/kernel/svm/svm_image.h
index 9d781b9cfec..328ff79223b 100644
--- a/intern/cycles/kernel/svm/svm_image.h
+++ b/intern/cycles/kernel/svm/svm_image.h
@@ -174,7 +174,7 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
 	}
 
 	if(srgb) {
-		r = color_srgb_to_scene_linear(r);
+		r = color_srgb_to_scene_linear_v4(r);
 	}
 
 	return r;
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index 114f0f9bf79..c73beab98dc 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -157,8 +157,7 @@ ccl_device float3 xyz_to_rgb(float x, float y, float z)
 	                   0.055648f * x + -0.204043f * y +  1.057311f * z);
 }
 
-#ifndef __KERNEL_OPENCL__
-#  ifdef __KERNEL_SSE2__
+#ifdef __KERNEL_SSE2__
 /*
  * Calculate initial guess for arg^exp based on float representation
  * This method gives a constant bias, which can be easily compensated by multiplication with bias_coeff.
@@ -213,16 +212,23 @@ ccl_device ssef color_srgb_to_scene_linear(const ssef &c)
 	ssef gte = fastpow24(gtebase);
 	return select(cmp, lt, gte);
 }
-#  endif  /* __KERNEL_SSE2__ */
+#endif  /* __KERNEL_SSE2__ */
 
-ccl_device float3 color_srgb_to_scene_linear(float3 c)
+ccl_device float3 color_srgb_to_scene_linear_v3(float3 c)
 {
 	return make_float3(color_srgb_to_scene_linear(c.x),
 	                   color_srgb_to_scene_linear(c.y),
 	                   color_srgb_to_scene_linear(c.z));
 }
 
-ccl_device float4 color_srgb_to_scene_linear(float4 c)
+ccl_device float3 color_scene_linear_to_srgb_v3(float3 c)
+{
+	return make_float3(color_scene_linear_to_srgb(c.x),
+	                   color_scene_linear_to_srgb(c.y),
+	                   color_scene_linear_to_srgb(c.z));
+}
+
+ccl_device float4 color_srgb_to_scene_linear_v4(float4 c)
 {
 #ifdef __KERNEL_SSE2__
 	ssef r_ssef;
@@ -239,15 +245,6 @@ ccl_device float4 color_srgb_to_scene_linear(float4 c)
 #endif
 }
 
-ccl_device float3 color_scene_linear_to_srgb(float3 c)
-{
-	return make_float3(color_scene_linear_to_srgb(c.x),
-	                   color_scene_linear_to_srgb(c.y),
-	                   color_scene_linear_to_srgb(c.z));
-}
-
-#endif  /* __KERNEL_OPENCL__ */
-
 ccl_device float linear_rgb_to_gray(float3 c)
 {
 	return c.x*0.2126f + c.y*0.7152f + c.z*0.0722f;




More information about the Bf-blender-cvs mailing list