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-01-11 16:08:21 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-01-11 18:50:54 +0300
commit0142264508925ddc02a67d5f65759ca24bafa387 (patch)
treed1df4c9c0ac6103cc1776a779cc171272260aed4 /source/blender/draw/engines/eevee/eevee_data.c
parenta08f687b91a2a7880889f7970bcefd10e92b0966 (diff)
Eevee: Lamps: Optimize lamps CPU/Memory usage.
Tests on my system with ~1200 objects with 128 shadow casting lamps (current max) show a significant perf improvment (cache timing : 22ms -> 9ms) With a baseline with no shadow casting light at 6ms this give a reduction of the overhead from 16ms to 3ms. This remove pretty much all allocations during the cache phase. Leading to a big improvement for scene with a large number of lights & shadowcasters. The lamps storage has been replace by a union to remove the need to free/allocate everyframe (also reducing memory fragmentation). We replaced the linked list system used to track shadow casters by a huge bitflag. We gather the lights shadows bounds as well as the shadow casters AABB during the cache populate phase and put them in big arrays cache friendly. Then in the cache finish phase, it's easier to iterate over the lamps shadow SphereBounds and test for intersection. We use a double buffer system for the shadow casters arrays to detect deleted shadow casters. Unfortunatly, it seems that deleting an object trigger an update for all other objects (thus tagging most shadow casting lamps to update), defeating the purpose of this tracking. This needs further investigation.
Diffstat (limited to 'source/blender/draw/engines/eevee/eevee_data.c')
-rw-r--r--source/blender/draw/engines/eevee/eevee_data.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c
index d5582a498a4..f34601ef7b6 100644
--- a/source/blender/draw/engines/eevee/eevee_data.c
+++ b/source/blender/draw/engines/eevee/eevee_data.c
@@ -45,7 +45,10 @@ static void eevee_view_layer_data_free(void *storage)
DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_target);
DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_blur);
DRW_TEXTURE_FREE_SAFE(sldata->shadow_pool);
- BLI_freelistN(&sldata->shadow_casters);
+ MEM_SAFE_FREE(sldata->shcasters_buffers[0].shadow_casters);
+ MEM_SAFE_FREE(sldata->shcasters_buffers[0].flags);
+ MEM_SAFE_FREE(sldata->shcasters_buffers[1].shadow_casters);
+ MEM_SAFE_FREE(sldata->shcasters_buffers[1].flags);
/* Probes */
MEM_SAFE_FREE(sldata->probes);
@@ -64,14 +67,6 @@ static void eevee_view_layer_data_free(void *storage)
MEM_SAFE_FREE(sldata->volumetrics);
}
-static void eevee_lamp_data_free(void *storage)
-{
- EEVEE_LampEngineData *led = (EEVEE_LampEngineData *)storage;
-
- MEM_SAFE_FREE(led->storage);
- BLI_freelistN(&led->shadow_caster_list);
-}
-
static void eevee_lightprobe_data_free(void *storage)
{
EEVEE_LightProbeEngineData *ped = (EEVEE_LightProbeEngineData *)storage;
@@ -110,6 +105,7 @@ EEVEE_ObjectEngineData *EEVEE_object_data_ensure(Object *ob)
if (*oedata == NULL) {
*oedata = MEM_callocN(sizeof(**oedata), "EEVEE_ObjectEngineData");
+ (*oedata)->shadow_caster_id = -1;
}
return *oedata;
@@ -144,11 +140,12 @@ EEVEE_LampEngineData *EEVEE_lamp_data_get(Object *ob)
EEVEE_LampEngineData *EEVEE_lamp_data_ensure(Object *ob)
{
EEVEE_LampEngineData **ledata = (EEVEE_LampEngineData **)DRW_object_engine_data_ensure(
- ob, &draw_engine_eevee_type, &eevee_lamp_data_free);
+ ob, &draw_engine_eevee_type, NULL);
if (*ledata == NULL) {
*ledata = MEM_callocN(sizeof(**ledata), "EEVEE_LampEngineData");
(*ledata)->need_update = true;
+ (*ledata)->prev_cube_shadow_id = -1;
}
return *ledata;