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:
authorAntonio Vazquez <blendergit@gmail.com>2021-05-26 13:43:03 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-05-26 13:43:03 +0300
commit8a6604f253e22bbade3dcf60b9a1c437ace44151 (patch)
treefee875d0a0b09fbe0df52aa83094159144048205 /intern/cycles/blender/blender_sync.cpp
parentedf1b833674a6e54df7a16c14f0c6193fbbb482e (diff)
parentafec66c024dc2b75447537d45406c06342ec201e (diff)
Merge branch 'master' into temp-gpencil-maskingtemp-gpencil-masking
Conflicts: source/blender/blenloader/intern/versioning_300.c
Diffstat (limited to 'intern/cycles/blender/blender_sync.cpp')
-rw-r--r--intern/cycles/blender/blender_sync.cpp58
1 files changed, 46 insertions, 12 deletions
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index aa87ac1dd81..bacf57df48e 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -69,7 +69,8 @@ BlenderSync::BlenderSync(BL::RenderEngine &b_engine,
experimental(false),
dicing_rate(1.0f),
max_subdivisions(12),
- progress(progress)
+ progress(progress),
+ has_updates_(true)
{
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") :
@@ -84,7 +85,9 @@ BlenderSync::~BlenderSync()
void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene)
{
/* Update data and scene pointers in case they change in session reset,
- * for example after undo. */
+ * for example after undo.
+ * Note that we do not modify the `has_updates_` flag here because the sync
+ * reset is also used during viewport navigation. */
this->b_data = b_data;
this->b_scene = b_scene;
}
@@ -117,6 +120,8 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
}
if (dicing_prop_changed) {
+ has_updates_ = true;
+
for (const pair<const GeometryKey, Geometry *> &iter : geometry_map.key_to_scene_data()) {
Geometry *geom = iter.second;
if (geom->is_mesh()) {
@@ -133,6 +138,12 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
/* Iterate over all IDs in this depsgraph. */
for (BL::DepsgraphUpdate &b_update : b_depsgraph.updates) {
+ /* TODO(sergey): Can do more selective filter here. For example, ignore changes made to
+ * screen datablock. Note that sync_data() needs to be called after object deletion, and
+ * currently this is ensured by the scene ID tagged for update, which sets the `has_updates_`
+ * flag. */
+ has_updates_ = true;
+
BL::ID b_id(b_update.id());
/* Material */
@@ -213,8 +224,18 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d
if (b_v3d) {
BlenderViewportParameters new_viewport_parameters(b_v3d);
+
if (viewport_parameters.modified(new_viewport_parameters)) {
world_recalc = true;
+ has_updates_ = true;
+ }
+
+ if (!has_updates_) {
+ Film *film = scene->film;
+
+ const PassType new_display_pass = new_viewport_parameters.get_viewport_display_render_pass(
+ b_v3d);
+ has_updates_ |= film->get_display_pass() != new_display_pass;
}
}
}
@@ -227,11 +248,15 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
int height,
void **python_thread_state)
{
+ if (!has_updates_) {
+ return;
+ }
+
scoped_timer timer;
BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
- sync_view_layer(b_v3d, b_view_layer);
+ sync_view_layer(b_view_layer);
sync_integrator();
sync_film(b_v3d);
sync_shaders(b_depsgraph, b_v3d);
@@ -254,6 +279,8 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
free_data_after_sync(b_depsgraph);
VLOG(1) << "Total time spent synchronizing data: " << timer.get_time();
+
+ has_updates_ = false;
}
/* Integrator */
@@ -424,7 +451,7 @@ void BlenderSync::sync_film(BL::SpaceView3D &b_v3d)
/* Render Layer */
-void BlenderSync::sync_view_layer(BL::SpaceView3D & /*b_v3d*/, BL::ViewLayer &b_view_layer)
+void BlenderSync::sync_view_layer(BL::ViewLayer &b_view_layer)
{
view_layer.name = b_view_layer.name();
@@ -739,12 +766,18 @@ void BlenderSync::free_data_after_sync(BL::Depsgraph &b_depsgraph)
* 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) &&
- /* Baking re-uses the depsgraph multiple times, clearing crashes
- * reading un-evaluated mesh data which isn't aligned with the
- * geometry we're baking, see T71012. */
- !scene->bake_manager->get_baking();
+ const bool is_persistent_data = b_engine.render() && b_engine.render().use_persistent_data();
+ const bool can_free_caches =
+ (BlenderSession::headless || is_interface_locked) &&
+ /* Baking re-uses the depsgraph multiple times, clearing crashes
+ * reading un-evaluated mesh data which isn't aligned with the
+ * geometry we're baking, see T71012. */
+ !scene->bake_manager->get_baking() &&
+ /* Persistent data must main caches for performance and correctness. */
+ !is_persistent_data;
+
if (!can_free_caches) {
return;
}
@@ -869,6 +902,9 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
/* Clamp samples. */
params.samples = min(params.samples, Integrator::MAX_SAMPLES);
+ /* Adaptive sampling. */
+ params.adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling");
+
/* tiles */
const bool is_cpu = (params.device.type == DEVICE_CPU);
if (!is_cpu && !background) {
@@ -921,7 +957,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
BL::RenderSettings b_r = b_scene.render();
params.progressive_refine = b_engine.is_preview() ||
get_boolean(cscene, "use_progressive_refine");
- if (b_r.use_save_buffers())
+ if (b_r.use_save_buffers() || params.adaptive_sampling)
params.progressive_refine = false;
if (background) {
@@ -957,8 +993,6 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
params.use_profiling = params.device.has_profiling && !b_engine.is_preview() && background &&
BlenderSession::print_render_stats;
- params.adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling");
-
return params;
}