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:
authorStefan Werner <stefan.werner@tangent-animation.com>2018-11-07 14:58:12 +0300
committerStefan Werner <stefan.werner@tangent-animation.com>2018-11-07 14:58:12 +0300
commit2c5531c0a521119a2f5c88b4ba2a67234c537d2b (patch)
treee1b27e6714a5746840cce4421cb9a3877c14fc97 /intern/cycles/render/mesh.cpp
parent8a014e780e504cb6e851af9a6c1b591e1bd9da0f (diff)
Cycles: Added Embree as BVH option for CPU renders.
Note that this is turned off by default and must be enabled at build time with the CMake WITH_CYCLES_EMBREE flag. Embree must be built as a static library with ray masking turned on, the `make deps` scripts have been updated accordingly. There, Embree is off by default too and must be enabled with the WITH_EMBREE flag. Using Embree allows for much faster rendering of deformation motion blur while reducing the memory footprint. TODO: GPU implementation, deduplication of data, leveraging more of Embrees features (e.g. tessellation cache). Differential Revision: https://developer.blender.org/D3682
Diffstat (limited to 'intern/cycles/render/mesh.cpp')
-rw-r--r--intern/cycles/render/mesh.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 6f619380988..adc9a076fa4 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -39,6 +39,10 @@
#include "util/util_progress.h"
#include "util/util_set.h"
+#ifdef WITH_EMBREE
+# include "bvh/bvh_embree.h"
+#endif
+
CCL_NAMESPACE_BEGIN
/* Triangle */
@@ -1073,6 +1077,9 @@ void Mesh::compute_bvh(Device *device,
params->use_bvh_unaligned_nodes;
bparams.num_motion_triangle_steps = params->num_bvh_time_steps;
bparams.num_motion_curve_steps = params->num_bvh_time_steps;
+ bparams.bvh_type = params->bvh_type;
+ bparams.curve_flags = dscene->data.curve.curveflags;
+ bparams.curve_subdivisions = dscene->data.curve.subdivisions;
delete bvh;
bvh = BVH::create(bparams, objects);
@@ -1861,14 +1868,32 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *
scene->params.use_bvh_unaligned_nodes;
bparams.num_motion_triangle_steps = scene->params.num_bvh_time_steps;
bparams.num_motion_curve_steps = scene->params.num_bvh_time_steps;
+ bparams.bvh_type = scene->params.bvh_type;
+ bparams.curve_flags = dscene->data.curve.curveflags;
+ bparams.curve_subdivisions = dscene->data.curve.subdivisions;
VLOG(1) << "Using " << bvh_layout_name(bparams.bvh_layout)
<< " layout.";
+#ifdef WITH_EMBREE
+ if(bparams.bvh_layout == BVH_LAYOUT_EMBREE) {
+ if(dscene->data.bvh.scene) {
+ BVHEmbree::destroy(dscene->data.bvh.scene);
+ }
+ }
+#endif
+
BVH *bvh = BVH::create(bparams, scene->objects);
- bvh->build(progress);
+ bvh->build(progress, &device->stats);
if(progress.get_cancel()) {
+#ifdef WITH_EMBREE
+ if(bparams.bvh_layout == BVH_LAYOUT_EMBREE) {
+ if(dscene->data.bvh.scene) {
+ BVHEmbree::destroy(dscene->data.bvh.scene);
+ }
+ }
+#endif
delete bvh;
return;
}
@@ -1923,6 +1948,16 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *
dscene->data.bvh.bvh_layout = bparams.bvh_layout;
dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0);
+
+#ifdef WITH_EMBREE
+ if(bparams.bvh_layout == BVH_LAYOUT_EMBREE) {
+ dscene->data.bvh.scene = ((BVHEmbree*)bvh)->scene;
+ }
+ else {
+ dscene->data.bvh.scene = NULL;
+ }
+#endif
+
delete bvh;
}