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>2018-07-18 17:09:19 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-07-18 17:09:19 +0300
commit2604f281b7bd74f396b2479fbdb97cbf9dc27689 (patch)
treec5f25ed3e806afff58dc95441ab12a9a5d1030f6
parent5fd677c83c80aa33cac9f4fe47dc149e61b96f67 (diff)
Cycles: Fix missing nested particle systems when instanced multiple times
Was only visible when doing command line, since it was happening due to cache-free policy which was aimed to bring memory usage down. The issue is that if object with particle system is used as a nested duplicator multiple times, it will only generate children first time, and after that its caches are freed. After that duplication system can not generate any instances, since the path cache is lost. Now we delay caches free to after all objects are synchronized, which ensures all instances are generated. This will increase a memory peak a bit during object synchronization time, but overall it shouldn't be that bad, since memory footprint after synchronization will stay the same as before this change. The ultimate thing to do here would be to drop the whole dependency graph away, but this will require: - API on engine side, to inform it to drop the dependency graph. - Changes in Cycles report system to NOT use evaluated scene to get scene name (evaluated scene will be gone with dependency graph).
-rw-r--r--intern/cycles/blender/blender_mesh.cpp12
-rw-r--r--intern/cycles/blender/blender_sync.cpp26
-rw-r--r--intern/cycles/blender/blender_sync.h3
3 files changed, 29 insertions, 12 deletions
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index b7d6c1bb36d..08206dd5521 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1077,14 +1077,6 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
bool object_updated,
bool hide_tris)
{
- /* When viewport display is not needed during render we can force some
- * caches to be releases from blender side in order to reduce peak memory
- * footprint during synchronization process.
- */
- const bool is_interface_locked = b_engine.render() &&
- b_engine.render().use_lock_interface();
- const bool can_free_caches = BlenderSession::headless || is_interface_locked;
-
/* test if we can instance or if the object is modified */
BL::ID b_ob_data = b_ob.data();
BL::ID key = (BKE_object_is_modified(b_ob))? b_ob_instance: b_ob_data;
@@ -1209,10 +1201,6 @@ Mesh *BlenderSync::sync_mesh(BL::Depsgraph& b_depsgraph,
if(view_layer.use_hair && mesh->subdivision_type == Mesh::SUBDIVISION_NONE)
sync_curves(mesh, b_mesh, b_ob, false);
- if(can_free_caches) {
- b_ob.cache_release();
- }
-
/* free derived mesh */
b_data.meshes.remove(b_mesh, false, true, false);
}
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index cbca623ece7..3204e0cd3f2 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -207,6 +207,8 @@ void BlenderSync::sync_data(BL::RenderSettings& b_render,
python_thread_state);
mesh_synced.clear();
+
+ free_data_after_sync(b_depsgraph);
}
/* Integrator */
@@ -566,6 +568,30 @@ array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay,
return passes;
}
+void BlenderSync::free_data_after_sync(BL::Depsgraph& b_depsgraph)
+{
+ /* When viewport display is not needed during render we can force some
+ * caches to be releases from blender side in order to reduce peak memory
+ * footprint during synchronization process.
+ */
+ const bool is_interface_locked = b_engine.render() &&
+ b_engine.render().use_lock_interface();
+ const bool can_free_caches = BlenderSession::headless || is_interface_locked;
+ if (!can_free_caches) {
+ return;
+ }
+ /* TODO(sergey): We can actually remove the whole dependency graph,
+ * but that will need some API support first.
+ */
+ BL::Depsgraph::objects_iterator b_ob;
+ for(b_depsgraph.objects.begin(b_ob);
+ b_ob != b_depsgraph.objects.end();
+ ++b_ob)
+ {
+ b_ob->cache_release();
+ }
+}
+
/* Scene Parameters */
SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index cd1a37d3f13..0465f703c51 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -157,6 +157,9 @@ private:
/* Images. */
void sync_images();
+ /* Early data free. */
+ void free_data_after_sync(BL::Depsgraph& b_depsgraph);
+
/* util */
void find_shader(BL::ID& id, vector<Shader*>& used_shaders, Shader *default_shader);
bool BKE_object_is_modified(BL::Object& b_ob);