Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-07-09 18:08:05 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-07-09 18:08:05 +0300
commitdeaa90b5a5fef3baac86aef758f2f7ded50043e9 (patch)
treecd846afc8dd3dca57734ca711528a14c37ad8859
parenta21742a07b4240e08386427c2ae5f20d5e45fade (diff)
Eevee: LightCache: Add Light Cache infos in the UI
This is still a bit basic but will be enhance in the future.
-rw-r--r--release/scripts/startup/bl_ui/properties_render.py5
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c46
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.h2
-rw-r--r--source/blender/editors/render/render_shading.c2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_scene.c5
6 files changed, 61 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 7c52b8ec118..ff36d2494ea 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -721,6 +721,11 @@ class RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
col.operator("scene.light_cache_bake", text="Bake Indirect Lighting", icon='RENDER_STILL')
col.operator("scene.light_cache_bake", text="Bake Cubemap Only", icon='LIGHTPROBE_CUBEMAP').subset = "CUBEMAPS"
col.operator("scene.light_cache_free", text="Free Lighting Cache")
+
+ cache_info = scene.eevee.gi_cache_info
+ if cache_info:
+ col.label(text=cache_info)
+
col.prop(props, "gi_auto_bake")
col.prop(props, "gi_diffuse_bounces")
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 07b07bc85cd..9f14aa581fb 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -150,6 +150,50 @@ typedef struct EEVEE_LightBake {
/** \name Light Cache
* \{ */
+/* Return memory footprint in bytes. */
+static unsigned int eevee_lightcache_memsize_get(LightCache *lcache)
+{
+ unsigned int size = 0;
+ if (lcache->grid_tx.data) {
+ size += MEM_allocN_len(lcache->grid_tx.data);
+ }
+ if (lcache->cube_tx.data) {
+ size += MEM_allocN_len(lcache->cube_tx.data);
+ for (int mip = 0; mip < lcache->mips_len; ++mip) {
+ size += MEM_allocN_len(lcache->cube_mips[mip].data);
+ }
+ }
+ return size;
+}
+
+static int eevee_lightcache_irradiance_sample_count(LightCache *lcache)
+{
+ int total_irr_samples = 0;
+
+ for (int i = 1; i < lcache->grid_len; ++i) {
+ EEVEE_LightGrid *egrid = lcache->grid_data + i;
+ total_irr_samples += egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2];
+ }
+ return total_irr_samples;
+}
+
+void EEVEE_lightcache_info_update(SceneEEVEE *eevee)
+{
+ LightCache *lcache = eevee->light_cache;
+
+ if (lcache != NULL) {
+ char formatted_mem[15];
+ BLI_str_format_byte_unit(formatted_mem, eevee_lightcache_memsize_get(lcache), true);
+
+ int irr_samples = eevee_lightcache_irradiance_sample_count(lcache);
+
+ BLI_snprintf(eevee->light_cache_info, sizeof(eevee->light_cache_info), IFACE_("%d Ref. Cubemaps, %d Irr. Samples (%s in memory)"), lcache->cube_len - 1, irr_samples, formatted_mem);
+ }
+ else {
+ BLI_strncpy(eevee->light_cache_info, IFACE_("No light cache in this scene."), sizeof(eevee->light_cache_info));
+ }
+}
+
static void irradiance_pool_size_get(int visibility_size, int total_samples, int r_size[3])
{
/* Compute how many irradiance samples we can store per visibility sample. */
@@ -925,6 +969,8 @@ void EEVEE_lightbake_update(void *custom_data)
lbake->own_light_cache = false;
}
+ EEVEE_lightcache_info_update(&lbake->scene->eevee);
+
DEG_id_tag_update(&scene_orig->id, DEG_TAG_COPY_ON_WRITE);
}
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.h b/source/blender/draw/engines/eevee/eevee_lightcache.h
index 2400486a698..b58a0544c59 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.h
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.h
@@ -30,6 +30,7 @@
struct ViewLayer;
struct Scene;
+struct SceneEEVEE;
struct LightCache;
struct EEVEE_ViewLayerData;
struct EEVEE_Data;
@@ -53,5 +54,6 @@ struct LightCache *EEVEE_lightcache_create(
const int irr_size[3]);
void EEVEE_lightcache_free(struct LightCache *lcache);
void EEVEE_lightcache_load(struct LightCache *lcache);
+void EEVEE_lightcache_info_update(struct SceneEEVEE *eevee);
#endif /* __EEVEE_LIGHTCACHE_H__ */ \ No newline at end of file
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index e0dde9b862b..19f30ac59aa 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -834,6 +834,8 @@ static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op))
EEVEE_lightcache_free(scene->eevee.light_cache);
scene->eevee.light_cache = NULL;
+ EEVEE_lightcache_info_update(&scene->eevee);
+
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 27b23f62210..e6ad7835b24 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1433,6 +1433,7 @@ typedef struct SceneEEVEE {
int shadow_cascade_size;
struct LightCache *light_cache;
+ char light_cache_info[64];
} SceneEEVEE;
/* *************************************************************** */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index b5d9cbbedcd..d6b70bef1d9 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5841,6 +5841,11 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
RNA_def_property_boolean_default(prop, 0);
RNA_def_property_ui_text(prop, "Auto Bake", "Auto bake indirect lighting when editing probes");
+ prop = RNA_def_property(srna, "gi_cache_info", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "light_cache_info");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Light Cache Info", "Info on current cache status");
+
/* Temporal Anti-Aliasing (super sampling) */
prop = RNA_def_property(srna, "taa_samples", PROP_INT, PROP_NONE);
RNA_def_property_int_default(prop, 16);