diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-05 09:48:20 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-05 09:48:20 +0300 |
commit | 8e5a4e364530686765daff435047eacddbc1a374 (patch) | |
tree | 10d6b486bb19c49a370dae30e134b2d181b148b4 /source/blender/draw/engines | |
parent | db907ea888408f7700478ac581aab652df0c2855 (diff) | |
parent | 6be8b6af4006e088ac4a2cd8c1adc8f18c04035b (diff) |
Merge branch 'blender-v2.90-release' into master
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lightcache.c | 55 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lightprobes.c | 9 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_private.h | 3 |
3 files changed, 58 insertions, 9 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index 78fcd28eb5d..92bb9227e13 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -228,7 +228,14 @@ void EEVEE_lightcache_info_update(SceneEEVEE *eevee) if (lcache->cube_tx.tex_size[2] > GPU_max_texture_layers()) { BLI_strncpy(eevee->light_cache_info, - TIP_("Error: Light cache is too big for your GPU to be loaded"), + TIP_("Error: Light cache is too big for the GPU to be loaded"), + sizeof(eevee->light_cache_info)); + return; + } + + if (lcache->flag & LIGHTCACHE_INVALID) { + BLI_strncpy(eevee->light_cache_info, + TIP_("Error: Light cache dimensions not supported by the GPU"), sizeof(eevee->light_cache_info)); return; } @@ -281,7 +288,7 @@ static bool EEVEE_lightcache_validate(const LightCache *light_cache, const int grid_len, const int irr_size[3]) { - if (light_cache) { + if (light_cache && !(light_cache->flag & LIGHTCACHE_INVALID)) { /* See if we need the same amount of texture space. */ if ((irr_size[0] == light_cache->grid_tx.tex_size[0]) && (irr_size[1] == light_cache->grid_tx.tex_size[1]) && @@ -343,12 +350,18 @@ LightCache *EEVEE_lightcache_create(const int grid_len, light_cache->cube_mips = MEM_callocN(sizeof(LightCacheTexture) * light_cache->mips_len, "LightCacheTexture"); - for (int mip = 0; mip < light_cache->mips_len; mip++) { - GPU_texture_get_mipmap_size( - light_cache->cube_tx.tex, mip + 1, light_cache->cube_mips[mip].tex_size); + if (light_cache->grid_tx.tex == NULL || light_cache->cube_tx.tex == NULL) { + /* We could not create the requested textures size. Stop baking and do not use the cache. */ + light_cache->flag = LIGHTCACHE_INVALID; } + else { + light_cache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID; - light_cache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | LIGHTCACHE_UPDATE_GRID; + for (int mip = 0; mip < light_cache->mips_len; mip++) { + GPU_texture_get_mipmap_size( + light_cache->cube_tx.tex, mip + 1, light_cache->cube_mips[mip].tex_size); + } + } return light_cache; } @@ -376,6 +389,12 @@ static bool eevee_lightcache_static_load(LightCache *lcache) 0, false, NULL); + + if (lcache->grid_tx.tex == NULL) { + lcache->flag |= LIGHTCACHE_NOT_USABLE; + return false; + } + GPU_texture_filter_mode(lcache->grid_tx.tex, true); } @@ -401,6 +420,11 @@ static bool eevee_lightcache_static_load(LightCache *lcache) NULL); } + if (lcache->cube_tx.tex == NULL) { + lcache->flag |= LIGHTCACHE_NOT_USABLE; + return false; + } + for (int mip = 0; mip < lcache->mips_len; mip++) { GPU_texture_add_mipmap( lcache->cube_tx.tex, GPU_DATA_10_11_11_REV, mip + 1, lcache->cube_mips[mip].data); @@ -420,6 +444,10 @@ bool EEVEE_lightcache_load(LightCache *lcache) return false; } + if (lcache->flag & (LIGHTCACHE_INVALID | LIGHTCACHE_NOT_USABLE)) { + return false; + } + switch (lcache->type) { case LIGHTCACHE_TYPE_STATIC: return eevee_lightcache_static_load(lcache); @@ -590,9 +618,7 @@ static void eevee_lightbake_create_resources(EEVEE_LightBake *lbake) if (lbake->lcache == NULL) { lbake->lcache = EEVEE_lightcache_create( lbake->grid_len, lbake->cube_len, lbake->ref_cube_res, lbake->vis_res, lbake->irr_size); - lbake->lcache->flag = LIGHTCACHE_UPDATE_WORLD | LIGHTCACHE_UPDATE_CUBE | - LIGHTCACHE_UPDATE_GRID; - lbake->lcache->vis_res = lbake->vis_res; + lbake->own_light_cache = true; eevee->light_cache_data = lbake->lcache; @@ -1269,6 +1295,17 @@ void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float * We cannot do it in the main thread. */ eevee_lightbake_context_enable(lbake); eevee_lightbake_create_resources(lbake); + + /* Resource allocation can fail. Early exit in this case. */ + if (lbake->lcache->flag & LIGHTCACHE_INVALID) { + *lbake->stop = 1; + *lbake->do_update = 1; + lbake->lcache->flag &= ~LIGHTCACHE_BAKING; + eevee_lightbake_context_disable(lbake); + eevee_lightbake_delete_resources(lbake); + return; + } + eevee_lightbake_create_render_target(lbake, lbake->rt_res); eevee_lightbake_context_disable(lbake); diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index a4c07584b86..47a913640c7 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -23,6 +23,7 @@ #include "DRW_render.h" #include "BLI_rand.h" +#include "BLI_string_utils.h" #include "BLI_utildefines.h" #include "DNA_image_types.h" @@ -161,6 +162,7 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); + vedata->info[0] = '\0'; if (!e_data.hammersley) { EEVEE_shaders_lightprobe_shaders_init(); @@ -176,6 +178,13 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) stl->g_data->light_cache = scene_eval->eevee.light_cache_data; } else { + if (scene_eval->eevee.light_cache_data && + (scene_eval->eevee.light_cache_data->flag & LIGHTCACHE_NOT_USABLE)) { + /* Error message info. */ + BLI_snprintf( + vedata->info, sizeof(vedata->info), "Error: LightCache cannot be loaded on this GPU"); + } + if (!sldata->fallback_lightcache) { #if defined(IRRADIANCE_SH_L2) int grid_res = 4; diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index c202bbbb754..87ec2785fc6 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -29,6 +29,8 @@ #include "DNA_lightprobe_types.h" +#include "GPU_viewport.h" + #include "BKE_camera.h" struct EEVEE_ShadowCasterBuffer; @@ -890,6 +892,7 @@ typedef struct EEVEE_Data { EEVEE_TextureList *txl; EEVEE_PassList *psl; EEVEE_StorageList *stl; + char info[GPU_INFO_SIZE]; } EEVEE_Data; typedef struct EEVEE_PrivateData { |