Commit: ed7f6b511f817d9b93eecb07955a30eb3a5afb87
Author: Clément Foucault
Date:   Tue Oct 23 18:04:29 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBed7f6b511f817d9b93eecb07955a30eb3a5afb87

Eevee: Fix lightcache not working for small caches

Was caused by a threading issue. The lightcache was free before the endjob
function pass it to the scene.

Also fix cache reuse if size matches.

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

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 f7945da196e..425749b0b52 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -226,7 +226,7 @@ static bool EEVEE_lightcache_validate(
                if ((irr_size[0] == light_cache->grid_tx.tex_size[0]) &&
                    (irr_size[1] == light_cache->grid_tx.tex_size[1]) &&
                    (irr_size[2] == light_cache->grid_tx.tex_size[2]) &&
-                   (grid_len != light_cache->grid_len))
+                   (grid_len == light_cache->grid_len))
                {
                        int mip_len = (int)(floorf(log2f(cube_res)) - 
MIN_CUBE_LOD_LEVEL);
                        if ((cube_res == light_cache->cube_tx.tex_size[0]) &&
@@ -472,8 +472,7 @@ static void 
eevee_lightbake_create_resources(EEVEE_LightBake *lbake)
        lbake->lcache = eevee->light_cache;
 
        /* TODO validate irradiance and reflection cache independently... */
-       if (lbake->lcache != NULL &&
-           !EEVEE_lightcache_validate(lbake->lcache, lbake->cube_len, 
lbake->ref_cube_res, lbake->grid_len, lbake->irr_size))
+       if (!EEVEE_lightcache_validate(lbake->lcache, lbake->cube_len, 
lbake->ref_cube_res, lbake->grid_len, lbake->irr_size))
        {
                eevee->light_cache = lbake->lcache = NULL;
        }
@@ -613,11 +612,6 @@ static void 
eevee_lightbake_delete_resources(EEVEE_LightBake *lbake)
                DRW_opengl_context_enable();
        }
 
-       if (lbake->own_light_cache) {
-               EEVEE_lightcache_free(lbake->lcache);
-               lbake->lcache = NULL;
-       }
-
        /* XXX Free the resources contained in the viewlayer data
         * to be able to free the context before deleting the depsgraph.  */
        if (lbake->sldata) {

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

Reply via email to