Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/render_result.c
| Show All 15 Lines | |||||
| * The Original Code is Copyright (C) 2006 Blender Foundation. | * The Original Code is Copyright (C) 2006 Blender Foundation. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| */ | */ | ||||
| /** \file | /** \file | ||||
| * \ingroup render | * \ingroup render | ||||
| */ | */ | ||||
| #include <CLG_log.h> | |||||
| #include <errno.h> | #include <errno.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| Show All 19 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.results"}; | |||||
| /********************************** 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 1,000 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 && | if (re->pushedresult->rectx == re->result->rectx && | ||||
| ▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (RenderLayer *, rl, &rr->layers) { | ||||
| re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL); | re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL); | ||||
| } | } | ||||
| BLI_rw_mutex_unlock(&re->resultmutex); | BLI_rw_mutex_unlock(&re->resultmutex); | ||||
| BLI_freelistN(&templates); | BLI_freelistN(&templates); | ||||
| /* Open EXR file for writing. */ | /* Open EXR file for writing. */ | ||||
| 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, "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 All 25 Lines | LISTBASE_FOREACH (RenderPass *, pass, &templates) { | ||||
| RE_create_render_pass(re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL); | RE_create_render_pass(re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL); | ||||
| } | } | ||||
| BLI_freelistN(&templates); | BLI_freelistN(&templates); | ||||
| /* Render passes contents from file. */ | /* Render passes contents from file. */ | ||||
| char str[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100] = ""; | char str[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100] = ""; | ||||
| render_result_exr_file_path(re->scene, rl->name, 0, str); | render_result_exr_file_path(re->scene, rl->name, 0, str); | ||||
| printf("read exr tmp file: %s\n", str); | CLOG_INFO(&LOG, "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); | ||||
| } | } | ||||
| BLI_rw_mutex_unlock(&re->resultmutex); | BLI_rw_mutex_unlock(&re->resultmutex); | ||||
| } | } | ||||
| } | } | ||||
| /* save part into exr file */ | /* save part into exr file */ | ||||
| void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart, const char *viewname) | void render_result_exr_file_merge(RenderResult *rr, RenderResult *rrpart, const char *viewname) | ||||
| { | { | ||||
| Show All 27 Lines | int render_result_exr_file_read_path(RenderResult *rr, | ||||
| const char *filepath) | 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 being 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) { | if (rr) { | ||||
| printf("error in reading render result: dimensions don't match\n"); | CLOG_STR_ERROR(&LOG, "error in reading render result: dimensions don't match"); | ||||
| } | } | ||||
| else { | else { | ||||
| printf("error in reading render result: NULL result pointer\n"); | CLOG_STR_ERROR(&LOG, "error in reading render result: NULL result pointer"); | ||||
| } | } | ||||
| 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 56 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, "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, "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, const RenderData *rd, const int view_id) | ImBuf *render_result_rect_to_ibuf(RenderResult *rr, const RenderData *rd, const int view_id) | ||||
| ▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines | |||||