From ac37a156754e7fdcf951f50d7318e041bd6cb8c7 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 21 Dec 2006 19:37:53 +0000 Subject: [PATCH] "Save Buffers" fix: when you ESC from rendering, it now saves empty tiles in the file, that read back fast as black. This also solves crashes on partial written files, when trying to read them. --- .../imbuf/intern/openexr/openexr_api.cpp | 5 +++++ .../imbuf/intern/openexr/openexr_multi.h | 2 ++ .../blender/render/intern/source/pipeline.c | 20 +++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index c035862c23f..b39700e019c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -526,6 +526,11 @@ void IMB_exr_set_channel(void *handle, char *layname, char *passname, int xstrid printf("IMB_exrtile_set_channel error %s\n", name); } +void IMB_exrtile_clear_channels(void *handle) +{ + ExrHandle *data= (ExrHandle *)handle; + BLI_freelistN(&data->channels); +} void IMB_exrtile_write_channels(void *handle, int partx, int party) { diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h index b9aa81e81da..ca4f7405f44 100644 --- a/source/blender/imbuf/intern/openexr/openexr_multi.h +++ b/source/blender/imbuf/intern/openexr/openexr_multi.h @@ -53,6 +53,7 @@ void IMB_exr_set_channel (void *handle, char *layname, char *passname, int xst void IMB_exr_read_channels (void *handle); void IMB_exr_write_channels (void *handle); void IMB_exrtile_write_channels (void *handle, int partx, int party); +void IMB_exrtile_clear_channels (void *handle); void IMB_exr_multilayer_convert (void *handle, void *base, void * (*addlayer)(void *base, char *str), @@ -77,6 +78,7 @@ void IMB_exr_set_channel (void *handle, char *layname, char *channame, int xst void IMB_exr_read_channels (void *handle) {} void IMB_exr_write_channels (void *handle) {} void IMB_exrtile_write_channels (void *handle, int partx, int party) {} +void IMB_exrtile_clear_channels (void *handle) {} void IMB_exr_multilayer_convert (void *handle, void *base, void * (*addlayer)(void *base, char *str), diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index f2015bcd494..84dcff1dd82 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -677,6 +677,22 @@ static void save_render_result_tile(Render *re, RenderPart *pa) } +static void save_empty_result_tiles(Render *re) +{ + RenderPart *pa; + + IMB_exrtile_clear_channels(re->result->exrhandle); + + for(pa= re->parts.first; pa; pa= pa->next) { + if(pa->ready==0) { + int party= pa->disprect.ymin - re->disprect.ymin + pa->crop; + int partx= pa->disprect.xmin - re->disprect.xmin + pa->crop; + IMB_exrtile_write_channels(re->result->exrhandle, partx, party); + } + } +} + + /* for passes read from files, these have names stored */ static char *make_pass_name(RenderPass *rpass, int chan) { @@ -1429,10 +1445,10 @@ static void threaded_tile_processor(Render *re) } if(rr->exrhandle) { + save_empty_result_tiles(re); IMB_exr_close(rr->exrhandle); rr->exrhandle= NULL; - if(!re->test_break()) - read_render_result(re); + read_render_result(re); } /* unset threadsafety */