Commit: 01e1dde74e31cfafe628ebb236a803f4b76c5d48 Author: Kévin Dietrich Date: Tue Nov 10 18:48:57 2020 +0100 Branches: cycles_procedural_api https://developer.blender.org/rB01e1dde74e31cfafe628ebb236a803f4b76c5d48
attempt to make persistent data for final renders =================================================================== M intern/cycles/blender/addon/ui.py M intern/cycles/blender/blender_session.cpp M intern/cycles/blender/blender_sync.cpp M intern/cycles/blender/blender_sync.h M intern/cycles/render/scene.cpp M intern/cycles/render/shader.cpp =================================================================== diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index c0c5f146dfb..3362cfd3054 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -741,7 +741,7 @@ class CYCLES_RENDER_PT_performance_final_render(CyclesButtonsPanel, Panel): col = layout.column() col.prop(rd, "use_save_buffers") - col.prop(rd, "use_persistent_data", text="Persistent Images") + col.prop(rd, "use_persistent_data", text="Persistent Data") class CYCLES_RENDER_PT_performance_viewport(CyclesButtonsPanel, Panel): diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index d4c0041e080..e739d9df114 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -225,7 +225,6 @@ void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsg } session->progress.reset(); - scene->reset(); session->tile_manager.set_tile_order(session_params.tile_order); @@ -237,9 +236,18 @@ void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsg /* There is no single depsgraph to use for the entire render. * See note on create_session(). */ - /* sync object should be re-created */ - delete sync; - sync = new BlenderSync(b_engine, b_data, b_scene, scene, !background, session->progress); + if (!scene->params.persistent_data) { + delete sync; + sync = nullptr; + scene->reset(); + } + + if (!sync) { + sync = new BlenderSync(b_engine, b_data, b_scene, scene, !background, session->progress); + } + else { + sync->sync_recalc(b_depsgraph, nullptr); + } BL::SpaceView3D b_null_space_view3d(PointerRNA_NULL); BL::RegionView3D b_null_region_view3d(PointerRNA_NULL); @@ -602,6 +610,13 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_) session->update_render_tile_cb = function_null; /* TODO: find a way to clear this data for persistent data render */ + // todo(kevin): from patch +// session->device_free(); + +// if (!scene->params.persistent_data) { +// delete sync; +// sync = NULL; +// } #if 0 /* free all memory used (host and device), so we wouldn't leave render * engine with extra memory allocated @@ -800,7 +815,7 @@ void BlenderSession::synchronize(BL::Depsgraph &b_depsgraph_) /* copy recalc flags, outside of mutex so we can decide to do the real * synchronization at a later time to not block on running updates */ - sync->sync_recalc(b_depsgraph_, b_v3d); + sync->sync_recalc(b_depsgraph_, &b_v3d); /* don't do synchronization if on pause */ if (session_pause) { diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index eb58c49a4a1..7f7ec17cb38 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -92,7 +92,7 @@ void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene) /* Sync */ -void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d) +void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D *b_v3d) { /* Sync recalc flags from blender to cycles. Actual update is done separate, * so we can do it later on if doing it immediate is not suitable. */ @@ -213,9 +213,11 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d } } - BlenderViewportParameters new_viewport_parameters(b_v3d); - if (viewport_parameters.modified(new_viewport_parameters)) { - world_recalc = true; + if (b_v3d) { + BlenderViewportParameters new_viewport_parameters(*b_v3d); + if (viewport_parameters.modified(new_viewport_parameters)) { + world_recalc = true; + } } } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 7fc2d05ad9b..900870f2db4 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -65,7 +65,7 @@ class BlenderSync { void reset(BL::BlendData &b_data, BL::Scene &b_scene); /* sync */ - void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d); + void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D *b_v3d); void sync_data(BL::RenderSettings &b_render, BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index fb80edfe666..1427fedc872 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -196,47 +196,51 @@ Scene::~Scene() void Scene::free_memory(bool final) { - foreach (Shader *s, shaders) - delete s; - foreach (Geometry *g, geometry) - delete g; - foreach (Object *o, objects) - delete o; - foreach (Light *l, lights) - delete l; - foreach (ParticleSystem *p, particle_systems) - delete p; - foreach (Procedural *p, procedurals) - delete p; - - shaders.clear(); - geometry.clear(); - objects.clear(); - lights.clear(); - particle_systems.clear(); - procedurals.clear(); + if (!params.persistent_data || final) { + foreach (Shader *s, shaders) + delete s; + foreach (Geometry *g, geometry) + delete g; + foreach (Object *o, objects) + delete o; + foreach (Light *l, lights) + delete l; + foreach (ParticleSystem *p, particle_systems) + delete p; + foreach (Procedural *p, procedurals) + delete p; + + shaders.clear(); + geometry.clear(); + objects.clear(); + lights.clear(); + particle_systems.clear(); + procedurals.clear(); + } if (device) { - camera->device_free(device, &dscene, this); - film->device_free(device, &dscene, this); - background->device_free(device, &dscene); - integrator->device_free(device, &dscene); + if (!params.persistent_data || final) { + camera->device_free(device, &dscene, this); + film->device_free(device, &dscene, this); + background->device_free(device, &dscene); + integrator->device_free(device, &dscene); - object_manager->device_free(device, &dscene); - geometry_manager->device_free(device, &dscene); - shader_manager->device_free(device, &dscene, this); - light_manager->device_free(device, &dscene); + object_manager->device_free(device, &dscene); + geometry_manager->device_free(device, &dscene); + shader_manager->device_free(device, &dscene, this); + light_manager->device_free(device, &dscene); - particle_system_manager->device_free(device, &dscene); + particle_system_manager->device_free(device, &dscene); - bake_manager->device_free(device, &dscene); + bake_manager->device_free(device, &dscene); - if (!params.persistent_data || final) image_manager->device_free(device); - else - image_manager->device_free_builtin(device); - lookup_tables->device_free(device, &dscene); + lookup_tables->device_free(device, &dscene); + } + else { + image_manager->device_free_builtin(device); + } } if (final) { diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 44ee714a515..55b50ea8da1 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -632,7 +632,7 @@ void ShaderManager::device_free_common(Device *, DeviceScene *dscene, Scene *sce void ShaderManager::add_default(Scene *scene) { /* default surface */ - { + if (scene->default_surface == nullptr) { ShaderGraph *graph = new ShaderGraph(); DiffuseBsdfNode *diffuse = graph->create_node<DiffuseBsdfNode>(); @@ -649,7 +649,7 @@ void ShaderManager::add_default(Scene *scene) } /* default volume */ - { + if (scene->default_volume == nullptr) { ShaderGraph *graph = new ShaderGraph(); PrincipledVolumeNode *principled = graph->create_node<PrincipledVolumeNode>(); @@ -665,7 +665,7 @@ void ShaderManager::add_default(Scene *scene) } /* default light */ - { + if (scene->default_light == nullptr) { ShaderGraph *graph = new ShaderGraph(); EmissionNode *emission = graph->create_node<EmissionNode>(); @@ -683,7 +683,7 @@ void ShaderManager::add_default(Scene *scene) } /* default background */ - { + if (scene->default_background == nullptr) { ShaderGraph *graph = new ShaderGraph(); Shader *shader = scene->create_node<Shader>(); @@ -694,7 +694,7 @@ void ShaderManager::add_default(Scene *scene) } /* default empty */ - { + if (scene->default_empty == nullptr) { ShaderGraph *graph = new ShaderGraph(); Shader *shader = scene->create_node<Shader>(); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs