[Bf-blender-cvs] [60cf62f] master: Cycles: Minor optimization of equirectangular projection
Sergey Sharybin
noreply at git.blender.org
Thu Mar 24 15:01:21 CET 2016
Commit: 60cf62ff4b08e310208dca9e35bd75131833e1aa
Author: Sergey Sharybin
Date: Thu Mar 24 15:00:09 2016 +0100
Branches: master
https://developer.blender.org/rB60cf62ff4b08e310208dca9e35bd75131833e1aa
Cycles: Minor optimization of equirectangular projection
Don't calculate sine twice, store this in a variable instead.
Perhaps compilers can optimize this out, but helping them a but wouldn't hurt.
===================================================================
M intern/cycles/kernel/kernel_projection.h
===================================================================
diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
index d042acc..c1a359e 100644
--- a/intern/cycles/kernel/kernel_projection.h
+++ b/intern/cycles/kernel/kernel_projection.h
@@ -47,10 +47,10 @@ ccl_device float2 direction_to_spherical(float3 dir)
ccl_device float3 spherical_to_direction(float theta, float phi)
{
- return make_float3(
- sinf(theta)*cosf(phi),
- sinf(theta)*sinf(phi),
- cosf(theta));
+ float sin_theta = sinf(theta);
+ return make_float3(sin_theta*cosf(phi),
+ sin_theta*sinf(phi),
+ cosf(theta));
}
/* Equirectangular coordinates <-> Cartesian direction */
@@ -67,11 +67,10 @@ ccl_device float3 equirectangular_range_to_direction(float u, float v, float4 ra
{
float phi = range.x*u + range.y;
float theta = range.z*v + range.w;
-
- return make_float3(
- sinf(theta)*cosf(phi),
- sinf(theta)*sinf(phi),
- cosf(theta));
+ float sin_theta = sinf(theta);
+ return make_float3(sin_theta*cosf(phi),
+ sin_theta*sinf(phi),
+ cosf(theta));
}
ccl_device float2 direction_to_equirectangular(float3 dir)
More information about the Bf-blender-cvs
mailing list