diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-22 18:25:33 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-31 11:06:21 +0300 |
commit | d9b729e342b72bfe31e7932723a149db3b7aa77c (patch) | |
tree | cc1de21b2999dea8ad4be41752e030758f280b09 /intern/cycles/bvh/bvh_split.cpp | |
parent | bbbbe68473e02567a902a6405ca09de216674615 (diff) |
Cycles: Only sort indices when finding a best dimension to split
This reduces amount of data being moved back and forth, which should
have positive effect on the performance.
Diffstat (limited to 'intern/cycles/bvh/bvh_split.cpp')
-rw-r--r-- | intern/cycles/bvh/bvh_split.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/intern/cycles/bvh/bvh_split.cpp b/intern/cycles/bvh/bvh_split.cpp index 037702c1d06..ff0142fa786 100644 --- a/intern/cycles/bvh/bvh_split.cpp +++ b/intern/cycles/bvh/bvh_split.cpp @@ -42,15 +42,25 @@ BVHObjectSplit::BVHObjectSplit(BVHBuild *builder, const BVHReference *ref_ptr = &builder->references[range.start()]; float min_sah = FLT_MAX; + storage->spatial_indices.resize(range.size()); + int *indices = &storage->spatial_indices[0]; + for(int dim = 0; dim < 3; dim++) { - /* sort references */ - bvh_reference_sort(range.start(), range.end(), &builder->references[0], dim); + /* Sort references. + * We only sort indices, to save amount of memory being sent back + * and forth. + */ + bvh_reference_sort_indices(range.start(), + range.end(), + &builder->references[0], + indices, + dim); /* sweep right to left and determine bounds. */ BoundBox right_bounds = BoundBox::empty; for(int i = range.size() - 1; i > 0; i--) { - right_bounds.grow(ref_ptr[i].bounds()); + right_bounds.grow(ref_ptr[indices[i]].bounds()); storage_->spatial_right_bounds[i - 1] = right_bounds; } @@ -58,7 +68,7 @@ BVHObjectSplit::BVHObjectSplit(BVHBuild *builder, BoundBox left_bounds = BoundBox::empty; for(int i = 1; i < range.size(); i++) { - left_bounds.grow(ref_ptr[i - 1].bounds()); + left_bounds.grow(ref_ptr[indices[i - 1]].bounds()); right_bounds = storage_->spatial_right_bounds[i - 1]; float sah = nodeSAH + |