diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-11-09 18:14:15 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-11-09 19:53:02 +0300 |
commit | 549468365157a075949f2d4b8d9496ff719cefbf (patch) | |
tree | f564368fe509f46e4ec13b350b62aaace571c093 /source/blender/render/intern | |
parent | cbbf991f62b7f1546771a71b3b9f14a46d1b6b61 (diff) |
Cycles: Free Blender side data as soon as we don't need it
Currently this is possible after built-in images are loaded in memory.
Allows to save memory used by dependency graph and copy-on-write.
In practice this lowers peak system memory usage from 52GB to 42GB on
a production file of spring 03_035_A.lighting.
Note, that this only applies to F12 and command line renders.
Bigger note, that this optimization is currently only possible if
there are no grease pencil objects to be rendered.
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r-- | source/blender/render/intern/source/external_engine.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index a06389bfcd4..758600e89aa 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -738,8 +738,13 @@ int RE_engine_render(Render *re, int do_all) type->render(engine, engine->depsgraph); - /* grease pencil render over previous render result */ - if (!RE_engine_test_break(engine)) { + /* Grease pencil render over previous render result. + * + * NOTE: External engine might have been requested to free its + * dependency graph, which is only allowed if there is no grease + * pencil (pipeline is taking care of that). + */ + if (!RE_engine_test_break(engine) && engine->depsgraph != NULL) { DRW_render_gpencil(engine, engine->depsgraph); } @@ -813,3 +818,18 @@ void RE_engine_register_pass(struct RenderEngine *engine, struct Scene *scene, s } } } + +void RE_engine_free_blender_memory(RenderEngine *engine) +{ + /* Weak way to save memory, but not crash grease pencil. + * + * TODO(sergey): Find better solution for this. + * TODO(sergey): Try to find solution which does not involve looping over + * all the objects. + */ + if (DRW_render_check_grease_pencil(engine->depsgraph)) { + return; + } + DEG_graph_free(engine->depsgraph); + engine->depsgraph = NULL; +} |