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.
This commit is contained in:
Sergey Sharybin
2017-05-03 14:11:19 +02:00
parent 44991a0132
commit 6f9c839f44
4 changed files with 24 additions and 27 deletions

View 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 curvekey = CData->curve_firstkey[curve]; curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 1; curvekey++) {
for(int section = 0; section < resol; section++) { 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++; 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++; 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++; 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++; 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++; 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++; vertexindex++;
} }
} }
@@ -1004,7 +1004,7 @@ void BlenderSync::sync_curves(Mesh *mesh,
for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++) for(size_t curve = 0; curve < CData.curve_vcol.size(); curve++)
if(!(CData.curve_keynum[curve] <= 1 || CData.curve_length[curve] == 0.0f)) 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]);
} }
} }
} }

View File

@@ -356,7 +356,7 @@ static void attr_create_vertex_color(Scene *scene,
int n = p->loop_total(); int n = p->loop_total();
for(int i = 0; i < n; i++) { for(int i = 0; i < n; i++) {
float3 color = get_float3(l->data[p->loop_start() + i].color()); 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); face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b);
uchar4 colors[4]; uchar4 colors[4];
colors[0] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color1()))); 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(get_float3(c->color2()))); 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(get_float3(c->color3()))); colors[2] = color_float_to_byte(color_srgb_to_scene_linear_v3(get_float3(c->color3())));
if(nverts[i] == 4) { 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]]; cdata[0] = colors[tri_a[0]];

View File

@@ -174,7 +174,7 @@ ccl_device float4 svm_image_texture(KernelGlobals *kg, int id, float x, float y,
} }
if(srgb) { if(srgb) {
r = color_srgb_to_scene_linear(r); r = color_srgb_to_scene_linear_v4(r);
} }
return r; return r;

View 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); 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 * 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. * 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); ssef gte = fastpow24(gtebase);
return select(cmp, lt, gte); 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), return make_float3(color_srgb_to_scene_linear(c.x),
color_srgb_to_scene_linear(c.y), color_srgb_to_scene_linear(c.y),
color_srgb_to_scene_linear(c.z)); 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__ #ifdef __KERNEL_SSE2__
ssef r_ssef; ssef r_ssef;
@@ -239,15 +245,6 @@ ccl_device float4 color_srgb_to_scene_linear(float4 c)
#endif #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) ccl_device float linear_rgb_to_gray(float3 c)
{ {
return c.x*0.2126f + c.y*0.7152f + c.z*0.0722f; return c.x*0.2126f + c.y*0.7152f + c.z*0.0722f;