diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-09-10 18:34:36 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-09-10 19:05:11 +0300 |
commit | a4b18bd1b92ed932be6738a9e8e89efc1919162a (patch) | |
tree | d24e0d565e3333a94d719ca938e5f4034d6bbe49 /source/blender/draw/engines/eevee/eevee_lightprobes.c | |
parent | 2a907bea9cef6fa7450afaff3bf5eb25e3d214c0 (diff) |
Fix T56627: Crash because of incomplete LightCache
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_lightprobes.c')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lightprobes.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 50f4e694d2a..87f90f37913 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -312,9 +312,14 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) lightprobe_shaders_init(); } - if ((scene_eval->eevee.light_cache == NULL) && - (sldata->fallback_lightcache == NULL)) - { + /* Use fallback if we don't have gpu texture allocated an we cannot restore them. */ + bool use_fallback_lightcache = (scene_eval->eevee.light_cache == NULL) || + ((scene_eval->eevee.light_cache->grid_tx.tex == NULL) && + (scene_eval->eevee.light_cache->grid_tx.data == NULL)) || + ((scene_eval->eevee.light_cache->cube_tx.tex == NULL) && + (scene_eval->eevee.light_cache->cube_tx.data == NULL)); + + if (use_fallback_lightcache && (sldata->fallback_lightcache == NULL)) { #if defined(IRRADIANCE_SH_L2) int grid_res = 4; #elif defined(IRRADIANCE_CUBEMAP) @@ -324,11 +329,10 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) #endif int cube_res = OCTAHEDRAL_SIZE_FROM_CUBESIZE(scene_eval->eevee.gi_cubemap_resolution); int vis_res = scene_eval->eevee.gi_visibility_resolution; - sldata->fallback_lightcache = EEVEE_lightcache_create(1, 1, cube_res, vis_res, (int[3]){grid_res, grid_res, 1}); } - stl->g_data->light_cache = (scene_eval->eevee.light_cache) ? scene_eval->eevee.light_cache : sldata->fallback_lightcache; + stl->g_data->light_cache = (use_fallback_lightcache) ? sldata->fallback_lightcache : scene_eval->eevee.light_cache; EEVEE_lightcache_load(stl->g_data->light_cache); |