Commit: 628a59e36de0c8a29521da467255bee1a2161f6a Author: Kévin Dietrich Date: Fri Nov 6 10:43:58 2020 +0100 Branches: cycles_procedural_api https://developer.blender.org/rB628a59e36de0c8a29521da467255bee1a2161f6a
add flags to update tagging for light and shader managers =================================================================== M intern/cycles/render/geometry.cpp M intern/cycles/render/integrator.cpp M intern/cycles/render/light.cpp M intern/cycles/render/light.h M intern/cycles/render/object.cpp M intern/cycles/render/osl.cpp M intern/cycles/render/scene.cpp M intern/cycles/render/shader.cpp M intern/cycles/render/shader.h M intern/cycles/render/svm.cpp =================================================================== diff --git a/intern/cycles/render/geometry.cpp b/intern/cycles/render/geometry.cpp index b2be93d2640..c73f9022ae9 100644 --- a/intern/cycles/render/geometry.cpp +++ b/intern/cycles/render/geometry.cpp @@ -262,13 +262,17 @@ void Geometry::tag_update(Scene *scene, bool rebuild) { if (rebuild) { need_update_rebuild = true; - scene->light_manager->need_update = true; + scene->light_manager->tag_update(scene, LightManager::MESH_NEED_REBUILD); } else { - foreach (Node *node, used_shaders) { - Shader *shader = static_cast<Shader *>(node); - if (shader->has_surface_emission) - scene->light_manager->need_update = true; + if (is_modified()) { + foreach (Node *node, used_shaders) { + Shader *shader = static_cast<Shader *>(node); + if (shader->has_surface_emission) { + scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED); + break; + } + } } } diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index 50775b1d08b..341e7274256 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -288,7 +288,7 @@ void Integrator::tag_update(Scene *scene, uint32_t flag) if (filter_glossy_is_modified()) { foreach (Shader *shader, scene->shaders) { if (shader->has_integrator_dependency) { - scene->shader_manager->need_update = true; + scene->shader_manager->tag_update(scene, ShaderManager::INTEGRATOR_MODIFIED); break; } } diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 80190dcbf82..4b34bf958d7 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -162,7 +162,9 @@ Light::Light() : Node(node_type) void Light::tag_update(Scene *scene) { - scene->light_manager->need_update = is_modified(); + if (is_modified()) { + scene->light_manager->tag_update(scene, LightManager::LIGHT_MODIFIED); + } } bool Light::has_contribution(Scene *scene) @@ -1013,7 +1015,7 @@ void LightManager::device_free(Device *, DeviceScene *dscene, const bool free_ba dscene->ies_lights.free(); } -void LightManager::tag_update(Scene * /*scene*/) +void LightManager::tag_update(Scene * /*scene*/, uint32_t /*flag*/) { need_update = true; } diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h index e590e13b489..1f0ca50cad4 100644 --- a/intern/cycles/render/light.h +++ b/intern/cycles/render/light.h @@ -91,8 +91,21 @@ class Light : public Node { class LightManager { public: - bool use_light_visibility; + enum { + LIGHT_MODIFIED = (1 << 0), + LIGHT_ADDED = (1 << 1), + LIGHT_REMOVED = (1 << 2), + MESH_NEED_REBUILD = (1 << 3), + EMISSIVE_MESH_MODIFIED = (1 << 4), + OBJECT_MANAGER = (1 << 5), + SHADER_COMPILED = (1 << 6), + SHADER_MODIFIED = (1 << 7), + + UPDATE_ALL = ~0u, + }; + bool need_update; + bool use_light_visibility; /* Need to update background (including multiple importance map) */ bool need_update_background; @@ -108,7 +121,7 @@ class LightManager { void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress); void device_free(Device *device, DeviceScene *dscene, const bool free_background = true); - void tag_update(Scene *scene); + void tag_update(Scene *scene, uint32_t flag); /* Check whether there is a background light. */ bool has_background_light(Scene *scene); diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 4cf771646d8..b50b3b76d1b 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -226,7 +226,7 @@ void Object::tag_update(Scene *scene) foreach (Node *node, geometry->get_used_shaders()) { Shader *shader = static_cast<Shader *>(node); if (shader->get_use_mis() && shader->has_surface_emission) - scene->light_manager->need_update = true; + scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED); } } @@ -946,7 +946,7 @@ void ObjectManager::tag_update(Scene *scene) { need_update = true; scene->geometry_manager->need_update = true; - scene->light_manager->need_update = true; + scene->light_manager->tag_update(scene, LightManager::OBJECT_MANAGER); } string ObjectManager::get_cryptomatte_objects(Scene *scene) diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index bea2c534bd1..c392a3b0a60 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -132,7 +132,7 @@ void OSLShaderManager::device_update(Device *device, compiler.compile(og, shader); if (shader->get_use_mis() && shader->has_surface_emission) - scene->light_manager->need_update = true; + scene->light_manager->tag_update(scene, LightManager::SHADER_COMPILED); } /* setup shader engine */ diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index 7cbd4411cf4..f84bfa82c69 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -484,7 +484,7 @@ void Scene::reset() integrator->tag_update(this, 0); object_manager->tag_update(this); geometry_manager->tag_update(this, GeometryManager::UPDATE_ALL); - light_manager->tag_update(this); + light_manager->tag_update(this, LightManager::UPDATE_ALL); particle_system_manager->tag_update(this); procedural_manager->need_update = true; } @@ -674,7 +674,7 @@ template<> Light *Scene::create_node<Light>() Light *node = new Light(); node->set_owner(this); lights.push_back(node); - light_manager->tag_update(this); + light_manager->tag_update(this, LightManager::LIGHT_ADDED); return node; } @@ -729,7 +729,7 @@ template<> Shader *Scene::create_node<Shader>() Shader *node = new Shader(); node->set_owner(this); shaders.push_back(node); - shader_manager->need_update = true; + shader_manager->tag_update(this, ShaderManager::SHADER_ADDED); return node; } @@ -758,7 +758,7 @@ template<typename T> void delete_node_from_array(vector<T> &nodes, T node) template<> void Scene::delete_node_impl(Light *node) { delete_node_from_array(lights, node); - light_manager->tag_update(this); + light_manager->tag_update(this, LightManager::LIGHT_REMOVED); } template<> void Scene::delete_node_impl(Mesh *node) @@ -845,7 +845,7 @@ static void remove_nodes_in_set(const set<T *> &nodes_set, template<> void Scene::delete_nodes(const set<Light *> &nodes, const NodeOwner *owner) { remove_nodes_in_set(nodes, lights, owner); - light_manager->tag_update(this); + light_manager->tag_update(this, LightManager::LIGHT_REMOVED); } template<> void Scene::delete_nodes(const set<Geometry *> &nodes, const NodeOwner *owner) diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index ce95c179ea1..c51a1a41691 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -310,13 +310,14 @@ void Shader::tag_update(Scene *scene) { /* update tag */ tag_modified(); - scene->shader_manager->need_update = true; + + scene->shader_manager->tag_update(scene, ShaderManager::SHADER_MODIFIED); /* if the shader previously was emissive, update light distribution, * if the new shader is emissive, a light manager update tag will be * done in the shader manager device update. */ if (use_mis && has_surface_emission) - scene->light_manager->need_update = true; + scene->light_manager->tag_update(scene, LightManager::SHADER_MODIFIED); /* Special handle of background MIS light for now: for some reason it * has use_mis set to false. We are quite close to release now, so @@ -325,7 +326,7 @@ void Shader::tag_update(Scene *scene) if (this == scene->background->get_shader(scene)) { scene->light_manager->need_update_background = true; if (scene->light_manager->has_background_light(scene)) { - scene->light_manager->need_update = true; + scene->light_manager->tag_update(scene, LightManager::SHADER_MODIFIED); } } @@ -373,7 +374,7 @@ void Shader::tag_used(Scene *scene) * recompiled because it was skipped for compilation before */ if (!used) { tag_modified(); - scene->shader_manager->need_update = true; + scene->shader_manager->tag_update(scene, ShaderManager::SHADER_MODIFIED); } } @@ -793,4 +794,9 @@ string ShaderManager::get_cryptomatte_materials(Scene *scene) return manifest; } +void ShaderManager::tag_update(Scene */*scene*/, uint32_t /*flag*/) +{ + need_update = true; +} + CCL_NAMESPACE_END diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index 0a8d0b7adf8..9eb72d46c76 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -165,6 +165,12 @@ class Shader : public Node { class ShaderManager { public: + enum { + INTEGRATOR_MODIFIED = (1 << 0), + SHADER_ADDED = (1 << 1), + SHADER_MODIFIED = (1 << 2), + }; + bool need_update; static ShaderManager *create(int shadingsystem); @@ -208,6 +214,8 @@ class ShaderManager { string get_cryptomatte_materials(Scene *scene); + void tag_update(Scene *scene, uint32_t flag); + protected: ShaderManager(); diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index b2bc17aec19..ccd52398d4c 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -125,7 +125,7 @@ void SVMShaderManager::device_update(Device *device, shader->clear_modified(); if (shader->get_use_mis() && shader->has_surface_emission) { - scene->light_manager->need_update = true; + scene->light_manager->tag_update(scene, LightManager::SHADER_COMPILED); } /* Update the global jump table. _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs