[Bf-blender-cvs] [46c0763187a] soc-2019-embree-gpu: Cycles: Remove unused BVH Builder using Embree BVH
MATILLAT Quentin
noreply at git.blender.org
Mon Aug 19 18:37:05 CEST 2019
Commit: 46c0763187abceef77133adb53993fbb3d067952
Author: MATILLAT Quentin
Date: Sun Aug 18 15:56:51 2019 +0200
Branches: soc-2019-embree-gpu
https://developer.blender.org/rB46c0763187abceef77133adb53993fbb3d067952
Cycles: Remove unused BVH Builder using Embree BVH
===================================================================
M intern/cycles/blender/addon/properties.py
M intern/cycles/blender/blender_sync.cpp
M intern/cycles/bvh/CMakeLists.txt
M intern/cycles/bvh/bvh.cpp
D intern/cycles/bvh/bvh_embree_gpu.cpp
D intern/cycles/bvh/bvh_embree_gpu.h
M intern/cycles/device/device_cpu.cpp
M intern/cycles/device/device_cuda.cpp
M intern/cycles/kernel/kernel_types.h
M intern/cycles/render/mesh.cpp
===================================================================
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 4da89ebd4a1..88dbfcdcc1e 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -61,7 +61,6 @@ enum_bvh_builder = (
('INTERNAL', "Internal", "Use old internal BVH builder"),
('EMBREE', "Embree", "Use full featured embree (only on CPU)"),
('EMBREE_CONVERT', "Embree, then convert", "Use embree, then convert it to BVH2"),
- ('EMBREE_BUILDER', "Embree builder", "Use Embree BVH Builder"),
)
enum_bvh_types = (
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index e249c86f403..9a88076db10 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -702,9 +702,6 @@ SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background)
case 2:
params.bvh_layout = BVH_LAYOUT_EMBREE_CONVERTED;
break;
- case 3:
- params.bvh_layout = BVH_LAYOUT_EMBREE_GPU;
- break;
}
#endif
return params;
diff --git a/intern/cycles/bvh/CMakeLists.txt b/intern/cycles/bvh/CMakeLists.txt
index f85a484a194..740ecaacca8 100644
--- a/intern/cycles/bvh/CMakeLists.txt
+++ b/intern/cycles/bvh/CMakeLists.txt
@@ -14,7 +14,6 @@ set(SRC
bvh_binning.cpp
bvh_build.cpp
bvh_embree.cpp
- bvh_embree_gpu.cpp
bvh_node.cpp
bvh_sort.cpp
bvh_split.cpp
@@ -30,7 +29,6 @@ set(SRC_HEADERS
bvh_binning.h
bvh_build.h
bvh_embree.h
- bvh_embree_gpu.h
bvh_node.h
bvh_params.h
bvh_sort.h
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 715651c96a8..525af8123d4 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -28,7 +28,6 @@
#ifdef WITH_EMBREE
# include "bvh/bvh_embree.h"
-# include "bvh/bvh_embree_gpu.h"
#endif
#include "util/util_foreach.h"
@@ -54,8 +53,6 @@ const char *bvh_layout_name(BVHLayout layout)
return "EMBREE";
case BVH_LAYOUT_EMBREE_CONVERTED:
return "EMBREE_CONVERTED";
- case BVH_LAYOUT_EMBREE_GPU:
- return "EMBREE_GPU";
case BVH_LAYOUT_ALL:
return "ALL";
}
@@ -114,10 +111,6 @@ BVH *BVH::create(const BVHParams ¶ms, const vector<Object *> &objects)
case BVH_LAYOUT_EMBREE_CONVERTED:
#ifdef WITH_EMBREE
return new BVHEmbree(params, objects);
-#endif
- case BVH_LAYOUT_EMBREE_GPU:
-#ifdef WITH_EMBREE
- return new BVHEmbreeGPU(params, objects);
#endif
case BVH_LAYOUT_NONE:
case BVH_LAYOUT_ALL:
diff --git a/intern/cycles/bvh/bvh_embree_gpu.cpp b/intern/cycles/bvh/bvh_embree_gpu.cpp
deleted file mode 100644
index f7b6fa8bb3c..00000000000
--- a/intern/cycles/bvh/bvh_embree_gpu.cpp
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Copyright 2018, 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_gpu.h"
-
-#include "render/mesh.h"
-#include "render/object.h"
-#include "util/util_foreach.h"
-#include "util/util_logging.h"
-#include "util/util_progress.h"
-
-CCL_NAMESPACE_BEGIN
-
-typedef struct {
- BVHEmbreeGPU *bvhBldr;
- Progress *p;
-} UserParams;
-
-
-BVHEmbreeGPU::BVHEmbreeGPU(const BVHParams& params_, const vector<Object*>& objects_)
- : BVH2(params_, objects_), stats(nullptr)
-{
- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
- _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
- this->rtc_device = rtcNewDevice("verbose=1");
-
- rtcSetDeviceErrorFunction(this->rtc_device, [](void*, enum RTCError, const char* str) {
- VLOG(1) << str;
- }, nullptr);
-
- pack.root_index = -1;
-}
-
-BVHEmbreeGPU::~BVHEmbreeGPU()
-{
- rtcReleaseDevice(this->rtc_device);
-}
-
-ccl::BoundBox RTCBoundBoxToCCL(const RTCBounds *bound) {
- return ccl::BoundBox(
- make_float3(bound->lower_x, bound->lower_y, bound->lower_z),
- make_float3(bound->upper_x, bound->upper_y, bound->upper_z));
-
-}
-ccl::BoundBox RTCBuildPrimToCCL(const RTCBuildPrimitive &bound) {
- return ccl::BoundBox(
- make_float3(bound.lower_x, bound.lower_y, bound.lower_z),
- make_float3(bound.upper_x, bound.upper_y, bound.upper_z));
-
-}
-
-void CCLBoundBoxToRTC(const ccl::BoundBox &bb, RTCBounds *bound) {
- bound->lower_x = bb.min.x;
- bound->lower_y = bb.min.y;
- bound->lower_z = bb.min.z;
-
- bound->upper_x = bb.max.x;
- bound->upper_y = bb.max.y;
- bound->upper_z = bb.max.z;
-}
-
-RTCBuildPrimitive makeBuildPrimitive(const BoundBox &bb, unsigned int geomId, unsigned int primId = -1) {
- RTCBuildPrimitive prim;
- prim.lower_x = bb.min.x;
- prim.lower_y = bb.min.y;
- prim.lower_z = bb.min.z;
- prim.upper_x = bb.max.x;
- prim.upper_y = bb.max.y;
- prim.upper_z = bb.max.z;
- prim.geomID = geomId;
- prim.primID = primId;
-
- return prim;
-}
-
-void BVHEmbreeGPU::build(Progress& progress, Stats *stats_)
-{
- this->stats = stats_;
- rtcSetDeviceMemoryMonitorFunction(this->rtc_device, [](void* userPtr, const ssize_t bytes, const bool) -> bool {
- Stats *stats = static_cast<Stats*>(userPtr);
- if(stats == NULL) return true;
-
- if(bytes > 0) {
- stats->mem_alloc(static_cast<size_t>(bytes));
- }
- else {
- stats->mem_free(static_cast<size_t>(-bytes));
- }
- return true;
- }, stats);
-
- progress.set_substatus("Building BVH");
-
-
- struct RTCBuildArguments args = rtcDefaultBuildArguments();
- args.byteSize = sizeof(args);
-
- const bool dynamic = params.bvh_type == SceneParams::BVH_DYNAMIC;
-
- args.buildFlags = (dynamic ? RTC_BUILD_FLAG_DYNAMIC : RTC_BUILD_FLAG_NONE);
- args.buildQuality = dynamic ? RTC_BUILD_QUALITY_LOW :
- ((params.use_spatial_split && !params.top_level) ? RTC_BUILD_QUALITY_HIGH : RTC_BUILD_QUALITY_MEDIUM);
-
- /* Count triangles first so we can reserve arrays once. */
- size_t prim_count = 0;
-
- foreach(Object *ob, objects) {
- if(params.top_level && ob->mesh->is_instanced()) {
- prim_count += 1;
- } else {
- prim_count += ob->mesh->num_triangles();
- }
- }
-
- pack.prim_object.reserve(prim_count);
- pack.prim_type.reserve(prim_count);
- pack.prim_index.reserve(prim_count);
- pack.prim_tri_index.reserve(prim_count);
-
- this->offset.resize(objects.size());
- unsigned int i = 0;
-
- pack.object_node.clear();
-
- vector<RTCBuildPrimitive> prims;
- prims.reserve(objects.size() * 3);
- foreach(Object *ob, objects) {
- if (params.top_level && !ob->is_traceable())
- continue;
-
- if (params.top_level && ob->mesh->is_instanced()) {
- args.maxLeafSize = 1;
- const auto offset = pack.prim_index.size();
- this->offset[i] = offset;
-
- pack.prim_type.push_back_reserved(0);
- pack.prim_index.push_back_reserved(-1);
- pack.prim_object.push_back_reserved(i);
-
- prims.push_back(makeBuildPrimitive(ob->bounds, i));
- } else {
- add_object(ob, i);
-
- const float3 *mesh_verts = ob->mesh->verts.data();
- const float3 *mesh_vert_steps = NULL;
- size_t motion_steps = 1;
-
- if (ob->mesh->has_motion_blur()) {
- const Attribute *attr_motion_vertex = ob->mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION);
- if (attr_motion_vertex) {
- mesh_vert_steps = attr_motion_vertex->data_float3();
- motion_steps = ob->mesh->motion_steps;
- }
- }
-
- for(size_t tri = 0; tri < ob->mesh->num_triangles(); ++tri) {
- BoundBox bb = BoundBox::empty;
- Mesh::Triangle t = ob->mesh->get_triangle(tri);
-
- for (uint step = 0; step < motion_steps; ++step) {
- float3 verts[3];
- t.verts_for_step(mesh_verts, mesh_vert_steps, ob->mesh->num_triangles(), motion_steps, step, verts);
-
- bb.grow(verts[0]);
- bb.grow(verts[1]);
- bb.grow(verts[2]);
- }
-
- prims.push_back(makeBuildPrimitive(bb, i, tri));
- }
- }
-
- ++i;
- if(progress.get_cancel()) return;
- }
-
- if(progress.get_cancel()) {
- stats = nullptr;
- return;
- }
-
- args.bvh = rtcNewBVH(this->rtc_device);
- args.maxBranchingFactor = 2;
-
- args.primitives = prims.data();
- args.primitiveCount = prims.size();
- args.primitiveArrayCapacity = prims.capacity();
-
- args.sahBlockSize = 1;
- args.maxDepth = BVHParams::MAX_DEPTH;
- args.traversalCost = this->params.sah_node_cost;
- // 2 is a corrective factor for Embree (may depend on the scene for optimal results)
- args.intersectionCost = this->params.sah_primitive_cost * 2;
-
- args.createNode = [](RTCThreadLocalAllocator alloc, unsigned int numChildren, void*) -> void* {
- CHECK_EQ(numChildren, 2) << "Should only have two children";
- void* ptr = rtcThreadLocalAlloc(alloc,sizeof(InnerNode),16);
- return new (ptr) InnerNode(BoundBox::empty);
- };
- args.setNodeBounds = [](void* nodePtr, const RTCBounds** bounds, unsigned int numChildren, void*) {
- InnerNode *node = static_cast<InnerNode*>(nodePtr);
- node->num_children_ = static_cast<int>(numChildren);
- for (size_t i=0; i < numChildren; i++) {
- node->bounds.grow(RTCBoundBoxToCCL(bounds[i]));
- }
- };
- args.setNodeChildren = [](void* nodePtr, void** c
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list