Commit: fce71a255cb9fcc1559247dc5c91e5d4b3481b05
Author: Clément Foucault
Date:   Wed Aug 5 02:26:16 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rBfce71a255cb9fcc1559247dc5c91e5d4b3481b05

EEVEE: LightCache: Add warning if the cache cannot be saved

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

M       source/blender/draw/engines/eevee/eevee_lightcache.c

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

diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c 
b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 92bb9227e13..d3a47c2641c 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -203,6 +203,21 @@ static bool eevee_lightcache_version_check(LightCache 
*lcache)
   }
 }
 
+static bool eevee_lightcache_can_be_saved(LightCache *lcache)
+{
+  if (lcache->grid_tx.data) {
+    if (MEM_allocN_len(lcache->grid_tx.data) >= INT_MAX) {
+      return false;
+    }
+  }
+  if (lcache->cube_tx.data) {
+    if (MEM_allocN_len(lcache->cube_tx.data) >= INT_MAX) {
+      return false;
+    }
+  }
+  return true;
+}
+
 static int eevee_lightcache_irradiance_sample_count(LightCache *lcache)
 {
   int total_irr_samples = 0;
@@ -246,6 +261,13 @@ void EEVEE_lightcache_info_update(SceneEEVEE *eevee)
       return;
     }
 
+    if (!eevee_lightcache_can_be_saved(lcache)) {
+      BLI_strncpy(eevee->light_cache_info,
+                  TIP_("Error: LightCache is too large and will not be saved 
to disk"),
+                  sizeof(eevee->light_cache_info));
+      return;
+    }
+
     char formatted_mem[15];
     BLI_str_format_byte_unit(formatted_mem, 
eevee_lightcache_memsize_get(lcache), false);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to