Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/pipeline.c
| Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | |||||
| * 4) Composite Render Result | * 4) Composite Render Result | ||||
| * - also read external files etc | * - also read external files etc | ||||
| * | * | ||||
| * 5) Image Files | * 5) Image Files | ||||
| * - save file or append in movie | * - save file or append in movie | ||||
| * | * | ||||
| */ | */ | ||||
| /* Freestyle needs the whole frame to be merged into memory prior to | |||||
| * doing stroke rendering. This conflicts a bit with multiview save | |||||
| * buffers behavior which does a merge of exr files after all the | |||||
| * views are rendered. | |||||
| * | |||||
| * For until a proper solution is implemented we'll just merge single | |||||
| * view image prior to freestyle stroke rendering, which is how this | |||||
| * worked prior to multiview. Multiview+freestyle+save buffers are | |||||
| * considered unsupported for the time being. | |||||
| */ | |||||
| #define FREESTYLR_SAVEBUFFERS_WORKAROUND | |||||
| /* ********* globals ******** */ | /* ********* globals ******** */ | ||||
| /* here we store all renders */ | /* here we store all renders */ | ||||
| static struct { | static struct { | ||||
| ListBase renderlist; | ListBase renderlist; | ||||
| } RenderGlobal = {{NULL, NULL}}; | } RenderGlobal = {{NULL, NULL}}; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | static void stats_background(void *UNUSED(arg), RenderStats *rs) | ||||
| else { | else { | ||||
| if (rs->tothalo) | if (rs->tothalo) | ||||
| fprintf(stdout, IFACE_("Sce: %s Ve:%d Fa:%d Ha:%d La:%d"), | fprintf(stdout, IFACE_("Sce: %s Ve:%d Fa:%d Ha:%d La:%d"), | ||||
| rs->scene_name, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); | rs->scene_name, rs->totvert, rs->totface, rs->tothalo, rs->totlamp); | ||||
| else | else | ||||
| fprintf(stdout, IFACE_("Sce: %s Ve:%d Fa:%d La:%d"), rs->scene_name, rs->totvert, rs->totface, rs->totlamp); | fprintf(stdout, IFACE_("Sce: %s Ve:%d Fa:%d La:%d"), rs->scene_name, rs->totvert, rs->totface, rs->totlamp); | ||||
| } | } | ||||
| /* Flush stdout to be sure python callbacks are printing stuff after blender. */ | |||||
| fflush(stdout); | |||||
| BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); | BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); | ||||
| fputc('\n', stdout); | fputc('\n', stdout); | ||||
| fflush(stdout); | fflush(stdout); | ||||
| } | } | ||||
| void RE_FreeRenderResult(RenderResult *res) | void RE_FreeRenderResult(RenderResult *res) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | if (re->result) { | ||||
| rr->rectx = re->result->rectx; | rr->rectx = re->result->rectx; | ||||
| rr->recty = re->result->recty; | rr->recty = re->result->recty; | ||||
| /* creates a temporary duplication of views */ | /* creates a temporary duplication of views */ | ||||
| render_result_views_shallowcopy(rr, re->result); | render_result_views_shallowcopy(rr, re->result); | ||||
| rv = rr->views.first; | rv = rr->views.first; | ||||
| rr->have_combined = (rv->rectf != NULL); | |||||
| /* active layer */ | /* active layer */ | ||||
| rl = render_get_active_layer(re, re->result); | rl = render_get_active_layer(re, re->result); | ||||
| if (rl) { | if (rl) { | ||||
| if (rv->rectf == NULL) { | if (rv->rectf == NULL) { | ||||
| for (rview = (RenderView *)rr->views.first; rview; rview = rview->next) { | for (rview = (RenderView *)rr->views.first; rview; rview = rview->next) { | ||||
| rview->rectf = RE_RenderLayerGetPass(rl, SCE_PASS_COMBINED, rview->name); | rview->rectf = RE_RenderLayerGetPass(rl, SCE_PASS_COMBINED, rview->name); | ||||
| } | } | ||||
| } | } | ||||
| if (rv->rectz == NULL) { | if (rv->rectz == NULL) { | ||||
| for (rview = (RenderView *)rr->views.first; rview; rview = rview->next) { | for (rview = (RenderView *)rr->views.first; rview; rview = rview->next) { | ||||
| rview->rectz = RE_RenderLayerGetPass(rl, SCE_PASS_Z, rview->name); | rview->rectz = RE_RenderLayerGetPass(rl, SCE_PASS_Z, rview->name); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| rr->have_combined = (rv->rectf != NULL); | |||||
| rr->layers = re->result->layers; | rr->layers = re->result->layers; | ||||
| rr->xof = re->disprect.xmin; | rr->xof = re->disprect.xmin; | ||||
| rr->yof = re->disprect.ymin; | rr->yof = re->disprect.ymin; | ||||
| rr->stamp_data = re->result->stamp_data; | rr->stamp_data = re->result->stamp_data; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,017 Lines • ▼ Show 20 Lines | while ((pa = BLI_thread_queue_pop(donequeue))) { | ||||
| render_result_free_list(&pa->fullresult, pa->result); | render_result_free_list(&pa->fullresult, pa->result); | ||||
| pa->result = NULL; | pa->result = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| BLI_thread_queue_free(donequeue); | BLI_thread_queue_free(donequeue); | ||||
| BLI_thread_queue_free(workqueue); | BLI_thread_queue_free(workqueue); | ||||
| if (re->result->do_exr_tile) { | |||||
| BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); | |||||
| render_result_save_empty_result_tiles(re); | |||||
| BLI_rw_mutex_unlock(&re->resultmutex); | |||||
| } | |||||
| /* unset threadsafety */ | /* unset threadsafety */ | ||||
| g_break = 0; | g_break = 0; | ||||
| BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_WRITE); | BLI_rw_mutex_lock(&re->partsmutex, THREAD_LOCK_WRITE); | ||||
| RE_parts_free(re); | RE_parts_free(re); | ||||
| BLI_rw_mutex_unlock(&re->partsmutex); | BLI_rw_mutex_unlock(&re->partsmutex); | ||||
| re->viewplane = viewplane; /* restore viewplane, modified by pano render */ | re->viewplane = viewplane; /* restore viewplane, modified by pano render */ | ||||
| } | } | ||||
| Show All 27 Lines | |||||
| #endif | #endif | ||||
| } | } | ||||
| /* ************ This part uses API, for rendering Blender scenes ********** */ | /* ************ This part uses API, for rendering Blender scenes ********** */ | ||||
| static void do_render_3d(Render *re) | static void do_render_3d(Render *re) | ||||
| { | { | ||||
| #ifdef FREESTYLR_SAVEBUFFERS_WORKAROUND | |||||
| const bool do_early_result_merge = (re->r.scemode & R_MULTIVIEW) == 0; | |||||
| #endif | |||||
| RenderView *rv; | RenderView *rv; | ||||
| int cfra_backup; | int cfra_backup; | ||||
| re->current_scene_update(re->suh, re->scene); | re->current_scene_update(re->suh, re->scene); | ||||
| /* try external */ | /* try external */ | ||||
| if (RE_engine_render(re, 0)) | if (RE_engine_render(re, 0)) | ||||
| return; | return; | ||||
| Show All 31 Lines | else { | ||||
| RE_Database_Preprocess(re); | RE_Database_Preprocess(re); | ||||
| } | } | ||||
| /* clear UI drawing locks */ | /* clear UI drawing locks */ | ||||
| if (re->draw_lock) | if (re->draw_lock) | ||||
| re->draw_lock(re->dlh, 0); | re->draw_lock(re->dlh, 0); | ||||
| threaded_tile_processor(re); | threaded_tile_processor(re); | ||||
| #ifdef FREESTYLR_SAVEBUFFERS_WORKAROUND | |||||
| if (do_early_result_merge) { | |||||
| main_render_result_end(re); | |||||
| } | |||||
| #endif | |||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| /* Freestyle */ | /* Freestyle */ | ||||
| if (re->r.mode & R_EDGE_FRS) | if (re->r.mode & R_EDGE_FRS) | ||||
| if (!re->test_break(re->tbh)) | if (!re->test_break(re->tbh)) | ||||
| add_freestyle(re, 1); | add_freestyle(re, 1); | ||||
| #endif | #endif | ||||
| /* do left-over 3d post effects (flares) */ | /* do left-over 3d post effects (flares) */ | ||||
| if (re->flag & R_HALO) | if (re->flag & R_HALO) | ||||
| if (!re->test_break(re->tbh)) | if (!re->test_break(re->tbh)) | ||||
| add_halo_flare(re); | add_halo_flare(re); | ||||
| /* free all render verts etc */ | /* free all render verts etc */ | ||||
| RE_Database_Free(re); | RE_Database_Free(re); | ||||
| } | } | ||||
| #ifdef FREESTYLR_SAVEBUFFERS_WORKAROUND | |||||
| if (!do_early_result_merge) { | |||||
| main_render_result_end(re); | main_render_result_end(re); | ||||
| } | |||||
| #else | |||||
| main_render_result_end(re); | |||||
| #endif | |||||
| re->scene->r.cfra = cfra_backup; | re->scene->r.cfra = cfra_backup; | ||||
| re->scene->r.subframe = 0.f; | re->scene->r.subframe = 0.f; | ||||
| } | } | ||||
| /* called by blur loop, accumulate RGBA key alpha */ | /* called by blur loop, accumulate RGBA key alpha */ | ||||
| static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, float blurfac) | static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, float blurfac) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 980 Lines • ▼ Show 20 Lines | if (ntree && re->scene->use_nodes && re->r.scemode & R_DOCOMP) { | ||||
| ntree->progress = re->progress; | ntree->progress = re->progress; | ||||
| ntree->sdh = re->sdh; | ntree->sdh = re->sdh; | ||||
| ntree->tbh = re->tbh; | ntree->tbh = re->tbh; | ||||
| ntree->prh = re->prh; | ntree->prh = re->prh; | ||||
| /* in case it was never initialized */ | /* in case it was never initialized */ | ||||
| R.sdh = re->sdh; | R.sdh = re->sdh; | ||||
| R.stats_draw = re->stats_draw; | R.stats_draw = re->stats_draw; | ||||
| R.i.starttime = re->i.starttime; | |||||
| R.i.cfra = re->i.cfra; | |||||
| if (update_newframe) | if (update_newframe) | ||||
| BKE_scene_update_for_newframe(re->eval_ctx, re->main, re->scene, re->lay); | BKE_scene_update_for_newframe(re->eval_ctx, re->main, re->scene, re->lay); | ||||
| if (re->r.scemode & R_FULL_SAMPLE) | if (re->r.scemode & R_FULL_SAMPLE) | ||||
| do_merge_fullsample(re, ntree); | do_merge_fullsample(re, ntree); | ||||
| else { | else { | ||||
| RenderView *rv; | RenderView *rv; | ||||
| ▲ Show 20 Lines • Show All 426 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| if (scene->r.mode & R_EDGE_FRS) { | if (scene->r.mode & R_EDGE_FRS) { | ||||
| if (scene->r.mode & R_FIELDS) { | if (scene->r.mode & R_FIELDS) { | ||||
| BKE_report(reports, RPT_ERROR, "Fields not supported in Freestyle"); | BKE_report(reports, RPT_ERROR, "Fields not supported in Freestyle"); | ||||
| return false; | return false; | ||||
| } | } | ||||
| # ifdef FREESTYLR_SAVEBUFFERS_WORKAROUND | |||||
| if ((scene->r.scemode & R_MULTIVIEW) != 0 && (scene->r.scemode & R_EXR_TILE_FILE) != 0) { | |||||
| BKE_report(reports, RPT_ERROR, "Multiview combined with Save Buffers not supported in Freestyle"); | |||||
| return false; | |||||
| } | |||||
| # endif | |||||
| } | } | ||||
| #endif | #endif | ||||
| /* layer flag tests */ | /* layer flag tests */ | ||||
| if (!render_scene_has_layers_to_render(scene)) { | if (!render_scene_has_layers_to_render(scene)) { | ||||
| BKE_report(reports, RPT_ERROR, "All render layers are disabled"); | BKE_report(reports, RPT_ERROR, "All render layers are disabled"); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 458 Lines • ▼ Show 20 Lines | static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovieHandle *mh, const size_t totvideos, const char *name_override) | ||||
| RE_ReleaseResultImageViews(re, &rres); | RE_ReleaseResultImageViews(re, &rres); | ||||
| render_time = re->i.lastframetime; | render_time = re->i.lastframetime; | ||||
| re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime; | re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime; | ||||
| BLI_timestr(re->i.lastframetime, name, sizeof(name)); | BLI_timestr(re->i.lastframetime, name, sizeof(name)); | ||||
| printf(" Time: %s", name); | printf(" Time: %s", name); | ||||
| /* Flush stdout to be sure python callbacks are printing stuff after blender. */ | |||||
| fflush(stdout); | |||||
| BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); | BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); | ||||
| BLI_timestr(re->i.lastframetime - render_time, name, sizeof(name)); | BLI_timestr(re->i.lastframetime - render_time, name, sizeof(name)); | ||||
| printf(" (Saving: %s)\n", name); | printf(" (Saving: %s)\n", name); | ||||
| fputc('\n', stdout); | fputc('\n', stdout); | ||||
| fflush(stdout); /* needed for renderd !! (not anymore... (ton)) */ | fflush(stdout); /* needed for renderd !! (not anymore... (ton)) */ | ||||
| ▲ Show 20 Lines • Show All 511 Lines • Show Last 20 Lines | |||||