Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/render_result.c
| Show All 28 Lines | |||||
| * \ingroup render | * \ingroup render | ||||
| */ | */ | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <errno.h> | #include <errno.h> | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_hash_md5.h" | #include "BLI_hash_md5.h" | ||||
| #include "BLI_path_util.h" | #include "BLI_path_util.h" | ||||
| #include "BLI_rect.h" | #include "BLI_rect.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| Show All 12 Lines | |||||
| #include "intern/openexr/openexr_multi.h" | #include "intern/openexr/openexr_multi.h" | ||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "render_result.h" | #include "render_result.h" | ||||
| #include "render_types.h" | #include "render_types.h" | ||||
| static CLG_LogRef LOG = {"render.result"}; | |||||
| /********************************** Free *************************************/ | /********************************** Free *************************************/ | ||||
| static void render_result_views_free(RenderResult *res) | static void render_result_views_free(RenderResult *res) | ||||
| { | { | ||||
| while (res->views.first) { | while (res->views.first) { | ||||
| RenderView *rv = res->views.first; | RenderView *rv = res->views.first; | ||||
| BLI_remlink(&res->views, rv); | BLI_remlink(&res->views, rv); | ||||
| ▲ Show 20 Lines • Show All 876 Lines • ▼ Show 20 Lines | |||||
| void render_result_single_layer_end(Render *re) | void render_result_single_layer_end(Render *re) | ||||
| { | { | ||||
| ViewLayer *view_layer; | ViewLayer *view_layer; | ||||
| RenderLayer *rlpush; | RenderLayer *rlpush; | ||||
| RenderLayer *rl; | RenderLayer *rl; | ||||
| int nr; | int nr; | ||||
| if (re->result == NULL) { | if (re->result == NULL) { | ||||
| printf("pop render result error; no current result!\n"); | CLOG_ERROR(&LOG, "pop render result error; no current result!"); | ||||
| return; | return; | ||||
| } | } | ||||
| if (!re->pushedresult) | if (!re->pushedresult) | ||||
| return; | return; | ||||
| if (re->pushedresult->rectx == re->result->rectx && re->pushedresult->recty == re->result->recty) { | if (re->pushedresult->rectx == re->result->rectx && re->pushedresult->recty == re->result->recty) { | ||||
| /* find which layer in re->pushedresult should be replaced */ | /* find which layer in re->pushedresult should be replaced */ | ||||
| ▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | void render_result_exr_file_begin(Render *re, RenderEngine *engine) | ||||
| RenderLayer *rl; | RenderLayer *rl; | ||||
| char str[FILE_MAX]; | char str[FILE_MAX]; | ||||
| for (rr = re->result; rr; rr = rr->next) { | for (rr = re->result; rr; rr = rr->next) { | ||||
| for (rl = rr->layers.first; rl; rl = rl->next) { | for (rl = rr->layers.first; rl; rl = rl->next) { | ||||
| render_result_create_all_passes(engine, re, rl); | render_result_create_all_passes(engine, re, rl); | ||||
| render_result_exr_file_path(re->scene, rl->name, rr->sample_nr, str); | render_result_exr_file_path(re->scene, rl->name, rr->sample_nr, str); | ||||
| printf("write exr tmp file, %dx%d, %s\n", rr->rectx, rr->recty, str); | CLOG_INFO(&LOG, 1, "write exr tmp file, %dx%d, %s", rr->rectx, rr->recty, str); | ||||
| IMB_exrtile_begin_write(rl->exrhandle, str, 0, rr->rectx, rr->recty, re->partx, re->party); | IMB_exrtile_begin_write(rl->exrhandle, str, 0, rr->rectx, rr->recty, re->partx, re->party); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* end write of exr tile file, read back first sample */ | /* end write of exr tile file, read back first sample */ | ||||
| void render_result_exr_file_end(Render *re, RenderEngine *engine) | void render_result_exr_file_end(Render *re, RenderEngine *engine) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | int render_result_exr_file_read_sample(Render *re, int sample, RenderEngine *engine) | ||||
| RE_FreeRenderResult(re->result); | RE_FreeRenderResult(re->result); | ||||
| re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS); | re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS); | ||||
| for (rl = re->result->layers.first; rl; rl = rl->next) { | for (rl = re->result->layers.first; rl; rl = rl->next) { | ||||
| render_result_create_all_passes(engine, re, rl); | render_result_create_all_passes(engine, re, rl); | ||||
| render_result_exr_file_path(re->scene, rl->name, sample, str); | render_result_exr_file_path(re->scene, rl->name, sample, str); | ||||
| printf("read exr tmp file: %s\n", str); | CLOG_INFO(&LOG, 1, "read exr tmp file: %s", str); | ||||
| if (!render_result_exr_file_read_path(re->result, rl, str)) { | if (!render_result_exr_file_read_path(re->result, rl, str)) { | ||||
| printf("cannot read: %s\n", str); | CLOG_ERROR(&LOG, "cannot read: %s", str); | ||||
| success = false; | success = false; | ||||
| } | } | ||||
| } | } | ||||
| return success; | return success; | ||||
| } | } | ||||
| /* called for reading temp files, and for external engines */ | /* called for reading temp files, and for external engines */ | ||||
| int render_result_exr_file_read_path(RenderResult *rr, RenderLayer *rl_single, const char *filepath) | int render_result_exr_file_read_path(RenderResult *rr, RenderLayer *rl_single, const char *filepath) | ||||
| { | { | ||||
| RenderLayer *rl; | RenderLayer *rl; | ||||
| RenderPass *rpass; | RenderPass *rpass; | ||||
| void *exrhandle = IMB_exr_get_handle(); | void *exrhandle = IMB_exr_get_handle(); | ||||
| int rectx, recty; | int rectx, recty; | ||||
| if (IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty) == 0) { | if (IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty) == 0) { | ||||
| printf("failed being read %s\n", filepath); | CLOG_ERROR(&LOG, "failed begin read %s", filepath); | ||||
| IMB_exr_close(exrhandle); | IMB_exr_close(exrhandle); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| if (rr == NULL || rectx != rr->rectx || recty != rr->recty) { | if (rr == NULL || rectx != rr->rectx || recty != rr->recty) { | ||||
| if (rr) | CLOG_ERROR(&LOG, "error in reading render result: %s", | ||||
| printf("error in reading render result: dimensions don't match\n"); | rr ? "dimensions don't match" : "NULL result pointer"); | ||||
| else | |||||
| printf("error in reading render result: NULL result pointer\n"); | |||||
| IMB_exr_close(exrhandle); | IMB_exr_close(exrhandle); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| for (rl = rr->layers.first; rl; rl = rl->next) { | for (rl = rr->layers.first; rl; rl = rl->next) { | ||||
| if (rl_single && rl_single != rl) | if (rl_single && rl_single != rl) | ||||
| continue; | continue; | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| void render_result_exr_file_cache_write(Render *re) | void render_result_exr_file_cache_write(Render *re) | ||||
| { | { | ||||
| RenderResult *rr = re->result; | RenderResult *rr = re->result; | ||||
| char str[FILE_MAXFILE + FILE_MAXFILE + MAX_ID_NAME + 100]; | char str[FILE_MAXFILE + FILE_MAXFILE + MAX_ID_NAME + 100]; | ||||
| char *root = U.render_cachedir; | char *root = U.render_cachedir; | ||||
| render_result_exr_file_cache_path(re->scene, root, str); | render_result_exr_file_cache_path(re->scene, root, str); | ||||
| printf("Caching exr file, %dx%d, %s\n", rr->rectx, rr->recty, str); | CLOG_INFO(&LOG, 1, "Caching exr file, %dx%d, %s", rr->rectx, rr->recty, str); | ||||
| RE_WriteRenderResult(NULL, rr, str, NULL, NULL, -1); | RE_WriteRenderResult(NULL, rr, str, NULL, NULL, -1); | ||||
| } | } | ||||
| /* For cache, makes exact copy of render result */ | /* For cache, makes exact copy of render result */ | ||||
| bool render_result_exr_file_cache_read(Render *re) | bool render_result_exr_file_cache_read(Render *re) | ||||
| { | { | ||||
| char str[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100] = ""; | char str[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100] = ""; | ||||
| char *root = U.render_cachedir; | char *root = U.render_cachedir; | ||||
| RE_FreeRenderResult(re->result); | RE_FreeRenderResult(re->result); | ||||
| re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS); | re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS); | ||||
| /* First try cache. */ | /* First try cache. */ | ||||
| render_result_exr_file_cache_path(re->scene, root, str); | render_result_exr_file_cache_path(re->scene, root, str); | ||||
| printf("read exr cache file: %s\n", str); | CLOG_INFO(&LOG, 1, "read exr cache file: %s", str); | ||||
| if (!render_result_exr_file_read_path(re->result, NULL, str)) { | if (!render_result_exr_file_read_path(re->result, NULL, str)) { | ||||
| printf("cannot read: %s\n", str); | CLOG_ERROR(&LOG, "cannot read: %s", str); | ||||
| return false; | return false; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| /*************************** Combined Pixel Rect *****************************/ | /*************************** Combined Pixel Rect *****************************/ | ||||
| ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd, const int view_id) | ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd, const int view_id) | ||||
| ▲ Show 20 Lines • Show All 232 Lines • Show Last 20 Lines | |||||