diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-10-25 16:08:33 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-10-25 16:08:33 +0300 |
commit | f7cf2f659afc97cf4d4a8603d4dcafb97031ba79 (patch) | |
tree | 7882573b8e4125f3c9c913bc39fbcb36e179d361 /intern/cycles/kernel/bvh/qbvh_nodes.h | |
parent | 064caae7b2943aa35953642fd4b15d0e9ec05a87 (diff) |
Cycles: Move QBVH near/far offset calculation to an utility function
Just preparing for new optimization to be used in all traversal implementation.
Should be no measurable difference.
Diffstat (limited to 'intern/cycles/kernel/bvh/qbvh_nodes.h')
-rw-r--r-- | intern/cycles/kernel/bvh/qbvh_nodes.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/intern/cycles/kernel/bvh/qbvh_nodes.h b/intern/cycles/kernel/bvh/qbvh_nodes.h index 2ee2a393e80..6d22f0b0d6a 100644 --- a/intern/cycles/kernel/bvh/qbvh_nodes.h +++ b/intern/cycles/kernel/bvh/qbvh_nodes.h @@ -21,6 +21,36 @@ struct QBVHStackItem { float dist; }; +ccl_device_inline void qbvh_near_far_idx_calc(const float3& idir, + int *ccl_restrict near_x, + int *ccl_restrict near_y, + int *ccl_restrict near_z, + int *ccl_restrict far_x, + int *ccl_restrict far_y, + int *ccl_restrict far_z) + +{ +#ifdef __KERNEL_SSE__ + *near_x = 0; *far_x = 1; + *near_y = 2; *far_y = 3; + *near_z = 4; *far_z = 5; + + const size_t mask = movemask(ssef(idir.m128)); + + const int mask_x = mask & 1; + const int mask_y = (mask & 2) >> 1; + const int mask_z = (mask & 4) >> 2; + + *near_x += mask_x; *far_x -= mask_x; + *near_y += mask_y; *far_y -= mask_y; + *near_z += mask_z; *far_z -= mask_z; +#else + if(idir.x >= 0.0f) { *near_x = 0; *far_x = 1; } else { *near_x = 1; *far_x = 0; } + if(idir.y >= 0.0f) { *near_y = 2; *far_y = 3; } else { *near_y = 3; *far_y = 2; } + if(idir.z >= 0.0f) { *near_z = 4; *far_z = 5; } else { *near_z = 5; *far_z = 4; } +#endif +} + /* TOOD(sergey): Investigate if using intrinsics helps for both * stack item swap and float comparison. */ |