[Bf-blender-cvs] [04ffa455a16] cycles_embree: Cycles: Updated Embree integration to version 3.2
Stefan Werner
noreply at git.blender.org
Wed Aug 1 23:00:14 CEST 2018
Commit: 04ffa455a16447bef8c11d70c3ee10520352f1ab
Author: Stefan Werner
Date: Wed Aug 1 23:00:08 2018 +0200
Branches: cycles_embree
https://developer.blender.org/rB04ffa455a16447bef8c11d70c3ee10520352f1ab
Cycles: Updated Embree integration to version 3.2
===================================================================
M build_files/cmake/platform/platform_apple.cmake
M build_files/cmake/platform/platform_unix.cmake
M build_files/cmake/platform/platform_win32.cmake
M build_files/cmake/platform/platform_win32_msvc.cmake
M intern/cycles/bvh/bvh_embree.cpp
M intern/cycles/bvh/bvh_embree.h
M intern/cycles/kernel/bvh/bvh.h
M intern/cycles/kernel/bvh/bvh_embree_traversal.h
M intern/cycles/kernel/kernel_types.h
M intern/cycles/render/mesh.cpp
===================================================================
diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 70f203b0d01..020d775470e 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -385,7 +385,7 @@ if(WITH_CYCLES_OSL)
endif()
if(WITH_CYCLES_EMBREE)
- find_package(embree 2.16.1 REQUIRED)
+ find_package(embree 3.2 REQUIRED)
endif()
if(WITH_OPENMP)
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 03a282c70e3..1ee98a8e600 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -353,7 +353,7 @@ if(WITH_OPENCOLORIO)
endif()
if(WITH_CYCLES_EMBREE)
- find_package(embree 2.16.1 REQUIRED)
+ find_package(embree 3.2 REQUIRED)
endif()
if(WITH_LLVM)
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index 19636b22f3a..a6e7cb4f0e2 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -602,5 +602,5 @@ if(WITH_CYCLES_OSL)
endif()
if(WITH_CYCLES_EMBREE)
- find_package(embree 2.16.1 REQUIRED)
+ find_package(embree 3.2 REQUIRED)
endif()
diff --git a/build_files/cmake/platform/platform_win32_msvc.cmake b/build_files/cmake/platform/platform_win32_msvc.cmake
index ce6cc3f0e51..120ce2987f7 100644
--- a/build_files/cmake/platform/platform_win32_msvc.cmake
+++ b/build_files/cmake/platform/platform_win32_msvc.cmake
@@ -422,7 +422,7 @@ if(WITH_OPENCOLORIO)
endif()
if(WITH_CYCLES_EMBREE)
- find_package(embree 2.16.1 REQUIRED)
+ find_package(embree 3.2 REQUIRED)
endif()
if(WITH_OPENVDB)
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index e45cfe79184..75f69f67363 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -24,7 +24,7 @@
#include "util/util_foreach.h"
#include "util/util_logging.h"
-#include "embree2/rtcore_geometry.h"
+#include "embree3/rtcore_geometry.h"
/* Kernel includes are necessary so that the filter function for Embree can access the packed BVH. */
#include "kernel/kernel_compat_cpu.h"
@@ -36,10 +36,6 @@
#include "xmmintrin.h"
#include "pmmintrin.h"
-/* this doesn't work with refitting unforutnately
- * #define EMBREE_SHARED_MEM 1
- */
-
CCL_NAMESPACE_BEGIN
/* This gets called by Embree at every valid ray/object intersection.
@@ -48,32 +44,35 @@ CCL_NAMESPACE_BEGIN
* Cycles' own BVH does that directly inside the traversal calls.
*/
-
-void rtc_filter_func(void*, RTCRay& ray_);
-void rtc_filter_func(void*, RTCRay& ray_)
+void rtc_filter_func(const RTCFilterFunctionNArguments* args);
+void rtc_filter_func(const RTCFilterFunctionNArguments* args)
{
- CCLRay &ray = (CCLRay&)ray_;
- KernelGlobals *kg = ray.kg;
+ assert(args->N == 1);
+
+ const RTCRay *ray = (RTCRay*)args->ray;
+ RTCHit *hit = (RTCHit*)args->hit;
+ CCLIntersectContext *ctx = ((IntersectContext*)args->context)->userRayExt;
+ KernelGlobals *kg = ctx->kg;
/* For all ray types: check if there is backfacing hair to ignore */
if((kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE)
- && !(kernel_data.curve.curveflags & CURVE_KN_BACKFACING)
- && !(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) && ray.geomID & 1) {
- if(dot(make_float3(ray.dir[0], ray.dir[1], ray.dir[2]), make_float3(ray.Ng[0], ray.Ng[1], ray.Ng[2])) > 0.0f) {
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ && !(kernel_data.curve.curveflags & CURVE_KN_BACKFACING)
+ && !(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) && hit->geomID & 1) {
+ if(dot(make_float3(ray->dir_x, ray->dir_y, ray->dir_z), make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)) > 0.0f) {
+ hit->geomID = RTC_INVALID_GEOMETRY_ID;
return;
}
}
- if(ray.type == CCLRay::RAY_REGULAR) {
+ if(ctx->type == CCLIntersectContext::RAY_REGULAR) {
return;
}
- else if(ray.type == CCLRay::RAY_SHADOW_ALL) {
+ else if(ctx->type == CCLIntersectContext::RAY_SHADOW_ALL) {
/* Append the intersection to the end of the array. */
- if(ray.num_hits < ray.max_hits) {
- Intersection *isect = &ray.isect_s[ray.num_hits];
- ray.num_hits++;
- ray.isect_to_ccl(isect);
+ if(ctx->num_hits < ctx->max_hits) {
+ Intersection *isect = &ctx->isect_s[ctx->num_hits];
+ ctx->num_hits++;
+ kernel_embree_convert_hit(kg, ray, hit, isect);
int prim = kernel_tex_fetch(__prim_index, isect->prim);
int shader = 0;
if(kernel_tex_fetch(__prim_type, isect->prim) & PRIMITIVE_ALL_TRIANGLE) {
@@ -87,80 +86,81 @@ void rtc_filter_func(void*, RTCRay& ray_)
/* If no transparent shadows, all light is blocked. */
if(flag & (SD_HAS_TRANSPARENT_SHADOW)) {
/* This tells Embree to continue tracing. */
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ hit->geomID = RTC_INVALID_GEOMETRY_ID;
}
else {
- ray.num_hits = ray.max_hits+1;
+ ctx->num_hits = ctx->max_hits+1;
}
}
else {
/* Increase the number of hits beyond ray.max_hits
* so that the caller can detect this as opaque. */
- ray.num_hits++;
+ ctx->num_hits++;
}
return;
}
- else if(ray.type == CCLRay::RAY_SSS) {
+ else if(ctx->type == CCLIntersectContext::RAY_SSS) {
/* No intersection information requested, just return a hit. */
- if(ray.ss_isect->num_hits == 0) {
+ if(ctx->ss_isect->num_hits == 0) {
return;
}
/* Only accept hits from the same object and triangles. */
- if(ray.instID/2 != ray.sss_object_id || ray.geomID & 1) {
+ if(hit->instID[0]/2 != ctx->sss_object_id || hit->geomID & 1) {
/* This tells Embree to continue tracing. */
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ hit->geomID = RTC_INVALID_GEOMETRY_ID;
return;
}
/* See triangle_intersect_subsurface() for the native equivalent. */
- for(int i = min(ray.max_hits, ray.ss_isect->num_hits) - 1; i >= 0; --i) {
- if(ray.ss_isect->hits[i].t == ray.tfar) {
+ for(int i = min(ctx->max_hits, ctx->ss_isect->num_hits) - 1; i >= 0; --i) {
+ if(ctx->ss_isect->hits[i].t == ray->tfar) {
/* This tells Embree to continue tracing. */
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ hit->geomID = RTC_INVALID_GEOMETRY_ID;
return;
}
}
- ray.ss_isect->num_hits++;
- int hit;
+ ctx->ss_isect->num_hits++;
+ int hit_idx;
- if(ray.ss_isect->num_hits <= ray.max_hits) {
- hit = ray.ss_isect->num_hits - 1;
+ if(ctx->ss_isect->num_hits <= ctx->max_hits) {
+ hit_idx = ctx->ss_isect->num_hits - 1;
}
else {
/* reservoir sampling: if we are at the maximum number of
* hits, randomly replace element or skip it */
- hit = lcg_step_uint(ray.lcg_state) % ray.ss_isect->num_hits;
+ hit_idx = lcg_step_uint(ctx->lcg_state) % ctx->ss_isect->num_hits;
- if(hit >= ray.max_hits) {
+ if(hit_idx >= ctx->max_hits) {
/* This tells Embree to continue tracing. */
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ hit->geomID = RTC_INVALID_GEOMETRY_ID;
return;
}
}
/* record intersection */
- ray.isect_to_ccl(&ray.ss_isect->hits[hit]);
- ray.ss_isect->Ng[hit].x = -ray.Ng[0];
- ray.ss_isect->Ng[hit].y = -ray.Ng[1];
- ray.ss_isect->Ng[hit].z = -ray.Ng[2];
- ray.ss_isect->Ng[hit] = normalize(ray.ss_isect->Ng[hit]);
+ kernel_embree_convert_hit(kg, ray, hit, &ctx->ss_isect->hits[hit_idx]);
+ ctx->ss_isect->Ng[hit_idx].x = hit->Ng_x;
+ ctx->ss_isect->Ng[hit_idx].y = hit->Ng_y;
+ ctx->ss_isect->Ng[hit_idx].z = hit->Ng_z;
+ ctx->ss_isect->Ng[hit_idx] = normalize(ctx->ss_isect->Ng[hit_idx]);
/* this tells Embree to continue tracing */
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ hit->geomID = RTC_INVALID_GEOMETRY_ID;
return;
- } else if(ray.type == CCLRay::RAY_VOLUME_ALL) {
+ }
+ else if(ctx->type == CCLIntersectContext::RAY_VOLUME_ALL) {
/* Append the intersection to the end of the array. */
- if(ray.num_hits < ray.max_hits) {
- Intersection *isect = &ray.isect_s[ray.num_hits];
- ray.num_hits++;
- ray.isect_to_ccl(isect);
+ if(ctx->num_hits < ctx->max_hits) {
+ Intersection *isect = &ctx->isect_s[ctx->num_hits];
+ ctx->num_hits++;
+ kernel_embree_convert_hit(kg, ray, hit, isect);
/* Only primitives from volume object. */
uint tri_object = (isect->object == OBJECT_NONE) ?kernel_tex_fetch(__prim_object, isect->prim) : isect->object;
int object_flag = kernel_tex_fetch(__object_flag, tri_object);
if((object_flag & SD_OBJECT_HAS_VOLUME) == 0) {
- ray.num_hits--;
+ ctx->num_hits--;
}
/* This tells Embree to continue tracing. */
- ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ hit->geomID = RTC_INVALID_GEOMETRY_ID;
return;
}
return;
@@ -178,6 +178,12 @@ bool rtc_memory_monitor_func(void* userPtr, const ssize_t bytes, const bool)
return true;
}
+
+void rtc_error_func(void*, enum RTCError code, const char* str)
+{
+ VLOG(0) << str;
+}
+
static double progress_start_time = 0.0f;
bool rtc_progress_func(void* user_ptr, const double n);
@@ -203,8 +209,8 @@ thread_mutex BVHEmbree::rtc_shared_mutex;
BVHEmbree::BVHEmbree(const BVHParams& params_, const vector<Object*>& objects_)
: BVH(params_, objects_), scene(NULL), mem_used(0), top_level(NULL), stats(NULL),
- curve_subdivisions(params.curve_subdivisions), use_curves(params_.curve_flags & CURVE_KN_INTERPOLATE),
- use_ribbons(params.curve_flags & CURVE_KN_RIBBONS), dynamic_scene(true)
+curve_subdivisions(params.curve_subdivisions), use_curves(params_.curve_flags & CURVE_KN_INTERPOLATE),
+use_ribbons(params.curve_flags & CURVE_KN_RIBBONS), dynamic_scene(true)
{
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
@@ -213,40 +219,36 @@ BVHEmbree::BVHEmbree(const BVHParams& params_, const vector<Object*>& objects_)
rtc_shared_device = rtcNewDevice("verbose=1");
/* Check here if Embree was built with the correct flags. */
- ssize_t ret = rtcDeviceGetParameter1i(rtc_shared_device, RTC_CONFIG_RAY_MASK);
- if(ret != 1) {
- assert(0);
- VLOG(1) << "Embree is compiled without the EMBREE_RAY_MASK flag. Ray visiblity will not work.";
- }
- ret = rtcDeviceGetParameter1i(rtc_shared_device, RTC_CONFIG_INTERSECTION_FILTER);
+ ssize_t ret = rtcGetDevicePropert
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list