Merge branch 'blender2.7'
[blender.git] / source / blender / render / intern / source / render_result.c
index 7efe0a5..9ec7054 100644 (file)
@@ -57,6 +57,8 @@
 
 #include "intern/openexr/openexr_multi.h"
 
+#include "RE_engine.h"
+
 #include "render_result.h"
 #include "render_types.h"
 
@@ -482,6 +484,7 @@ void render_result_add_pass(RenderResult *rr, const char *name, int channels, co
                        for (rp = rl->passes.first; rp; rp = rp->next) {
                                if (!STREQ(rp->name, name)) continue;
                                if (!STREQ(rp->view, view)) continue;
+                               break;
                        }
 
                        if (!rp) {
@@ -1063,8 +1066,25 @@ void render_result_save_empty_result_tiles(Render *re)
        }
 }
 
+static void render_result_register_pass_cb(RenderEngine *engine, Scene *UNUSED(scene), ViewLayer *view_layer,
+                                           const char *name, int channels, const char *chanid, int UNUSED(type))
+{
+       RE_engine_add_pass(engine, name, channels, chanid, view_layer->name);
+}
+
+static void render_result_create_all_passes(RenderEngine *engine, Render *re, RenderLayer *rl)
+{
+       if (engine && engine->type->update_render_passes) {
+               ViewLayer *view_layer;
+               view_layer = BLI_findstring(&re->view_layers, rl->name, offsetof(ViewLayer, name));
+               if (view_layer) {
+                       RE_engine_update_render_passes(engine, re->scene, view_layer, render_result_register_pass_cb);
+               }
+       }
+}
+
 /* begin write of exr tile file */
-void render_result_exr_file_begin(Render *re)
+void render_result_exr_file_begin(Render *re, RenderEngine *engine)
 {
        RenderResult *rr;
        RenderLayer *rl;
@@ -1072,6 +1092,8 @@ void render_result_exr_file_begin(Render *re)
 
        for (rr = re->result; rr; rr = rr->next) {
                for (rl = rr->layers.first; rl; rl = rl->next) {
+                       render_result_create_all_passes(engine, re, rl);
+
                        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);
                        IMB_exrtile_begin_write(rl->exrhandle, str, 0, rr->rectx, rr->recty, re->partx, re->party);
@@ -1080,7 +1102,7 @@ void render_result_exr_file_begin(Render *re)
 }
 
 /* end write of exr tile file, read back first sample */
-void render_result_exr_file_end(Render *re)
+void render_result_exr_file_end(Render *re, RenderEngine *engine)
 {
        RenderResult *rr;
        RenderLayer *rl;
@@ -1097,7 +1119,7 @@ void render_result_exr_file_end(Render *re)
        render_result_free_list(&re->fullresult, re->result);
        re->result = NULL;
 
-       render_result_exr_file_read_sample(re, 0);
+       render_result_exr_file_read_sample(re, 0, engine);
 }
 
 /* save part into exr file */
@@ -1127,7 +1149,7 @@ void render_result_exr_file_path(Scene *scene, const char *layname, int sample,
 }
 
 /* only for temp buffer, makes exact copy of render result */
-int render_result_exr_file_read_sample(Render *re, int sample)
+int render_result_exr_file_read_sample(Render *re, int sample, RenderEngine *engine)
 {
        RenderLayer *rl;
        char str[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100] = "";
@@ -1137,6 +1159,8 @@ int render_result_exr_file_read_sample(Render *re, int sample)
        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) {
+               render_result_create_all_passes(engine, re, rl);
+
                render_result_exr_file_path(re->scene, rl->name, sample, str);
                printf("read exr tmp file: %s\n", str);