diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-28 19:07:48 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-28 19:15:25 +0300 |
commit | 68478aea016e87e071d550797b36acd32d33bd12 (patch) | |
tree | 4bb75e4d3fac377d66d160764c727a27ea3e41da /intern/cycles/bvh/bvh_build.h | |
parent | b506f3d3280c08b2b8817ab9aaf7f8ff803eb2ec (diff) |
Cycles: Avoid having duplication of BVH arrays during build
Previous idea behind having vector during building and array for actual storage
was needed in order to minimize amount of re-allocations happening during the
build, but it lead to double memory overhead used by those arrays at the vector
to array conversion stage.
Issue with such approach was that for BVH without spatial split size of arrays
is known in advance and it never changes, which made vector to array conversion
totally redundant.
Also after testing with several rather complex from spatial split scenes (such
as trees) it seems even conservative approach of reallocation (when we perform
re-allocation when leaf does not fit into the memory) doesn't give measurable
difference in time.
This makes it so we can switch to array, which will avoid unneeded memory
re-allocations when spatial split is disabled without harming other cases.
it's a bit difficult to measure exact benefit of this change on our production
files here, but depending on the scene it might give quite reasonable memory
save.
Diffstat (limited to 'intern/cycles/bvh/bvh_build.h')
-rw-r--r-- | intern/cycles/bvh/bvh_build.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/intern/cycles/bvh/bvh_build.h b/intern/cycles/bvh/bvh_build.h index 294c5a1758d..eefb7b60f7c 100644 --- a/intern/cycles/bvh/bvh_build.h +++ b/intern/cycles/bvh/bvh_build.h @@ -42,13 +42,12 @@ class BVHBuild { public: /* Constructor/Destructor */ - BVHBuild( - const vector<Object*>& objects, - vector<int>& prim_type, - vector<int>& prim_index, - vector<int>& prim_object, - const BVHParams& params, - Progress& progress); + BVHBuild(const vector<Object*>& objects, + array<int>& prim_type, + array<int>& prim_index, + array<int>& prim_object, + const BVHParams& params, + Progress& progress); ~BVHBuild(); BVHNode *run(); @@ -99,9 +98,9 @@ protected: int num_original_references; /* output primitive indexes and objects */ - vector<int>& prim_type; - vector<int>& prim_index; - vector<int>& prim_object; + array<int>& prim_type; + array<int>& prim_index; + array<int>& prim_object; /* build parameters */ BVHParams params; |