diff options
author | Jacques Lucke <jacques@blender.org> | 2020-11-06 15:35:19 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-11-06 15:35:19 +0300 |
commit | 41db8f2fce1763c312a7fa47ed3aa338e6d77124 (patch) | |
tree | cc38e034a760ffe83859d38eb335ce4f1599e7fc /source/blender/blenloader/intern | |
parent | da96389dcba7b07506fd241616e7b1db3ba7a27b (diff) |
Refactor: move LightCache .blend I/O to eevee_lightcache.c
Ref T76372.
Diffstat (limited to 'source/blender/blenloader/intern')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 43 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 39 |
2 files changed, 4 insertions, 78 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f7ae7e1e2a2..fcf839f8751 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3894,47 +3894,6 @@ static void lib_link_sequence_modifiers(BlendLibReader *reader, Scene *scene, Li } } -static void direct_link_lightcache_texture(BlendDataReader *reader, LightCacheTexture *lctex) -{ - lctex->tex = NULL; - - if (lctex->data) { - BLO_read_data_address(reader, &lctex->data); - if (lctex->data && BLO_read_requires_endian_switch(reader)) { - int data_size = lctex->components * lctex->tex_size[0] * lctex->tex_size[1] * - lctex->tex_size[2]; - - if (lctex->data_type == LIGHTCACHETEX_FLOAT) { - BLI_endian_switch_float_array((float *)lctex->data, data_size * sizeof(float)); - } - else if (lctex->data_type == LIGHTCACHETEX_UINT) { - BLI_endian_switch_uint32_array((uint *)lctex->data, data_size * sizeof(uint)); - } - } - } - - if (lctex->data == NULL) { - zero_v3_int(lctex->tex_size); - } -} - -static void direct_link_lightcache(BlendDataReader *reader, LightCache *cache) -{ - cache->flag &= ~LIGHTCACHE_NOT_USABLE; - direct_link_lightcache_texture(reader, &cache->cube_tx); - direct_link_lightcache_texture(reader, &cache->grid_tx); - - if (cache->cube_mips) { - BLO_read_data_address(reader, &cache->cube_mips); - for (int i = 0; i < cache->mips_len; i++) { - direct_link_lightcache_texture(reader, &cache->cube_mips[i]); - } - } - - BLO_read_data_address(reader, &cache->cube_data); - BLO_read_data_address(reader, &cache->grid_data); -} - /* check for cyclic set-scene, * libs can cause this case which is normally prevented, see (T#####) */ #define USE_SETSCENE_CHECK @@ -4512,7 +4471,7 @@ static void direct_link_scene(BlendDataReader *reader, Scene *sce) /* else try to read the cache from file. */ BLO_read_data_address(reader, &sce->eevee.light_cache_data); if (sce->eevee.light_cache_data) { - direct_link_lightcache(reader, sce->eevee.light_cache_data); + EEVEE_lightcache_blend_read_data(reader, sce->eevee.light_cache_data); } } EEVEE_lightcache_info_update(&sce->eevee); diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 8583e8b3b10..f5b588883b3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -170,6 +170,8 @@ #include "SEQ_sequencer.h" +#include "engines/eevee/eevee_lightcache.h" + #include "readfile.h" #include <errno.h> @@ -1322,41 +1324,6 @@ static void write_view_settings(BlendWriter *writer, ColorManagedViewSettings *v } } -static void write_lightcache_texture(BlendWriter *writer, LightCacheTexture *tex) -{ - if (tex->data) { - size_t data_size = tex->components * tex->tex_size[0] * tex->tex_size[1] * tex->tex_size[2]; - if (tex->data_type == LIGHTCACHETEX_FLOAT) { - data_size *= sizeof(float); - } - else if (tex->data_type == LIGHTCACHETEX_UINT) { - data_size *= sizeof(uint); - } - - /* FIXME: We can't save more than what 32bit systems can handle. - * The solution would be to split the texture but it is too late for 2.90. (see T78529) */ - if (data_size < INT_MAX) { - BLO_write_raw(writer, data_size, tex->data); - } - } -} - -static void write_lightcache(BlendWriter *writer, LightCache *cache) -{ - write_lightcache_texture(writer, &cache->grid_tx); - write_lightcache_texture(writer, &cache->cube_tx); - - if (cache->cube_mips) { - BLO_write_struct_array(writer, LightCacheTexture, cache->mips_len, cache->cube_mips); - for (int i = 0; i < cache->mips_len; i++) { - write_lightcache_texture(writer, &cache->cube_mips[i]); - } - } - - BLO_write_struct_array(writer, LightGridCache, cache->grid_len, cache->grid_data); - BLO_write_struct_array(writer, LightProbeCache, cache->cube_len, cache->cube_data); -} - static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) { if (BLO_write_is_undo(writer)) { @@ -1583,7 +1550,7 @@ static void write_scene(BlendWriter *writer, Scene *sce, const void *id_address) /* Eevee Lightcache */ if (sce->eevee.light_cache_data && !BLO_write_is_undo(writer)) { BLO_write_struct(writer, LightCache, sce->eevee.light_cache_data); - write_lightcache(writer, sce->eevee.light_cache_data); + EEVEE_lightcache_blend_write(writer, sce->eevee.light_cache_data); } BKE_screen_view3d_shading_blend_write(writer, &sce->display.shading); |