diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-09-01 16:03:03 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-09-01 16:05:10 +0400 |
commit | 6212b7302cce8f6e2b5f9a0297b9595cf2ad69a8 (patch) | |
tree | f1e8daed921fc33243e7452d5cbd8a00bc2a2d9f /intern/cycles/bvh | |
parent | e8f3fa99de8196a36736381b03015689492137bd (diff) |
Cycles: Rebuild BVH from scratch if loading cache failed
Before this Cycles used to try using the cache even so it knew for the
fact that reading it from the disk failed. This change doesn't make it
more stable if someone will try to trick Cycles and give malformed data
but it solves general cases when Blender crashed during the cache write
and will preserve rendering from crashing when trying to use that partial
cache.
Diffstat (limited to 'intern/cycles/bvh')
-rw-r--r-- | intern/cycles/bvh/bvh.cpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp index 3c0c5c021c8..15bd814b8d5 100644 --- a/intern/cycles/bvh/bvh.cpp +++ b/intern/cycles/bvh/bvh.cpp @@ -103,18 +103,30 @@ bool BVH::cache_read(CacheData& key) if(Cache::global.lookup(key, value)) { cache_filename = key.get_filename(); - value.read(pack.root_index); - value.read(pack.SAH); - - value.read(pack.nodes); - value.read(pack.object_node); - value.read(pack.tri_woop); - value.read(pack.prim_type); - value.read(pack.prim_visibility); - value.read(pack.prim_index); - value.read(pack.prim_object); - value.read(pack.is_leaf); - + if(!(value.read(pack.root_index) && + value.read(pack.SAH) && + value.read(pack.nodes) && + value.read(pack.object_node) && + value.read(pack.tri_woop) && + value.read(pack.prim_type) && + value.read(pack.prim_visibility) && + value.read(pack.prim_index) && + value.read(pack.prim_object) && + value.read(pack.is_leaf))) + { + /* Clear the pack if load failed. */ + pack.root_index = 0; + pack.SAH = 0.0f; + pack.nodes.clear(); + pack.object_node.clear(); + pack.tri_woop.clear(); + pack.prim_type.clear(); + pack.prim_visibility.clear(); + pack.prim_index.clear(); + pack.prim_object.clear(); + pack.is_leaf.clear(); + return false; + } return true; } |