diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-01-17 17:34:18 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-01-20 14:46:18 +0300 |
commit | 1ad04c7d65b0e9e3efa8563005e91d9aa419fec5 (patch) | |
tree | 99912cb1c7c6506388da1ca623f025ba985dd214 /intern/cycles/kernel/bvh | |
parent | c4890cd354bdba341be5b5fb9cf3724ee294634b (diff) |
Cycles: Store time in BVH nodes
This way we can stop traversing BVH node early on.
Gives about 2-2.5x times render time improvement with 3 BVH steps.
Hopefully this gives no measurable performance loss for scenes with
single BVH step.
Traversal is currently only implemented for QBVH, meaning old CPUs
and GPU do not benefit from this change.
Diffstat (limited to 'intern/cycles/kernel/bvh')
-rw-r--r-- | intern/cycles/kernel/bvh/qbvh_shadow_all.h | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/bvh/qbvh_traversal.h | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/intern/cycles/kernel/bvh/qbvh_shadow_all.h b/intern/cycles/kernel/bvh/qbvh_shadow_all.h index b2e99725626..607295f9ed5 100644 --- a/intern/cycles/kernel/bvh/qbvh_shadow_all.h +++ b/intern/cycles/kernel/bvh/qbvh_shadow_all.h @@ -106,14 +106,20 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, while(node_addr >= 0 && node_addr != ENTRYPOINT_SENTINEL) { float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr+0); + if(false #ifdef __VISIBILITY_FLAG__ - if((__float_as_uint(inodes.x) & PATH_RAY_SHADOW) == 0) { + || ((__float_as_uint(inodes.x) & PATH_RAY_SHADOW) == 0) +#endif +#if BVH_FEATURE(BVH_MOTION) + || UNLIKELY(ray->time < inodes.y) + || UNLIKELY(ray->time > inodes.z) +#endif + ) { /* Pop. */ node_addr = traversal_stack[stack_ptr].addr; --stack_ptr; continue; } -#endif ssef dist; int child_mask = NODE_INTERSECT(kg, diff --git a/intern/cycles/kernel/bvh/qbvh_traversal.h b/intern/cycles/kernel/bvh/qbvh_traversal.h index 1d5643ca540..10ae7bee852 100644 --- a/intern/cycles/kernel/bvh/qbvh_traversal.h +++ b/intern/cycles/kernel/bvh/qbvh_traversal.h @@ -117,6 +117,10 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg, float4 inodes = kernel_tex_fetch(__bvh_nodes, node_addr+0); if(UNLIKELY(node_dist > isect->t) +#if BVH_FEATURE(BVH_MOTION) + || UNLIKELY(ray->time < inodes.y) + || UNLIKELY(ray->time > inodes.z) +#endif #ifdef __VISIBILITY_FLAG__ || (__float_as_uint(inodes.x) & visibility) == 0) #endif |