[Cycles/msvc] Get cycles_kernel compile time under control.

Ever since we merged the extra texture types (half etc) and spit kernel the compile time for cycles_kernel has been going out of control.

It's currently sitting at a cool 1295.762 seconds with our standard compiler (2013/x64/release)

I'm not entirely sure why msvc gets upset with it, but the inlining of matrix near the bottom of the tri-cubic 3d interpolator is the source of the issue, this patch excludes it from being inlined.

This patch bring it back down to a manageable 186 seconds. (7x faster!!)

with the attached bzzt.blend that @sergey  kindly provided i got the following results with builds with identical hashes

58:51.73 buildbot
58:04.23 Patched

it's really close, the slight speedup could be explained by the switch instead of having multiple if's (switches do generate more optimal code than a chain of if/else/if/else statements) but in all honesty it might just have been pure luck (dev box,very polluted, bad for benchmarks) regardless, this patch doesn't seem to slow down anything with my limited testing.

{F532336}

{F532337}

Reviewers: brecht, lukasstockner97, juicyfruit, dingto, sergey

Reviewed By: brecht, dingto, sergey

Subscribers: InsigMathK, sergey

Tags: #cycles

Differential Revision: https://developer.blender.org/D2595
This commit is contained in:
lazydodo
2017-04-07 10:25:54 -06:00
parent 8e0cdfd0c9
commit b332fc8f23
2 changed files with 170 additions and 149 deletions

View File

@@ -316,15 +316,9 @@ template<typename T> struct texture_image {
return interp_3d_ex(x, y, z, interpolation);
}
ccl_always_inline float4 interp_3d_ex(float x, float y, float z,
int interpolation = INTERPOLATION_LINEAR)
ccl_always_inline float4 interp_3d_ex_closest(float x, float y, float z)
{
if(UNLIKELY(!data))
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
int ix, iy, iz, nix, niy, niz;
if(interpolation == INTERPOLATION_CLOSEST) {
int ix, iy, iz;
frac(x*(float)width, &ix);
frac(y*(float)height, &iy);
frac(z*(float)depth, &iz);
@@ -354,7 +348,12 @@ template<typename T> struct texture_image {
return read(data[ix + iy*width + iz*width*height]);
}
else if(interpolation == INTERPOLATION_LINEAR) {
ccl_always_inline float4 interp_3d_ex_linear(float x, float y, float z)
{
int ix, iy, iz;
int nix, niy, niz;
float tx = frac(x*(float)width - 0.5f, &ix);
float ty = frac(y*(float)height - 0.5f, &iy);
float tz = frac(z*(float)depth - 0.5f, &iz);
@@ -404,7 +403,11 @@ template<typename T> struct texture_image {
return r;
}
else {
ccl_never_inline float4 interp_3d_ex_tricubic(float x, float y, float z)
{
int ix, iy, iz;
int nix, niy, niz;
/* Tricubic b-spline interpolation. */
const float tx = frac(x*(float)width - 0.5f, &ix);
const float ty = frac(y*(float)height - 0.5f, &iy);
@@ -495,6 +498,22 @@ template<typename T> struct texture_image {
#undef ROW_TERM
#undef DATA
}
ccl_always_inline float4 interp_3d_ex(float x, float y, float z,
int interpolation = INTERPOLATION_LINEAR)
{
if(UNLIKELY(!data))
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
switch(interpolation) {
case INTERPOLATION_CLOSEST:
return interp_3d_ex_closest(x, y, z);
case INTERPOLATION_LINEAR:
return interp_3d_ex_linear(x, y, z);
default:
return interp_3d_ex_tricubic(x, y, z);
}
}
ccl_always_inline void dimensions_set(int width_, int height_, int depth_)

View File

@@ -55,6 +55,7 @@
#endif
#define ccl_may_alias
#define ccl_always_inline __forceinline
#define ccl_never_inline __declspec(noinline)
#define ccl_maybe_unused
#else
@@ -68,6 +69,7 @@
#define ccl_try_align(...) __attribute__((aligned(__VA_ARGS__)))
#define ccl_may_alias __attribute__((__may_alias__))
#define ccl_always_inline __attribute__((always_inline))
#define ccl_never_inline __attribute__((noinline))
#define ccl_maybe_unused __attribute__((used))
#endif