[Bf-blender-cvs] [4906998754c] cycles_procedural_api: note down some thoughts for the light manager

Kévin Dietrich noreply at git.blender.org
Mon Nov 16 13:11:01 CET 2020


Commit: 4906998754ca901a93e34b435a5c944269f3851a
Author: Kévin Dietrich
Date:   Tue Nov 10 18:16:01 2020 +0100
Branches: cycles_procedural_api
https://developer.blender.org/rB4906998754ca901a93e34b435a5c944269f3851a

note down some thoughts for the light manager

===================================================================

M	intern/cycles/render/light.cpp
M	intern/cycles/render/light.h

===================================================================

diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 9989fa32f82..4bd226d2cdb 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -980,13 +980,24 @@ void LightManager::device_update(Device *device,
 
   use_light_visibility = false;
 
-  device_update_points(device, dscene, scene);
-  if (progress.get_cancel())
-    return;
+  bool need_update_points = true;
 
-  device_update_distribution(device, dscene, scene, progress);
-  if (progress.get_cancel())
-    return;
+  if (need_update_points) {
+    device_update_points(device, dscene, scene);
+    if (progress.get_cancel())
+      return;
+  }
+
+  bool need_update_distribution = true;
+  need_update_distribution |= (update_flags & (SHADER_MODIFIED | SHADER_COMPILED)) != 0;
+  need_update_distribution |= (update_flags & (OBJECT_ADDED | OBJECT_REMOVED)) != 0;
+  need_update_distribution |= (update_flags & (LIGHT_ADDED | LIGHT_REMOVED)) != 0;
+
+  if (need_update_distribution) {
+    device_update_distribution(device, dscene, scene, progress);
+    if (progress.get_cancel())
+      return;
+  }
 
   if (need_update_background) {
     device_update_background(device, dscene, scene, progress);
@@ -994,9 +1005,13 @@ void LightManager::device_update(Device *device,
       return;
   }
 
-  device_update_ies(dscene);
-  if (progress.get_cancel())
-    return;
+  bool need_update_ies = true;
+
+  if (need_update_ies) {
+    device_update_ies(dscene);
+    if (progress.get_cancel())
+      return;
+  }
 
   scene->film->set_use_light_visibility(use_light_visibility);
 
@@ -1015,9 +1030,23 @@ void LightManager::device_free(Device *, DeviceScene *dscene, const bool free_ba
   dscene->ies_lights.free();
 }
 
-void LightManager::tag_update(Scene * /*scene*/, uint32_t /*flag*/)
+void LightManager::tag_update(Scene * /*scene*/, UpdateFlags flag)
 {
-  update_flags |= UPDATE_ALL;
+  /* todo(kevin)
+   *
+   * dscene->lights
+   * - light->is_enabled (strength, light_type, shader)
+   * - light->is_portal
+   *
+   * dscene->light_distribution
+   * - light->is_enabled (strength, light_type, shader)
+   * - light->is_portal
+   * - object_useable_as_light, but needs valid bounds to know in advance what is needed
+   * - shader modified or compiled
+   *
+   * dscene->ies_lights, just a special flag would be enough
+   */
+  update_flags |= flag;
 }
 
 bool LightManager::need_update() const
diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h
index a7093cd74e1..afeecc64c9f 100644
--- a/intern/cycles/render/light.h
+++ b/intern/cycles/render/light.h
@@ -108,7 +108,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, uint32_t flag);
+  void tag_update(Scene *scene, UpdateFlags flag);
 
   bool need_update() const;



More information about the Bf-blender-cvs mailing list