diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-21 17:39:02 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-03-31 11:06:21 +0300 |
commit | bbbbe68473e02567a902a6405ca09de216674615 (patch) | |
tree | 0e6dd43ed39c091bfac7001e636612e2136ea202 /intern/cycles/bvh/bvh_split.h | |
parent | 9c420e5e481f00f42eeea42979c140afc8ee4acc (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_split.h')
-rw-r--r-- | intern/cycles/bvh/bvh_split.h | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/intern/cycles/bvh/bvh_split.h b/intern/cycles/bvh/bvh_split.h index 1e46bb66203..cc61899c9b5 100644 --- a/intern/cycles/bvh/bvh_split.h +++ b/intern/cycles/bvh/bvh_split.h @@ -37,9 +37,18 @@ public: BoundBox right_bounds; BVHObjectSplit() {} - BVHObjectSplit(BVHBuild *builder, const BVHRange& range, float nodeSAH); + BVHObjectSplit(BVHBuild *builder, + BVHSpatialStorage *storage, + const BVHRange& range, + float nodeSAH); - void split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range); + void split(BVHBuild *builder, + BVHRange& left, + BVHRange& right, + const BVHRange& range); + +protected: + BVHSpatialStorage *storage_; }; /* Spatial Split */ @@ -52,7 +61,10 @@ public: float pos; BVHSpatialSplit() : sah(FLT_MAX), dim(0), pos(0.0f) {} - BVHSpatialSplit(BVHBuild *builder, const BVHRange& range, float nodeSAH); + BVHSpatialSplit(BVHBuild *builder, + BVHSpatialStorage *storage, + const BVHRange& range, + float nodeSAH); void split(BVHBuild *builder, BVHRange& left, BVHRange& right, const BVHRange& range); void split_reference(BVHBuild *builder, @@ -63,6 +75,8 @@ public: float pos); protected: + BVHSpatialStorage *storage_; + /* Lower-level functions which calculates boundaries of left and right nodes * needed for spatial split. * @@ -123,7 +137,10 @@ public: bool no_split; - __forceinline BVHMixedSplit(BVHBuild *builder, const BVHRange& range, int level) + __forceinline BVHMixedSplit(BVHBuild *builder, + BVHSpatialStorage *storage, + const BVHRange& range, + int level) { /* find split candidates. */ float area = range.bounds().safe_area(); @@ -131,14 +148,14 @@ public: leafSAH = area * builder->params.primitive_cost(range.size()); nodeSAH = area * builder->params.node_cost(2); - object = BVHObjectSplit(builder, range, nodeSAH); + object = BVHObjectSplit(builder, storage, range, nodeSAH); if(builder->params.use_spatial_split && level < BVHParams::MAX_SPATIAL_DEPTH) { BoundBox overlap = object.left_bounds; overlap.intersect(object.right_bounds); if(overlap.safe_area() >= builder->spatial_min_overlap) - spatial = BVHSpatialSplit(builder, range, nodeSAH); + spatial = BVHSpatialSplit(builder, storage, range, nodeSAH); } /* leaf SAH is the lowest => create leaf. */ |