Commit: 6f25eda4d7f60f04e5cd54c9f199ee499763d7c1 Author: MATILLAT Quentin Date: Thu Jul 11 15:05:32 2019 +0200 Branches: soc-2019-embree-gpu https://developer.blender.org/rB6f25eda4d7f60f04e5cd54c9f199ee499763d7c1
Update timing information Timing information are now stored using the same system as visibility : Each node store information from his children =================================================================== M intern/cycles/bvh/bvh2.cpp M intern/cycles/bvh/bvh2.h M intern/cycles/bvh/bvh_embree_converter.cpp M intern/cycles/bvh/bvh_node.cpp M intern/cycles/kernel/bvh/bvh_local.h M intern/cycles/kernel/bvh/bvh_nodes.h M intern/cycles/kernel/bvh/bvh_shadow_all.h M intern/cycles/kernel/bvh/bvh_traversal.h M intern/cycles/kernel/bvh/bvh_volume.h M intern/cycles/kernel/bvh/bvh_volume_all.h =================================================================== diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp index edec6a9aebe..0475ac33887 100644 --- a/intern/cycles/bvh/bvh2.cpp +++ b/intern/cycles/bvh/bvh2.cpp @@ -76,8 +76,8 @@ void BVH2::pack_aligned_inner(const BVHStackEntry &e, e1.node->bounds, e0.encodeIdx(), e1.encodeIdx(), - e.node->time_from, - e.node->time_to, + make_float2(e0.node->time_from, e0.node->time_to), + make_float2(e1.node->time_from, e1.node->time_to), e0.node->visibility, e1.node->visibility); } @@ -87,8 +87,8 @@ void BVH2::pack_aligned_node(int idx, const BoundBox &b1, int c0, int c1, - float timeFrom, - float timeTo, + float2 time0, + float2 time1, uint visibility0, uint visibility1) { @@ -111,9 +111,10 @@ void BVH2::pack_aligned_node(int idx, __float_as_int(b1.min.z), __float_as_int(b0.max.z), __float_as_int(b1.max.z)), - make_int4(__float_as_int(timeFrom), - __float_as_int(timeTo), - 0, 0), + make_int4(__float_as_int(time0.x), + __float_as_int(time1.x), + __float_as_int(time0.y), + __float_as_int(time1.y)), }; memcpy(&pack.nodes[idx], data, sizeof(int4) * BVH_NODE_SIZE); @@ -289,7 +290,12 @@ void BVH2::refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility) idx, aligned_space, aligned_space, bbox0, bbox1, c0, c1, visibility0, visibility1); } else { - pack_aligned_node(idx, bbox0, bbox1, c0, c1, __int_as_float(data[4].x), __int_as_float(data[4].y), visibility0, visibility1); + pack_aligned_node(idx, + bbox0, bbox1, + c0, c1, + make_float2(__int_as_float(data[4].x), __int_as_float(data[4].z)), + make_float2(__int_as_float(data[4].y), __int_as_float(data[4].w)), + visibility0, visibility1); } bbox.grow(bbox0); diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h index 08938a04bc1..3a371a1d79c 100644 --- a/intern/cycles/bvh/bvh2.h +++ b/intern/cycles/bvh/bvh2.h @@ -65,8 +65,8 @@ class BVH2 : public BVH { const BoundBox &b1, int c0, int c1, - float timeFrom, - float timeTo, + float2 time0, + float2 time1, uint visibility0, uint visibility1); diff --git a/intern/cycles/bvh/bvh_embree_converter.cpp b/intern/cycles/bvh/bvh_embree_converter.cpp index b9e2ca6954d..b93b6039c54 100644 --- a/intern/cycles/bvh/bvh_embree_converter.cpp +++ b/intern/cycles/bvh/bvh_embree_converter.cpp @@ -330,6 +330,7 @@ BVHNode* BVHEmbreeConverter::getBVH2() { std::cout << root->getSubtreeSize(BVH_STAT_TIMELIMIT_NODE) << " times nodes" << std::endl; std::cout << "BVH4 SAH is " << root->computeSubtreeSAHCost(this->params) << std::endl; root = bvh_shrink(root); + std::cout << root->getSubtreeSize(BVH_STAT_TIMELIMIT_NODE) << " times nodes" << std::endl; std::cout << "BVH2 SAH is " << root->computeSubtreeSAHCost(this->params) << std::endl; return root; } diff --git a/intern/cycles/bvh/bvh_node.cpp b/intern/cycles/bvh/bvh_node.cpp index 0e3db43ecb1..413f5befcca 100644 --- a/intern/cycles/bvh/bvh_node.cpp +++ b/intern/cycles/bvh/bvh_node.cpp @@ -92,7 +92,7 @@ int BVHNode::getSubtreeSize(BVH_STAT stat) const } return cnt; case BVH_STAT_TIMELIMIT_NODE: - if(this->time_from != 0 || this->time_to != 1) + if(this->time_from > 0 || this->time_to < 1) cnt = 1; break; default: diff --git a/intern/cycles/kernel/bvh/bvh_local.h b/intern/cycles/kernel/bvh/bvh_local.h index 7a069ef1108..98eb5a89c0e 100644 --- a/intern/cycles/kernel/bvh/bvh_local.h +++ b/intern/cycles/kernel/bvh/bvh_local.h @@ -127,6 +127,7 @@ ccl_device_inline isect_t, node_addr, PATH_RAY_ALL_VISIBILITY, + ray->time, dist); #else // __KERNEL_SSE2__ traverse_mask = NODE_INTERSECT(kg, diff --git a/intern/cycles/kernel/bvh/bvh_nodes.h b/intern/cycles/kernel/bvh/bvh_nodes.h index a33bc73e25b..0fc6ecad5bc 100644 --- a/intern/cycles/kernel/bvh/bvh_nodes.h +++ b/intern/cycles/kernel/bvh/bvh_nodes.h @@ -35,6 +35,7 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg, const float t, const int node_addr, const uint visibility, + const float rayTime, float dist[2]) { @@ -43,6 +44,7 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg, float4 node0 = kernel_tex_fetch(__bvh_nodes, node_addr + 1); float4 node1 = kernel_tex_fetch(__bvh_nodes, node_addr + 2); float4 node2 = kernel_tex_fetch(__bvh_nodes, node_addr + 3); + float4 timeLimits = kernel_tex_fetch(__bvh_nodes, node_addr + 4); /* intersect ray against child nodes */ float c0lox = (node0.x - P.x) * idir.x; @@ -66,6 +68,12 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg, dist[0] = c0min; dist[1] = c1min; + if(timeLimits.x > rayTime || timeLimits.z < rayTime) + c0max = -1.0f; + + if(timeLimits.y > rayTime || timeLimits.w < rayTime) + c1max = -1.0f; + # ifdef __VISIBILITY_FLAG__ /* this visibility test gives a 5% performance hit, how to solve? */ return (((c0max >= c0min) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) | @@ -138,6 +146,7 @@ ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg, const float t, const int node_addr, const uint visibility, + const float rayTime, float dist[2]) { float4 node = kernel_tex_fetch(__bvh_nodes, node_addr); @@ -145,7 +154,7 @@ ccl_device_forceinline int bvh_node_intersect(KernelGlobals *kg, return bvh_unaligned_node_intersect(kg, P, dir, idir, t, node_addr, visibility, dist); } else { - return bvh_aligned_node_intersect(kg, P, idir, t, node_addr, visibility, dist); + return bvh_aligned_node_intersect(kg, P, idir, t, node_addr, visibility, rayTime, dist); } } diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h index 268bb149970..c008b7cde42 100644 --- a/intern/cycles/kernel/bvh/bvh_shadow_all.h +++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h @@ -122,6 +122,7 @@ ccl_device_inline isect_t, node_addr, visibility, + ray->time, dist); #else // __KERNEL_SSE2__ traverse_mask = NODE_INTERSECT(kg, diff --git a/intern/cycles/kernel/bvh/bvh_traversal.h b/intern/cycles/kernel/bvh/bvh_traversal.h index 02e1c038057..a8e181951ac 100644 --- a/intern/cycles/kernel/bvh/bvh_traversal.h +++ b/intern/cycles/kernel/bvh/bvh_traversal.h @@ -106,11 +106,6 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, float dist[2]; float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0); float4 timeLimits = kernel_tex_fetch(__bvh_nodes, node_addr + 4); - if(timeLimits.x > ray->time || timeLimits.y < ray->time) { - node_addr = traversal_stack[stack_ptr]; - --stack_ptr; - continue; - } #if !defined(__KERNEL_SSE2__) { @@ -123,6 +118,7 @@ ccl_device_noinline bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, isect->t, node_addr, visibility, + ray->time, dist); } #else // __KERNEL_SSE2__ diff --git a/intern/cycles/kernel/bvh/bvh_volume.h b/intern/cycles/kernel/bvh/bvh_volume.h index c83b0d783f4..49839ec83a0 100644 --- a/intern/cycles/kernel/bvh/bvh_volume.h +++ b/intern/cycles/kernel/bvh/bvh_volume.h @@ -118,6 +118,7 @@ ccl_device_inline isect->t, node_addr, visibility, + ray->time, dist); #else // __KERNEL_SSE2__ traverse_mask = NODE_INTERSECT(kg, diff --git a/intern/cycles/kernel/bvh/bvh_volume_all.h b/intern/cycles/kernel/bvh/bvh_volume_all.h index ae8c4d12e8a..8399e92cc92 100644 --- a/intern/cycles/kernel/bvh/bvh_volume_all.h +++ b/intern/cycles/kernel/bvh/bvh_volume_all.h @@ -122,6 +122,7 @@ ccl_device_inline isect_t, node_addr, visibility, + ray->time, dist); #else // __KERNEL_SSE2__ traverse_mask = NODE_INTERSECT(kg, _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs