Cycles: Fix OpenCL compilation failure after recent color changes
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 3 May 2017 12:11:19 +0000 (14:11 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 3 May 2017 12:11:19 +0000 (14:11 +0200)
It is really confusing to have some functions available in some devices
and not on another devices.

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

index ed361cc971ee8e3437e1debe9501b1aa69ba10de..42b985305ea1f7e530c809473b8514f0087777f3 100644 (file)
@@ -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]);
                                }
                        }
                }
index 54571b1fea1b9306af03790253788114cf6edc4c..f13b9db7013a210297ab67f43c63ac0e5702c281 100644 (file)
@@ -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]];
index 9d781b9cfecf05f133287734a4ef5da3f0c5816f..328ff79223b99a37035404e2881b1e658135037e 100644 (file)
@@ -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;
index 114f0f9bf79835089f801e0ca1d5bcf23c3bd121..c73beab98dc70cf6f7baf5f6378c2dc206b72be9 100644 (file)
@@ -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;