[Bf-blender-cvs] [ad6db67771f] soc-2019-embree-gpu: Add support for linear interpolation on bounding box
MATILLAT Quentin
noreply at git.blender.org
Fri Jul 26 18:58:57 CEST 2019
Commit: ad6db67771ff82ad79d99c00070b7d0ced15a65f
Author: MATILLAT Quentin
Date: Fri Jul 26 12:16:10 2019 +0200
Branches: soc-2019-embree-gpu
https://developer.blender.org/rBad6db67771ff82ad79d99c00070b7d0ced15a65f
Add support for linear interpolation on bounding box
===================================================================
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_embree_converter.h
M intern/cycles/bvh/bvh_node.cpp
M intern/cycles/bvh/bvh_node.h
M intern/cycles/kernel/bvh/bvh_nodes.h
M intern/cycles/kernel/kernel_types.h
===================================================================
diff --git a/intern/cycles/bvh/bvh2.cpp b/intern/cycles/bvh/bvh2.cpp
index ed355f16efa..6a2875adaac 100644
--- a/intern/cycles/bvh/bvh2.cpp
+++ b/intern/cycles/bvh/bvh2.cpp
@@ -76,8 +76,6 @@ void BVH2::pack_aligned_inner(const BVHStackEntry &e,
e1.node->bounds,
e0.encodeIdx(),
e1.encodeIdx(),
- 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 +85,6 @@ void BVH2::pack_aligned_node(int idx,
const BoundBox &b1,
int c0,
int c1,
- float2 time0,
- float2 time1,
uint visibility0,
uint visibility1)
{
@@ -96,19 +92,9 @@ void BVH2::pack_aligned_node(int idx,
assert(c0 < 0 || c0 < pack.nodes.size());
assert(c1 < 0 || c1 < pack.nodes.size());
- if(time0.x > 0 || time0.y < 1)
- visibility0 |= PATH_RAY_NODE_4D;
- else
- visibility0 &= ~PATH_RAY_NODE_4D;
-
- if(time1.x > 0 || time1.y < 1)
- visibility1 |= PATH_RAY_NODE_4D;
- else
- visibility1 &= ~PATH_RAY_NODE_4D;
-
int4 data[BVH_NODE_SIZE] = {
make_int4(
- visibility0 & ~PATH_RAY_NODE_UNALIGNED, visibility1 & ~PATH_RAY_NODE_UNALIGNED, c0, c1),
+ visibility0 & ~PATH_RAY_NODE_CLEAR, visibility1 & ~PATH_RAY_NODE_CLEAR, c0, c1),
make_int4(__float_as_int(b0.min.x),
__float_as_int(b1.min.x),
__float_as_int(b0.max.x),
@@ -121,10 +107,6 @@ 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(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);
@@ -162,8 +144,8 @@ void BVH2::pack_unaligned_node(int idx,
float4 data[BVH_UNALIGNED_NODE_SIZE];
Transform space0 = BVHUnaligned::compute_node_transform(bounds0, aligned_space0);
Transform space1 = BVHUnaligned::compute_node_transform(bounds1, aligned_space1);
- data[0] = make_float4(__int_as_float(visibility0 | PATH_RAY_NODE_UNALIGNED),
- __int_as_float(visibility1 | PATH_RAY_NODE_UNALIGNED),
+ data[0] = make_float4(__int_as_float((visibility0 & ~PATH_RAY_NODE_CLEAR) | PATH_RAY_NODE_UNALIGNED),
+ __int_as_float((visibility1 & ~PATH_RAY_NODE_CLEAR) | PATH_RAY_NODE_UNALIGNED),
__int_as_float(c0),
__int_as_float(c1));
@@ -303,8 +285,6 @@ void BVH2::refit_node(int idx, bool leaf, BoundBox &bbox, uint &visibility)
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);
}
diff --git a/intern/cycles/bvh/bvh2.h b/intern/cycles/bvh/bvh2.h
index 3a371a1d79c..c6a4e6fa73a 100644
--- a/intern/cycles/bvh/bvh2.h
+++ b/intern/cycles/bvh/bvh2.h
@@ -34,7 +34,7 @@ class LeafNode;
class Object;
class Progress;
-#define BVH_NODE_SIZE (4+1)
+#define BVH_NODE_SIZE 4
#define BVH_NODE_LEAF_SIZE 1
#define BVH_UNALIGNED_NODE_SIZE 7
@@ -65,8 +65,6 @@ class BVH2 : public BVH {
const BoundBox &b1,
int c0,
int c1,
- 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 162485a621a..e9e72aa1f6b 100644
--- a/intern/cycles/bvh/bvh_embree_converter.cpp
+++ b/intern/cycles/bvh/bvh_embree_converter.cpp
@@ -88,19 +88,24 @@ BVHNode *bvh_shrink(BVHNode *root) {
// We have 2 node or more, we'll pack them into 2 nodes (to respect BVH2)
node->num_children_ = 2;
-
if(num_children == 2) {
node->children[0] = children[0];
node->children[1] = children[1];
return node;
}
- node->children[0] = new InnerNode(merge(children[0]->bounds, children[1]->bounds), children[0], children[1]);
+ // node->children[0] = new InnerNode(merge(children[0]->bounds, children[1]->bounds), children[0], children[1]);
+ node->children[0] = new InnerNode(node->bounds, children[0], children[1]);
+ if(node->deltaBounds != nullptr) node->children[0]->deltaBounds = new BoundBox(*node->deltaBounds);
+
if(num_children == 3) {
- node->children[1] = node->children[2];
+ node->children[1] = children[2];
} else {
- node->children[1] = new InnerNode(merge(children[2]->bounds, children[3]->bounds), children[2], children[3]);
+ // node->children[1] = new InnerNode(merge(children[2]->bounds, children[3]->bounds), children[2], children[3]);
+ node->children[1] = new InnerNode(node->bounds, children[2], children[3]);
+ if(node->deltaBounds != nullptr) node->children[1]->deltaBounds = new BoundBox(*node->deltaBounds);
}
+
return node;
}
@@ -126,15 +131,43 @@ std::deque<BVHNode*> BVHEmbreeConverter::handleLeaf<embree::Triangle4i>(const em
const int object_id = geom_id / 2;
Object *obj = this->objects.at(object_id);
+ Mesh::Triangle tri = obj->mesh->get_triangle(prim_id);
int prim_type = obj->mesh->has_motion_blur() ? PRIMITIVE_MOTION_TRIANGLE : PRIMITIVE_TRIANGLE;
visibility |= obj->visibility;
packPush(this->pack, this->packIdx++, object_id, prim_id, prim_type, obj->visibility, this->pack->prim_tri_verts.size());
+
+ /*
pushVec(this->pack,
prims[i].getVertex(prims[i].v0, j, this->s),
prims[i].getVertex(prims[i].v1, j, this->s),
prims[i].getVertex(prims[i].v2, j, this->s));
+ */
+
+ this->pack->prim_tri_verts.push_back_slow(float3_to_float4(obj->mesh->verts[tri.v[0]]));
+ this->pack->prim_tri_verts.push_back_slow(float3_to_float4(obj->mesh->verts[tri.v[1]]));
+ this->pack->prim_tri_verts.push_back_slow(float3_to_float4(obj->mesh->verts[tri.v[2]]));
+
+ /*
+ std::cout << "Vertex " << prim_id << " "
+ << prims[i].getVertex(prims[i].v0, j, this->s) << ", "
+ << prims[i].getVertex(prims[i].v1, j, this->s) << ", "
+ << prims[i].getVertex(prims[i].v2, j, this->s) << std::endl;
+
+ std::cout << "VERTEX " << prim_id << " "
+ << "(" << obj->mesh->verts[tri.v[0]].x << ", " << obj->mesh->verts[tri.v[0]].y << ", " << obj->mesh->verts[tri.v[0]].z << "), "
+ << "(" << obj->mesh->verts[tri.v[1]].x << ", " << obj->mesh->verts[tri.v[1]].y << ", " << obj->mesh->verts[tri.v[1]].z << "), "
+ << "(" << obj->mesh->verts[tri.v[2]].x << ", " << obj->mesh->verts[tri.v[2]].y << ", " << obj->mesh->verts[tri.v[2]].z << ")" << std::endl;
+
+ std::cout << "Indices "
+ << prims[i].v0[j] << ", "
+ << prims[i].v1[j] << ", "
+ << prims[i].v2[j] << " <=> "
+ << tri.v[0] << ", "
+ << tri.v[1] << ", "
+ << tri.v[2] << std::endl;
+ */
}
}
@@ -208,7 +241,7 @@ std::deque<BVHNode*> BVHEmbreeConverter::handleLeaf<embree::InstancePrimitive>(c
}
template<typename Primitive>
-BVHNode* BVHEmbreeConverter::nodeEmbreeToCcl(embree::BVH4::NodeRef node, ccl::BoundBox bb) {
+BVHNode* BVHEmbreeConverter::nodeEmbreeToCcl(embree::BVH4::NodeRef node, ccl::BoundBox bb, ccl::BoundBox *t0bound, ccl::BoundBox *deltaBound) {
if(node.isLeaf()) {
BVHNode *ret = nullptr;
std::deque<BVHNode *> nodes = this->handleLeaf<Primitive>(node, bb);
@@ -237,74 +270,73 @@ BVHNode* BVHEmbreeConverter::nodeEmbreeToCcl(embree::BVH4::NodeRef node, ccl::Bo
}
return ret;
- } else {
- InnerNode *ret = nullptr;
+ }
- if(node.isAlignedNode()) {
- embree::BVH4::AlignedNode *anode = node.alignedNode();
+ InnerNode *ret = nullptr;
+ int nb = 0;
+ BVHNode *children[4];
- int nb = 0;
- BVHNode *children[4];
- for(uint i = 0; i < 4; i++) {
- BVHNode *child = this->nodeEmbreeToCcl<Primitive>(anode->children[i], RTCBoundBoxToCCL(anode->bounds(i)));
- if(child != nullptr)
- children[nb++] = child;
- }
+ if(node.isAlignedNode()) {
+ embree::BVH4::AlignedNode *anode = node.alignedNode();
- ret = new InnerNode(
- bb,
- children,
- nb);
- } else if(node.isAlignedNodeMB()) {
- embree::BVH4::AlignedNodeMB *anode = node.alignedNodeMB();
-
- int nb = 0;
- BVHNode *children[4];
- for(uint i = 0; i < 4; i++) {
- BVHNode *child = this->nodeEmbreeToCcl<Primitive>(anode->children[i], RTCBoundBoxToCCL(anode->bounds(i)));
- if(child != nullptr) {
- children[nb++] = child;
- }
- }
+ for(uint i = 0; i < 4; i++) {
+ BVHNode *child = this->nodeEmbreeToCcl<Primitive>(anode->children[i], RTCBoundBoxToCCL(anode->bounds(i)));
+ if(child != nullptr)
+ children[nb++] = child;
+ }
- ret = new InnerNode(
- bb,
- children,
- nb);
- } else if (node.isUnalignedNo
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list