[Bf-blender-cvs] [d13a0e8] master: Cycles: Limit triangle magnitude check for only GPU
Sergey Sharybin
noreply at git.blender.org
Wed Sep 9 10:39:42 CEST 2015
Commit: d13a0e8f4ac0352de25e76756509e613a9cc6514
Author: Sergey Sharybin
Date: Wed Sep 9 13:25:56 2015 +0500
Branches: master
https://developer.blender.org/rBd13a0e8f4ac0352de25e76756509e613a9cc6514
Cycles: Limit triangle magnitude check for only GPU
Found a way to make AVX2 CPUs happy by reshuffling instructions a bit,
so now there's no weird precision errors happening in there.
This solves some render speed regressions on CPU, but unfortunately
this doesn't help for GPU rendering.
===================================================================
M intern/cycles/kernel/geom/geom_triangle_intersect.h
===================================================================
diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h
index 5f88ef0..fd521c1 100644
--- a/intern/cycles/kernel/geom/geom_triangle_intersect.h
+++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h
@@ -140,13 +140,15 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg,
/* Calculate scaled barycentric coordinates. */
float U = Cx * By - Cy * Bx;
- int sign_mask = (__float_as_int(U) & 0x80000000);
float V = Ax * Cy - Ay * Cx;
- if(sign_mask != (__float_as_int(V) & 0x80000000)) {
- return false;
- }
float W = Bx * Ay - By * Ax;
- if(sign_mask != (__float_as_int(W) & 0x80000000)) {
+ const int sign_mask = (__float_as_int(U) & 0x80000000);
+ /* TODO(sergey): Check if multiplication plus sign check is faster
+ * or at least same speed (but robust for endian types).
+ */
+ if(sign_mask != (__float_as_int(V) & 0x80000000) ||
+ sign_mask != (__float_as_int(W) & 0x80000000))
+ {
return false;
}
@@ -173,6 +175,7 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg,
if(kernel_tex_fetch(__prim_visibility, triAddr) & visibility)
#endif
{
+#ifdef __KERNEL_GPU__
float4 a = tri_b - tri_a, b = tri_c - tri_a;
if(len_squared(make_float3(a.y*b.z - a.z*b.y,
a.z*b.x - a.x*b.z,
@@ -180,6 +183,8 @@ ccl_device_inline bool triangle_intersect(KernelGlobals *kg,
{
return false;
}
+#endif
+
/* Normalize U, V, W, and T. */
const float inv_det = 1.0f / det;
isect->prim = triAddr;
More information about the Bf-blender-cvs
mailing list