Fix #141388: Cycles: CPU/GPU difference in pow function with 0 base
If the base is 0 and the exponent is non-zero, return 0 for both CPU and GPU. Pull Request: https://projects.blender.org/blender/blender/pulls/142678
This commit is contained in:
committed by
Weizhen Huang
parent
40b2cd92ee
commit
9404db8c7c
@@ -547,10 +547,14 @@ ccl_device float safe_acosf(const float a)
|
||||
|
||||
ccl_device float compatible_powf(const float x, const float y)
|
||||
{
|
||||
#ifdef __KERNEL_GPU__
|
||||
if (y == 0.0f) /* x^0 -> 1, including 0^0 */
|
||||
if (y == 0.0f) {
|
||||
/* x^0 -> 1, including 0^0. */
|
||||
return 1.0f;
|
||||
|
||||
}
|
||||
if (x == 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
#ifdef __KERNEL_GPU__
|
||||
/* GPU pow doesn't accept negative x, do manual checks here */
|
||||
if (x < 0.0f) {
|
||||
if (fmodf(-y, 2.0f) == 0.0f) {
|
||||
@@ -560,8 +564,6 @@ ccl_device float compatible_powf(const float x, const float y)
|
||||
return -powf(-x, y);
|
||||
}
|
||||
}
|
||||
else if (x == 0.0f)
|
||||
return 0.0f;
|
||||
#endif
|
||||
return powf(x, y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user