Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMai Lavelle <mai.lavelle@gmail.com>2017-08-23 07:40:35 +0300
committerMai Lavelle <mai.lavelle@gmail.com>2017-08-23 13:54:26 +0300
commit579edb1510d22571b5e10a55d1cc7be9d6fcf9f8 (patch)
treecb380160a249453ad83cbd16d8eeeec904657b7c /intern/cycles/bvh
parent2540741dee789f752687198c6f272a995d45073e (diff)
Cycles: Add maximum depth stat to bvh builder
Diffstat (limited to 'intern/cycles/bvh')
-rw-r--r--intern/cycles/bvh/bvh_build.cpp4
-rw-r--r--intern/cycles/bvh/bvh_node.cpp11
-rw-r--r--intern/cycles/bvh/bvh_node.h1
3 files changed, 15 insertions, 1 deletions
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index eb1d89729fb..d7098806569 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -529,7 +529,9 @@ BVHNode* BVHBuild::run()
<< " Allocation slop factor: "
<< ((prim_type.capacity() != 0)
? (float)prim_type.size() / prim_type.capacity()
- : 1.0f) << "\n";
+ : 1.0f) << "\n"
+ << " Maximum depth: "
+ << string_human_readable_number(rootnode->getSubtreeSize(BVH_STAT_DEPTH)) << "\n";
}
}
diff --git a/intern/cycles/bvh/bvh_node.cpp b/intern/cycles/bvh/bvh_node.cpp
index 4237c62ab5b..ab6df4d265d 100644
--- a/intern/cycles/bvh/bvh_node.cpp
+++ b/intern/cycles/bvh/bvh_node.cpp
@@ -132,6 +132,17 @@ int BVHNode::getSubtreeSize(BVH_STAT stat) const
case BVH_STAT_UNALIGNED_LEAF_COUNT:
cnt = (is_leaf() && is_unaligned) ? 1 : 0;
break;
+ case BVH_STAT_DEPTH:
+ if(is_leaf()) {
+ cnt = 1;
+ }
+ else {
+ for(int i = 0; i < num_children(); i++) {
+ cnt = max(cnt, get_child(i)->getSubtreeSize(stat));
+ }
+ cnt += 1;
+ }
+ return cnt;
default:
assert(0); /* unknown mode */
}
diff --git a/intern/cycles/bvh/bvh_node.h b/intern/cycles/bvh/bvh_node.h
index 1c875f5a524..94cf5ab730c 100644
--- a/intern/cycles/bvh/bvh_node.h
+++ b/intern/cycles/bvh/bvh_node.h
@@ -38,6 +38,7 @@ enum BVH_STAT {
BVH_STAT_UNALIGNED_INNER_QNODE_COUNT,
BVH_STAT_ALIGNED_LEAF_COUNT,
BVH_STAT_UNALIGNED_LEAF_COUNT,
+ BVH_STAT_DEPTH,
};
class BVHParams;