[Bf-blender-cvs] [c9052dc995c] cycles_embree: Merge branch 'master' of git.blender.org:blender into cycles_embree
Stefan Werner
noreply at git.blender.org
Tue Mar 20 12:33:14 CET 2018
Commit: c9052dc995cd74f477af030e8e71222a26ffde19
Author: Stefan Werner
Date: Tue Mar 20 12:33:01 2018 +0100
Branches: cycles_embree
https://developer.blender.org/rBc9052dc995cd74f477af030e8e71222a26ffde19
Merge branch 'master' of git.blender.org:blender into cycles_embree
# Conflicts:
# intern/cycles/bvh/bvh.cpp
# intern/cycles/device/device.cpp
# intern/cycles/device/device.h
# intern/cycles/device/device_cpu.cpp
# intern/cycles/kernel/geom/geom_object.h
# intern/cycles/render/mesh.cpp
# intern/cycles/render/scene.h
===================================================================
===================================================================
diff --cc CMakeLists.txt
index c09230aaf5d,9909544cd1a..dd24ea7cb60
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -407,10 -406,10 +406,11 @@@ option(WITH_CYCLES "Enable Cycles R
option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
option(WITH_CYCLES_STANDALONE_GUI "Build Cycles standalone with GUI" OFF)
option(WITH_CYCLES_OSL "Build Cycles with OSL support" ${_init_CYCLES_OSL})
+option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON)
option(WITH_CYCLES_OPENSUBDIV "Build Cycles with OpenSubdiv support" ${_init_CYCLES_OPENSUBDIV})
option(WITH_CYCLES_CUDA_BINARIES "Build Cycles CUDA binaries" OFF)
- set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
+ option(WITH_CYCLES_CUBIN_COMPILER "Build cubins with nvrtc based compiler instead of nvcc" OFF)
+ set(CYCLES_CUDA_BINARIES_ARCH sm_30 sm_35 sm_37 sm_50 sm_52 sm_60 sm_61 CACHE STRING "CUDA architectures to build binaries for")
mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
unset(PLATFORM_DEFAULT)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
diff --cc build_files/cmake/platform/platform_unix.cmake
index 64347f1a5ca,6796e254c27..d6798831522
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@@ -328,11 -348,15 +348,19 @@@ if(WITH_OPENCOLORIO
endif()
endif()
+if(WITH_CYCLES_EMBREE)
+ find_package(embree 2.16.1 REQUIRED)
+endif()
+
if(WITH_LLVM)
+ # Symbol conflicts with same UTF library used by OpenCollada
+ if(EXISTS ${LIBDIR})
+ set(LLVM_STATIC ON)
+ if(WITH_OPENCOLLADA)
+ list(REMOVE_ITEM OPENCOLLADA_LIBRARIES ${OPENCOLLADA_UTF_LIBRARY})
+ endif()
+ endif()
+
find_package_wrapper(LLVM)
if(NOT LLVM_FOUND)
diff --cc intern/cycles/blender/blender_sync.cpp
index 9f286d3a1c4,283aa5600fd..a6e9cfbe617
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@@ -671,8 -662,8 +662,10 @@@ SceneParams BlenderSync::get_scene_para
params.texture_limit = 0;
}
- params.use_qbvh = DebugFlags().cpu.qbvh;
-
+ params.bvh_layout = DebugFlags().cpu.bvh_layout;
-
++#ifdef WITH_EMBREE
++ params.bvh_layout = RNA_boolean_get(&cscene, "use_bvh_embree") ? BVH_LAYOUT_EMBREE : params.bvh_layout;
++#endif
return params;
}
diff --cc intern/cycles/bvh/bvh.cpp
index 81fa47a4830,b524ca07d8d..357d9de28fd
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@@ -25,15 -25,47 +25,52 @@@
#include "bvh/bvh_build.h"
#include "bvh/bvh_node.h"
+#ifdef WITH_EMBREE
+#include "bvh/bvh_embree.h"
+#endif
+
#include "util/util_foreach.h"
+ #include "util/util_logging.h"
#include "util/util_progress.h"
CCL_NAMESPACE_BEGIN
+ /* BVH Parameters. */
+
+ const char *bvh_layout_name(BVHLayout layout)
+ {
+ switch(layout) {
+ case BVH_LAYOUT_BVH2: return "BVH2";
+ case BVH_LAYOUT_BVH4: return "BVH4";
+ case BVH_LAYOUT_NONE: return "NONE";
+ case BVH_LAYOUT_ALL: return "ALL";
++ case BVH_LAYOUT_EMBREE: return "EMBREE";
+ }
+ LOG(DFATAL) << "Unsupported BVH layout was passed.";
+ return "";
+ }
+
+ BVHLayout BVHParams::best_bvh_layout(BVHLayout requested_layout,
+ BVHLayoutMask supported_layouts)
+ {
+ const BVHLayoutMask requested_layout_mask = (BVHLayoutMask)requested_layout;
+ /* Check whether requested layout is supported, if so -- no need to do
+ * any extra computation.
+ */
+ if(supported_layouts & requested_layout_mask) {
+ return requested_layout;
+ }
+ /* Some bit magic to get widest supported BVH layout. */
+ /* This is a mask of supported BVH layouts which are narrower than the
+ * requested one.
+ */
+ const BVHLayoutMask allowed_layouts_mask =
+ (supported_layouts & (requested_layout_mask - 1));
+ /* We get widest from allowed ones and convert mask to actual layout. */
+ const BVHLayoutMask widest_allowed_layout_mask = __bsr(allowed_layouts_mask);
+ return (BVHLayout)(1 << widest_allowed_layout_mask);
+ }
+
/* Pack Utility */
BVHStackEntry::BVHStackEntry(const BVHNode *n, int i)
@@@ -55,14 -87,17 +92,19 @@@ BVH::BVH(const BVHParams& params_, cons
BVH *BVH::create(const BVHParams& params, const vector<Object*>& objects)
{
- #ifdef WITH_EMBREE
- if(params.use_bvh_embree)
- return new BVHEmbree(params, objects);
- #endif
- if(params.use_qbvh)
- return new BVH4(params, objects);
- else
- return new BVH2(params, objects);
+ switch(params.bvh_layout) {
+ case BVH_LAYOUT_BVH2:
+ return new BVH2(params, objects);
+ case BVH_LAYOUT_BVH4:
+ return new BVH4(params, objects);
++ case BVH_LAYOUT_EMBREE:
++ return new BVHEmbree(params, objects);
+ case BVH_LAYOUT_NONE:
+ case BVH_LAYOUT_ALL:
+ break;
+ }
+ LOG(DFATAL) << "Requested unsupported BVH layout.";
+ return NULL;
}
/* Building */
diff --cc intern/cycles/bvh/bvh_embree.cpp
index f0d2fc162e2,00000000000..ac2bd0e756e
mode 100644,000000..100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@@ -1,868 -1,0 +1,866 @@@
+/*
+ * Copyright 2017, Blender Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef WITH_EMBREE
+
+#include "bvh/bvh_embree.h"
+
+#include "render/mesh.h"
+#include "render/object.h"
+#include "util/util_progress.h"
+#include "util/util_foreach.h"
+#include "util/util_logging.h"
+
+#include "embree2/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"
+#include "kernel/split/kernel_split_data_types.h"
+#include "kernel/kernel_globals.h"
+#include "kernel/kernel_random.h"
+#include "kernel/bvh/bvh_embree_traversal.h"
+
+#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.
+ * Things like recording subsurface or shadow hits for later evaluation
+ * as well as filtering for volume objects happen here.
+ * Cycles' own BVH does that directly inside the traversal calls.
+ */
+
+
+void rtc_filter_func(void*, RTCRay& ray_);
+void rtc_filter_func(void*, RTCRay& ray_)
+{
+ CCLRay &ray = (CCLRay&)ray_;
+ KernelGlobals *kg = ray.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;
+ return;
+ }
+ }
+
+ if(ray.type == CCLRay::RAY_REGULAR) {
+ return;
+ }
+ else if(ray.type == CCLRay::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);
+ int prim = kernel_tex_fetch(__prim_index, isect->prim);
+ int shader = 0;
- if(kernel_tex_fetch(__prim_type, isect->prim) & PRIMITIVE_ALL_TRIANGLE)
- {
++ if(kernel_tex_fetch(__prim_type, isect->prim) & PRIMITIVE_ALL_TRIANGLE) {
+ shader = kernel_tex_fetch(__tri_shader, prim);
+ }
+ else {
+ float4 str = kernel_tex_fetch(__curves, prim);
+ shader = __float_as_int(str.z);
+ }
- int flag = kernel_tex_fetch(__shader_flag, (shader & SHADER_MASK)*SHADER_SIZE);
++ int flag = kernel_tex_fetch(__shaders, shader & SHADER_MASK).flags;
+ /* 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;
+ }
+ else {
+ ray.num_hits = ray.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++;
+ }
+ return;
+ }
+ else if(ray.type == CCLRay::RAY_SSS) {
+ /* Only accept hits from the same object and triangles. */
+ if(ray.instID/2 != ray.sss_object_id || ray.geomID & 1) {
+ /* This tells Embree to continue tracing. */
+ ray.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) {
+ /* This tells Embree to continue tracing. */
+ ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ return;
+ }
+ }
+
+ ray.ss_isect->num_hits++;
+ int hit;
+
+ if(ray.ss_isect->num_hits <= ray.max_hits) {
+ hit = ray.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;
+
+ if(hit >= ray.max_hits) {
+ /* This tells Embree to continue tracing. */
+ ray.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]);
+ /* this tells Embree to continue tracing */
+ ray.geomID = RTC_INVALID_GEOMETRY_ID;
+ return;
+ } else if(
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list