Commit: 47cfdb3c0ce62d3ceba8b52c3cf276e7562e361a
Author: Clément Foucault
Date:   Sun Apr 8 14:31:41 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB47cfdb3c0ce62d3ceba8b52c3cf276e7562e361a

Eevee: Reduce loading time.

Only compile the needed shadow shaders to reduce the startup time.

Theses shaders is taking forever to compile on intel (~5s each).

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

M       source/blender/draw/engines/eevee/eevee_lights.c

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

diff --git a/source/blender/draw/engines/eevee/eevee_lights.c 
b/source/blender/draw/engines/eevee/eevee_lights.c
index 56c9ed4555d..7496142a26e 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -107,50 +107,6 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
        if (!e_data.shadow_sh) {
                e_data.shadow_sh = DRW_shader_create(
                        datatoc_shadow_vert_glsl, datatoc_shadow_geom_glsl, 
datatoc_shadow_frag_glsl, NULL);
-
-               DynStr *ds_frag = BLI_dynstr_new();
-               BLI_dynstr_append(ds_frag, datatoc_concentric_samples_lib_glsl);
-               BLI_dynstr_append(ds_frag, datatoc_shadow_store_frag_glsl);
-               char *store_shadow_shader_str = BLI_dynstr_get_cstring(ds_frag);
-               BLI_dynstr_free(ds_frag);
-
-               e_data.shadow_store_cube_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
-                       store_shadow_shader_str,
-                       "#define ESM\n");
-               e_data.shadow_store_cascade_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
-                       store_shadow_shader_str,
-                       "#define ESM\n"
-                       "#define CSM\n");
-
-               e_data.shadow_store_cube_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
-                       store_shadow_shader_str,
-                       "#define VSM\n");
-               e_data.shadow_store_cascade_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
-                       store_shadow_shader_str,
-                       "#define VSM\n"
-                       "#define CSM\n");
-
-               MEM_freeN(store_shadow_shader_str);
-
-               e_data.shadow_copy_cube_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
-                       datatoc_shadow_copy_frag_glsl,
-                       "#define ESM\n"
-                       "#define COPY\n");
-               e_data.shadow_copy_cascade_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
-                       datatoc_shadow_copy_frag_glsl,
-                       "#define ESM\n"
-                       "#define COPY\n"
-                       "#define CSM\n");
-
-               e_data.shadow_copy_cube_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
-                       datatoc_shadow_copy_frag_glsl,
-                       "#define VSM\n"
-                       "#define COPY\n");
-               e_data.shadow_copy_cascade_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
-                       datatoc_shadow_copy_frag_glsl,
-                       "#define VSM\n"
-                       "#define COPY\n"
-                       "#define CSM\n");
        }
 
        if (!sldata->lamps) {
@@ -204,6 +160,60 @@ void EEVEE_lights_init(EEVEE_ViewLayerData *sldata)
                linfo->shadow_cube_target_size = new_cube_target_size;
                linfo->shadow_render_data.cube_texel_size = 1.0 / 
(float)linfo->shadow_cube_target_size;
        }
+
+       /* only compile the ones needed. reduce startup time. */
+       if ((sh_method == SHADOW_ESM) && 
!e_data.shadow_store_cube_sh[SHADOW_ESM]) {
+               DynStr *ds_frag = BLI_dynstr_new();
+               BLI_dynstr_append(ds_frag, datatoc_concentric_samples_lib_glsl);
+               BLI_dynstr_append(ds_frag, datatoc_shadow_store_frag_glsl);
+               char *store_shadow_shader_str = BLI_dynstr_get_cstring(ds_frag);
+               BLI_dynstr_free(ds_frag);
+
+               e_data.shadow_store_cube_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
+                       store_shadow_shader_str,
+                       "#define ESM\n");
+               e_data.shadow_store_cascade_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
+                       store_shadow_shader_str,
+                       "#define ESM\n"
+                       "#define CSM\n");
+               MEM_freeN(store_shadow_shader_str);
+
+               e_data.shadow_copy_cube_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
+                       datatoc_shadow_copy_frag_glsl,
+                       "#define ESM\n"
+                       "#define COPY\n");
+               e_data.shadow_copy_cascade_sh[SHADOW_ESM] = 
DRW_shader_create_fullscreen(
+                       datatoc_shadow_copy_frag_glsl,
+                       "#define ESM\n"
+                       "#define COPY\n"
+                       "#define CSM\n");
+       }
+       else if ((sh_method == SHADOW_VSM) && 
!e_data.shadow_store_cube_sh[SHADOW_VSM]) {
+               DynStr *ds_frag = BLI_dynstr_new();
+               BLI_dynstr_append(ds_frag, datatoc_concentric_samples_lib_glsl);
+               BLI_dynstr_append(ds_frag, datatoc_shadow_store_frag_glsl);
+               char *store_shadow_shader_str = BLI_dynstr_get_cstring(ds_frag);
+               BLI_dynstr_free(ds_frag);
+
+               e_data.shadow_store_cube_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
+                       store_shadow_shader_str,
+                       "#define VSM\n");
+               e_data.shadow_store_cascade_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
+                       store_shadow_shader_str,
+                       "#define VSM\n"
+                       "#define CSM\n");
+               MEM_freeN(store_shadow_shader_str);
+
+               e_data.shadow_copy_cube_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
+                       datatoc_shadow_copy_frag_glsl,
+                       "#define VSM\n"
+                       "#define COPY\n");
+               e_data.shadow_copy_cascade_sh[SHADOW_VSM] = 
DRW_shader_create_fullscreen(
+                       datatoc_shadow_copy_frag_glsl,
+                       "#define VSM\n"
+                       "#define COPY\n"
+                       "#define CSM\n");
+       }
 }
 
 void EEVEE_lights_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to