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:
authorSergey Sharybin <sergey.vfx@gmail.com>2015-01-10 20:41:49 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-01-12 13:04:52 +0300
commitbc7ff3c2b44e9cd8f3aea1a3943b787deede2838 (patch)
treeb93c8de1b10b739fc7b7250305b4b0121f37a068 /intern/cycles/bvh
parentc707b91ce6b14182a3a579b645cfd832fc1ae658 (diff)
Cycles: Enable leaf split by primitive type and adopt BVH traversal for this
This commit enables BVH leaf nodes split by the primitive type and makes it so BVH traversal code is now aware and benefits from this. As was mentioned in original commit, this change is crucial to be able to do single ray to multiple triangle intersection. But it also appears to give barely visible speedup in some scene. In any case there should be no noticeable slowdown, and this change is what we need to have anyway.
Diffstat (limited to 'intern/cycles/bvh')
-rw-r--r--intern/cycles/bvh/bvh_build.cpp64
-rw-r--r--intern/cycles/bvh/bvh_build.h1
-rw-r--r--intern/cycles/bvh/bvh_params.h6
3 files changed, 1 insertions, 70 deletions
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index d0542f064a3..23c696ea6b2 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -473,7 +473,7 @@ BVHNode *BVHBuild::create_primitive_leaf_node(const int *p_type,
return new LeafNode(bounds, visibility, start, start + num);
}
-BVHNode* BVHBuild::create_leaf_node_split(const BVHRange& range)
+BVHNode* BVHBuild::create_leaf_node(const BVHRange& range)
{
#define MAX_LEAF_SIZE 8
int p_num[PRIMITIVE_NUM_TOTAL] = {0};
@@ -564,68 +564,6 @@ BVHNode* BVHBuild::create_leaf_node_split(const BVHRange& range)
#undef AMX_LEAF_SIZE
}
-BVHNode* BVHBuild::create_leaf_node(const BVHRange& range)
-{
- if(params.use_split_leaf_types) {
- /* Need to ensure leaf nodes has single primitive type only. */
- return create_leaf_node_split(range);
- }
-
- vector<int>& p_type = prim_type;
- vector<int>& p_index = prim_index;
- vector<int>& p_object = prim_object;
- BoundBox bounds = BoundBox::empty;
- int num = 0, ob_num = 0;
- uint visibility = 0;
-
- for(int i = 0; i < range.size(); i++) {
- BVHReference& ref = references[range.start() + i];
-
- if(ref.prim_index() != -1) {
- if(range.start() + num == prim_index.size()) {
- assert(params.use_spatial_split);
-
- p_type.push_back(ref.prim_type());
- p_index.push_back(ref.prim_index());
- p_object.push_back(ref.prim_object());
- }
- else {
- p_type[range.start() + num] = ref.prim_type();
- p_index[range.start() + num] = ref.prim_index();
- p_object[range.start() + num] = ref.prim_object();
- }
-
- bounds.grow(ref.bounds());
- visibility |= objects[ref.prim_object()]->visibility;
- num++;
- }
- else {
- if(ob_num < i)
- references[range.start() + ob_num] = ref;
- ob_num++;
- }
- }
-
- BVHNode *leaf = NULL;
-
- if(num > 0) {
- leaf = new LeafNode(bounds, visibility, range.start(), range.start() + num);
-
- if(num == range.size())
- return leaf;
- }
-
- /* while there may be multiple triangles in a leaf, for object primitives
- * we want there to be the only one, so we keep splitting */
- const BVHReference *ref = (ob_num)? &references[range.start()]: NULL;
- BVHNode *oleaf = create_object_leaf_nodes(ref, range.start() + num, ob_num);
-
- if(leaf)
- return new InnerNode(range.bounds(), leaf, oleaf);
- else
- return oleaf;
-}
-
/* Tree Rotations */
void BVHBuild::rotate(BVHNode *node, int max_depth, int iterations)
diff --git a/intern/cycles/bvh/bvh_build.h b/intern/cycles/bvh/bvh_build.h
index 1e629fb5eb2..294c5a1758d 100644
--- a/intern/cycles/bvh/bvh_build.h
+++ b/intern/cycles/bvh/bvh_build.h
@@ -71,7 +71,6 @@ protected:
BVHNode *create_object_leaf_nodes(const BVHReference *ref, int start, int num);
/* Leaf node type splitting. */
- BVHNode *create_leaf_node_split(const BVHRange& range);
BVHNode *create_primitive_leaf_node(const int *p_type,
const int *p_index,
const int *p_object,
diff --git a/intern/cycles/bvh/bvh_params.h b/intern/cycles/bvh/bvh_params.h
index c4dc14710e3..3fa6ebd75af 100644
--- a/intern/cycles/bvh/bvh_params.h
+++ b/intern/cycles/bvh/bvh_params.h
@@ -49,11 +49,6 @@ public:
/* QBVH */
int use_qbvh;
- /* Split leaf nodes by primitive types,
- * leaving node containing primitives of single type only.
- */
- int use_split_leaf_types;
-
/* fixed parameters */
enum {
MAX_DEPTH = 64,
@@ -78,7 +73,6 @@ public:
top_level = false;
use_cache = false;
use_qbvh = false;
- use_split_leaf_types = false;
}
/* SAH costs */