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:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-02-21 17:39:02 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-03-31 11:06:21 +0300
commitbbbbe68473e02567a902a6405ca09de216674615 (patch)
tree0e6dd43ed39c091bfac7001e636612e2136ea202 /intern/cycles/bvh/bvh_build.cpp
parent9c420e5e481f00f42eeea42979c140afc8ee4acc (diff)
Cycles: Wrap spatial split storage into own structure
This has following advantages: - Localizes all the run-time storage into a single structure, which could easily be extended further. - Storage could be created per-thread, so once builder is threaded we wouldn't have any conflicts between threads. - Global nature of the storage avoids memory re-allocation on the runtime, keeping builder as fast as possible. Currently it's just API changes, which don't affect user at all.
Diffstat (limited to 'intern/cycles/bvh/bvh_build.cpp')
-rw-r--r--intern/cycles/bvh/bvh_build.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index ef58bb2357b..b83c1e8864b 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -230,8 +230,23 @@ BVHNode* BVHBuild::run()
}
spatial_min_overlap = root.bounds().safe_area() * params.spatial_split_alpha;
- spatial_right_bounds.clear();
- spatial_right_bounds.resize(max(root.size(), (int)BVHParams::NUM_SPATIAL_BINS) - 1);
+
+ if(params.use_spatial_split) {
+ /* NOTE: The API here tries to be as much ready for multi-threaded build
+ * as possible, but at the same time it tries not to introduce any
+ * changes in behavior for until all refactoring needed for threading is
+ * finished.
+ *
+ * So we currently allocate single storage for now, which is only used by
+ * the only thread working on the spatial BVH build.
+ */
+ spatial_storage.resize(1);
+ size_t num_bins = max(root.size(), (int)BVHParams::NUM_SPATIAL_BINS) - 1;
+ foreach(BVHSpatialStorage &storage, spatial_storage) {
+ storage.spatial_right_bounds.clear();
+ storage.spatial_right_bounds.resize(num_bins);
+ }
+ }
/* init progress updates */
double build_start_time;
@@ -407,7 +422,7 @@ BVHNode* BVHBuild::build_node(const BVHRange& range, int level)
}
/* splitting test */
- BVHMixedSplit split(this, range, level);
+ BVHMixedSplit split(this, &spatial_storage[0], range, level);
if(!(range.size() > 0 && params.top_level && level == 0)) {
if(split.no_split) {