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:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2021-01-22 17:01:26 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2021-01-22 18:08:25 +0300
commitbbe6d44928235cd4a5cfbeaf1a1de78ed861bb92 (patch)
treec3a8653dfdf38029caebfd9978ea4644535bae3d /intern/cycles/blender
parent131a758b6f88a2be816e9351d216bcfb9c965c4b (diff)
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in the viewport) by avoiding unnecessary computations. To achieve this, we use a combination of the sockets' update flags as well as some new flags passed to the various managers when tagging for an update to tell exactly what the tagging is for (e.g. shader was modified, object was removed, etc.). Besides avoiding recomputations, we also avoid resending to the devices unmodified data arrays, thus reducing bandwidth usage. For OptiX and Embree, BVH packing was also multithreaded. The performance improvements may vary depending on the used device (CPU or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive subdivision or volumes) rendered using OptiX will benefit from this work the most. On average, for a variety of animated scenes, this gives a 3x speedup. Reviewed By: #cycles, brecht Maniphest Tasks: T79174 Differential Revision: https://developer.blender.org/D9555
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r--intern/cycles/blender/blender_curves.cpp5
-rw-r--r--intern/cycles/blender/blender_geometry.cpp2
-rw-r--r--intern/cycles/blender/blender_mesh.cpp11
-rw-r--r--intern/cycles/blender/blender_object.cpp3
-rw-r--r--intern/cycles/blender/blender_particles.cpp4
-rw-r--r--intern/cycles/blender/blender_session.cpp5
-rw-r--r--intern/cycles/blender/blender_shader.cpp4
-rw-r--r--intern/cycles/blender/blender_sync.cpp11
8 files changed, 10 insertions, 35 deletions
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 964241e9904..1764b5b635d 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -855,10 +855,7 @@ void BlenderSync::sync_hair(BL::Depsgraph b_depsgraph, BL::Object b_ob, Hair *ha
hair->set_value(socket, new_hair, socket);
}
- hair->attributes.clear();
- foreach (Attribute &attr, new_hair.attributes.attributes) {
- hair->attributes.attributes.push_back(std::move(attr));
- }
+ hair->attributes.update(std::move(new_hair.attributes));
/* tag update */
diff --git a/intern/cycles/blender/blender_geometry.cpp b/intern/cycles/blender/blender_geometry.cpp
index bd2f0731030..99df8b7b1c9 100644
--- a/intern/cycles/blender/blender_geometry.cpp
+++ b/intern/cycles/blender/blender_geometry.cpp
@@ -124,7 +124,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
foreach (Node *node, geom->get_used_shaders()) {
Shader *shader = static_cast<Shader *>(node);
- if (shader->need_update_geometry) {
+ if (shader->need_update_geometry()) {
attribute_recalc = true;
}
}
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 3420025f472..b334da38372 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -1075,15 +1075,8 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, BL::Object b_ob, Mesh *me
mesh->set_value(socket, new_mesh, socket);
}
- mesh->attributes.clear();
- foreach (Attribute &attr, new_mesh.attributes.attributes) {
- mesh->attributes.attributes.push_back(std::move(attr));
- }
-
- mesh->subd_attributes.clear();
- foreach (Attribute &attr, new_mesh.subd_attributes.attributes) {
- mesh->subd_attributes.attributes.push_back(std::move(attr));
- }
+ mesh->attributes.update(std::move(new_mesh.attributes));
+ mesh->subd_attributes.update(std::move(new_mesh.subd_attributes));
mesh->set_num_subd_faces(new_mesh.get_num_subd_faces());
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index 5261fbcee07..8daaaea6978 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -243,9 +243,6 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* holdout */
object->set_use_holdout(use_holdout);
- if (object->use_holdout_is_modified()) {
- scene->object_manager->tag_update(scene);
- }
object->set_visibility(visibility);
diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp
index ca221b229b4..d5dd7215c47 100644
--- a/intern/cycles/blender/blender_particles.cpp
+++ b/intern/cycles/blender/blender_particles.cpp
@@ -57,7 +57,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
/* no update needed? */
if (!need_update && !object->get_geometry()->is_modified() &&
- !scene->object_manager->need_update)
+ !scene->object_manager->need_update())
return true;
/* first time used in this sync loop? clear and tag update */
@@ -85,7 +85,7 @@ bool BlenderSync::sync_dupli_particle(BL::Object &b_ob,
object->set_particle_index(psys->particles.size() - 1);
if (object->particle_index_is_modified())
- scene->object_manager->tag_update(scene);
+ scene->object_manager->tag_update(scene, ObjectManager::PARTICLE_MODIFIED);
/* return that this object has particle data */
return true;
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 8566d0e7ed5..2ec76be4ee8 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -552,7 +552,6 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
int seed = scene->integrator->get_seed();
seed += hash_uint2(seed, hash_uint2(view_index * 0xdeadbeef, 0));
scene->integrator->set_seed(seed);
- scene->integrator->tag_update(scene);
}
/* Update number of samples per layer. */
@@ -1116,10 +1115,6 @@ void BlenderSession::update_resumable_tile_manager(int num_samples)
scene->integrator->set_start_sample(rounded_range_start_sample);
- if (scene->integrator->is_modified()) {
- scene->integrator->tag_update(scene);
- }
-
session->tile_manager.range_start_sample = rounded_range_start_sample;
session->tile_manager.range_num_samples = rounded_range_num_samples;
}
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index ac86cf3345c..f3f46a1b108 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1497,7 +1497,6 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
shader->set_graph(graph);
shader->tag_update(scene);
- background->tag_update(scene);
}
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
@@ -1517,8 +1516,7 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
viewport_parameters.custom_viewport_parameters());
background->set_use_ao(background->get_use_ao() && view_layer.use_background_ao);
- if (background->is_modified())
- background->tag_update(scene);
+ background->tag_update(scene);
}
/* Sync Lights */
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index e27daa2488d..6b2039e7e21 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -302,11 +302,6 @@ void BlenderSync::sync_integrator()
integrator->set_sample_clamp_direct(get_float(cscene, "sample_clamp_direct"));
integrator->set_sample_clamp_indirect(get_float(cscene, "sample_clamp_indirect"));
if (!preview) {
- if (integrator->get_motion_blur() != r.use_motion_blur()) {
- scene->object_manager->tag_update(scene);
- scene->camera->tag_modified();
- }
-
integrator->set_motion_blur(r.use_motion_blur());
}
@@ -375,8 +370,8 @@ void BlenderSync::sync_integrator()
integrator->set_ao_bounces(0);
}
- if (integrator->is_modified())
- integrator->tag_update(scene);
+ /* UPDATE_NONE as we don't want to tag the integrator as modified, just tag dependent things */
+ integrator->tag_update(scene, Integrator::UPDATE_NONE);
}
/* Film */
@@ -729,7 +724,7 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay,
scene->film->set_pass_alpha_threshold(b_view_layer.pass_alpha_threshold());
scene->film->tag_passes_update(scene, passes);
- scene->integrator->tag_update(scene);
+ scene->integrator->tag_update(scene, Integrator::UPDATE_ALL);
return passes;
}