diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-01-13 19:15:30 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-01-17 19:35:23 +0300 |
commit | 4d10a46e6368f0b48a901325b94ebd43b672db32 (patch) | |
tree | da3a7e85d4a82f4d06b4852858dfc187a13c80c0 /intern/cycles/kernel/bvh/shadow_all.h | |
parent | a25cfc5db2625d147c4f2d89584e6d87748a47bb (diff) |
Cleanup: refactor BVH2 in preparation of self intersection skip
Move some logic out of triangle intersection functions and into BVH
traversal, so we can share logic between primitives.
Ref D12954
Diffstat (limited to 'intern/cycles/kernel/bvh/shadow_all.h')
-rw-r--r-- | intern/cycles/kernel/bvh/shadow_all.h | 53 |
1 files changed, 21 insertions, 32 deletions
diff --git a/intern/cycles/kernel/bvh/shadow_all.h b/intern/cycles/kernel/bvh/shadow_all.h index b0e799675e0..0fb86bfda77 100644 --- a/intern/cycles/kernel/bvh/shadow_all.h +++ b/intern/cycles/kernel/bvh/shadow_all.h @@ -146,7 +146,7 @@ ccl_device_inline --stack_ptr; /* primitive intersection */ - while (prim_addr < prim_addr2) { + for (; prim_addr < prim_addr2; prim_addr++) { kernel_assert((kernel_tex_fetch(__prim_type, prim_addr) & PRIMITIVE_ALL) == (type & PRIMITIVE_ALL)); bool hit; @@ -156,16 +156,29 @@ ccl_device_inline * might give a few % performance improvement */ Intersection isect ccl_optional_struct_init; + const int prim_object = (object == OBJECT_NONE) ? + kernel_tex_fetch(__prim_object, prim_addr) : + object; + const int prim = kernel_tex_fetch(__prim_index, prim_addr); + switch (type & PRIMITIVE_ALL) { case PRIMITIVE_TRIANGLE: { hit = triangle_intersect( - kg, &isect, P, dir, t_max_current, visibility, object, prim_addr); + kg, &isect, P, dir, t_max_current, visibility, prim_object, prim, prim_addr); break; } #if BVH_FEATURE(BVH_MOTION) case PRIMITIVE_MOTION_TRIANGLE: { - hit = motion_triangle_intersect( - kg, &isect, P, dir, t_max_current, ray->time, visibility, object, prim_addr); + hit = motion_triangle_intersect(kg, + &isect, + P, + dir, + t_max_current, + ray->time, + visibility, + prim_object, + prim, + prim_addr); break; } #endif @@ -182,20 +195,9 @@ ccl_device_inline } } - const int curve_object = (object == OBJECT_NONE) ? - kernel_tex_fetch(__prim_object, prim_addr) : - object; const int curve_type = kernel_tex_fetch(__prim_type, prim_addr); - const int curve_prim = kernel_tex_fetch(__prim_index, prim_addr); - hit = curve_intersect(kg, - &isect, - P, - dir, - t_max_current, - curve_object, - curve_prim, - ray->time, - curve_type); + hit = curve_intersect( + kg, &isect, P, dir, t_max_current, prim_object, prim, ray->time, curve_type); break; } @@ -211,20 +213,9 @@ ccl_device_inline } } - const int point_object = (object == OBJECT_NONE) ? - kernel_tex_fetch(__prim_object, prim_addr) : - object; - const int point_prim = kernel_tex_fetch(__prim_index, prim_addr); const int point_type = kernel_tex_fetch(__prim_type, prim_addr); - hit = point_intersect(kg, - &isect, - P, - dir, - t_max_current, - point_object, - point_prim, - ray->time, - point_type); + hit = point_intersect( + kg, &isect, P, dir, t_max_current, prim_object, prim, ray->time, point_type); break; } #endif /* BVH_FEATURE(BVH_POINTCLOUD) */ @@ -301,8 +292,6 @@ ccl_device_inline integrator_state_write_shadow_isect(state, &isect, record_index); } } - - prim_addr++; } } else { |