Cycles: Use more explicit and commonly used names for BVH structures

This renames BinaryBVH to BVH2 and QBVH to BVH8. There is no user measurable
difference, but allows us to add more types of BVH trees such as BVH8.
This commit is contained in:
Sergey Sharybin 2017-04-13 10:29:14 +02:00
parent ed5c3121f5
commit c8548871ac
2 changed files with 46 additions and 46 deletions

@ -65,9 +65,9 @@ BVH::BVH(const BVHParams& params_, const vector<Object*>& objects_)
BVH *BVH::create(const BVHParams& params, const vector<Object*>& objects)
{
if(params.use_qbvh)
return new QBVH(params, objects);
return new BVH4(params, objects);
else
return new BinaryBVH(params, objects);
return new BVH2(params, objects);
}
/* Building */
@ -427,12 +427,12 @@ static bool node_bvh_is_unaligned(const BVHNode *node)
return node0->is_unaligned || node1->is_unaligned;
}
BinaryBVH::BinaryBVH(const BVHParams& params_, const vector<Object*>& objects_)
BVH2::BVH2(const BVHParams& params_, const vector<Object*>& objects_)
: BVH(params_, objects_)
{
}
void BinaryBVH::pack_leaf(const BVHStackEntry& e,
void BVH2::pack_leaf(const BVHStackEntry& e,
const LeafNode *leaf)
{
assert(e.idx + BVH_NODE_LEAF_SIZE <= pack.leaf_nodes.size());
@ -456,7 +456,7 @@ void BinaryBVH::pack_leaf(const BVHStackEntry& e,
memcpy(&pack.leaf_nodes[e.idx], data, sizeof(float4)*BVH_NODE_LEAF_SIZE);
}
void BinaryBVH::pack_inner(const BVHStackEntry& e,
void BVH2::pack_inner(const BVHStackEntry& e,
const BVHStackEntry& e0,
const BVHStackEntry& e1)
{
@ -467,7 +467,7 @@ void BinaryBVH::pack_inner(const BVHStackEntry& e,
}
}
void BinaryBVH::pack_aligned_inner(const BVHStackEntry& e,
void BVH2::pack_aligned_inner(const BVHStackEntry& e,
const BVHStackEntry& e0,
const BVHStackEntry& e1)
{
@ -477,7 +477,7 @@ void BinaryBVH::pack_aligned_inner(const BVHStackEntry& e,
e0.node->visibility, e1.node->visibility);
}
void BinaryBVH::pack_aligned_node(int idx,
void BVH2::pack_aligned_node(int idx,
const BoundBox& b0,
const BoundBox& b1,
int c0, int c1,
@ -508,7 +508,7 @@ void BinaryBVH::pack_aligned_node(int idx,
memcpy(&pack.nodes[idx], data, sizeof(int4)*BVH_NODE_SIZE);
}
void BinaryBVH::pack_unaligned_inner(const BVHStackEntry& e,
void BVH2::pack_unaligned_inner(const BVHStackEntry& e,
const BVHStackEntry& e0,
const BVHStackEntry& e1)
{
@ -521,7 +521,7 @@ void BinaryBVH::pack_unaligned_inner(const BVHStackEntry& e,
e0.node->visibility, e1.node->visibility);
}
void BinaryBVH::pack_unaligned_node(int idx,
void BVH2::pack_unaligned_node(int idx,
const Transform& aligned_space0,
const Transform& aligned_space1,
const BoundBox& bounds0,
@ -553,7 +553,7 @@ void BinaryBVH::pack_unaligned_node(int idx,
memcpy(&pack.nodes[idx], data, sizeof(float4)*BVH_UNALIGNED_NODE_SIZE);
}
void BinaryBVH::pack_nodes(const BVHNode *root)
void BVH2::pack_nodes(const BVHNode *root)
{
const size_t num_nodes = root->getSubtreeSize(BVH_STAT_NODE_COUNT);
const size_t num_leaf_nodes = root->getSubtreeSize(BVH_STAT_LEAF_COUNT);
@ -630,7 +630,7 @@ void BinaryBVH::pack_nodes(const BVHNode *root)
pack.root_index = (root->is_leaf())? -1: 0;
}
void BinaryBVH::refit_nodes()
void BVH2::refit_nodes()
{
assert(!params.top_level);
@ -639,7 +639,7 @@ void BinaryBVH::refit_nodes()
refit_node(0, (pack.root_index == -1)? true: false, bbox, visibility);
}
void BinaryBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
void BVH2::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
{
if(leaf) {
assert(idx + BVH_NODE_LEAF_SIZE <= pack.leaf_nodes.size());
@ -756,7 +756,7 @@ void BinaryBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
}
}
/* QBVH */
/* BVH4 */
/* Can we avoid this somehow or make more generic?
*
@ -785,13 +785,13 @@ static bool node_qbvh_is_unaligned(const BVHNode *node)
return has_unaligned;
}
QBVH::QBVH(const BVHParams& params_, const vector<Object*>& objects_)
BVH4::BVH4(const BVHParams& params_, const vector<Object*>& objects_)
: BVH(params_, objects_)
{
params.use_qbvh = true;
}
void QBVH::pack_leaf(const BVHStackEntry& e, const LeafNode *leaf)
void BVH4::pack_leaf(const BVHStackEntry& e, const LeafNode *leaf)
{
float4 data[BVH_QNODE_LEAF_SIZE];
memset(data, 0, sizeof(data));
@ -813,7 +813,7 @@ void QBVH::pack_leaf(const BVHStackEntry& e, const LeafNode *leaf)
memcpy(&pack.leaf_nodes[e.idx], data, sizeof(float4)*BVH_QNODE_LEAF_SIZE);
}
void QBVH::pack_inner(const BVHStackEntry& e,
void BVH4::pack_inner(const BVHStackEntry& e,
const BVHStackEntry *en,
int num)
{
@ -841,7 +841,7 @@ void QBVH::pack_inner(const BVHStackEntry& e,
}
}
void QBVH::pack_aligned_inner(const BVHStackEntry& e,
void BVH4::pack_aligned_inner(const BVHStackEntry& e,
const BVHStackEntry *en,
int num)
{
@ -860,7 +860,7 @@ void QBVH::pack_aligned_inner(const BVHStackEntry& e,
num);
}
void QBVH::pack_aligned_node(int idx,
void BVH4::pack_aligned_node(int idx,
const BoundBox *bounds,
const int *child,
const uint visibility,
@ -908,7 +908,7 @@ void QBVH::pack_aligned_node(int idx,
memcpy(&pack.nodes[idx], data, sizeof(float4)*BVH_QNODE_SIZE);
}
void QBVH::pack_unaligned_inner(const BVHStackEntry& e,
void BVH4::pack_unaligned_inner(const BVHStackEntry& e,
const BVHStackEntry *en,
int num)
{
@ -930,7 +930,7 @@ void QBVH::pack_unaligned_inner(const BVHStackEntry& e,
num);
}
void QBVH::pack_unaligned_node(int idx,
void BVH4::pack_unaligned_node(int idx,
const Transform *aligned_space,
const BoundBox *bounds,
const int *child,
@ -999,7 +999,7 @@ void QBVH::pack_unaligned_node(int idx,
/* Quad SIMD Nodes */
void QBVH::pack_nodes(const BVHNode *root)
void BVH4::pack_nodes(const BVHNode *root)
{
/* Calculate size of the arrays required. */
const size_t num_nodes = root->getSubtreeSize(BVH_STAT_QNODE_COUNT);
@ -1096,7 +1096,7 @@ void QBVH::pack_nodes(const BVHNode *root)
pack.root_index = (root->is_leaf())? -1: 0;
}
void QBVH::refit_nodes()
void BVH4::refit_nodes()
{
assert(!params.top_level);
@ -1105,7 +1105,7 @@ void QBVH::refit_nodes()
refit_node(0, (pack.root_index == -1)? true: false, bbox, visibility);
}
void QBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
void BVH4::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility)
{
if(leaf) {
int4 *data = &pack.leaf_nodes[idx];

@ -110,15 +110,15 @@ protected:
virtual void refit_nodes() = 0;
};
/* Binary BVH
/* BVH2
*
* Typical BVH with each node having two children. */
class BinaryBVH : public BVH {
class BVH2 : public BVH {
protected:
/* constructor */
friend class BVH;
BinaryBVH(const BVHParams& params, const vector<Object*>& objects);
BVH2(const BVHParams& params, const vector<Object*>& objects);
/* pack */
void pack_nodes(const BVHNode *root);
@ -154,15 +154,15 @@ protected:
void refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility);
};
/* QBVH
/* BVH4
*
* Quad BVH, with each node having four children, to use with SIMD instructions. */
class QBVH : public BVH {
class BVH4 : public BVH {
protected:
/* constructor */
friend class BVH;
QBVH(const BVHParams& params, const vector<Object*>& objects);
BVH4(const BVHParams& params, const vector<Object*>& objects);
/* pack */
void pack_nodes(const BVHNode *root);