void BLI_task_pool_free(TaskPool *pool) { BLI_task_pool_stop(pool); BLI_mutex_end(&pool->num_mutex); BLI_condition_end(&pool->num_cond); BLI_mutex_end(&pool->user_mutex); /* Free local memory pool, those pointers are lost forever. */ if (pool->task_mempool == &pool->task_mempool_local) { for (int i = 0; i < pool->task_mempool_local.num_tasks; i++) { MEM_freeN(pool->task_mempool_local.tasks[i]); } } #ifdef DEBUG_STATS printf("Thread ID Allocated Reused Discarded\n"); for (int i = 0; i < pool->scheduler->num_threads + 1; ++i) { printf("%02d %05d %05d %05d\n", i, pool->mempool_stats[i].num_alloc, pool->mempool_stats[i].num_reuse, pool->mempool_stats[i].num_discard); } MEM_freeN(pool->mempool_stats); #endif MEM_freeN(pool); BLI_end_threaded_malloc(); }
/* executes blocking render */ static int screen_render_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); SceneRenderLayer *srl = NULL; Render *re; Image *ima; View3D *v3d = CTX_wm_view3d(C); Main *mainp = CTX_data_main(C); unsigned int lay_override; const bool is_animation = RNA_boolean_get(op->ptr, "animation"); const bool is_write_still = RNA_boolean_get(op->ptr, "write_still"); struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; /* custom scene and single layer re-render */ screen_render_scene_layer_set(op, mainp, &scene, &srl); if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); return OPERATOR_CANCELLED; } re = RE_NewRender(scene->id.name); lay_override = (v3d && v3d->lay != scene->lay) ? v3d->lay : 0; G.is_break = false; RE_test_break_cb(re, NULL, render_break); ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE); BKE_image_backup_render(scene, ima); /* cleanup sequencer caches before starting user triggered render. * otherwise, invalidated cache entries can make their way into * the output rendering. We can't put that into RE_BlenderFrame, * since sequence rendering can call that recursively... (peter) */ BKE_sequencer_cache_cleanup(); RE_SetReports(re, op->reports); BLI_begin_threaded_malloc(); if (is_animation) RE_BlenderAnim(re, mainp, scene, camera_override, lay_override, scene->r.sfra, scene->r.efra, scene->r.frame_step); else RE_BlenderFrame(re, mainp, scene, srl, camera_override, lay_override, scene->r.cfra, is_write_still); BLI_end_threaded_malloc(); RE_SetReports(re, NULL); // no redraw needed, we leave state as we entered it ED_update_for_newframe(mainp, scene, 1); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); return OPERATOR_FINISHED; }
void BLI_task_pool_free(TaskPool *pool) { BLI_task_pool_stop(pool); BLI_mutex_end(&pool->num_mutex); BLI_condition_end(&pool->num_cond); BLI_mutex_end(&pool->user_mutex); MEM_freeN(pool); BLI_end_threaded_malloc(); }
void RE_engine_free(RenderEngine *engine) { #ifdef WITH_PYTHON if (engine->py_instance) { BPY_DECREF_RNA_INVALIDATE(engine->py_instance); } #endif if (engine->flag & RE_ENGINE_USED_FOR_VIEWPORT) { BLI_end_threaded_malloc(); } MEM_freeN(engine); }
static int render_frame(int argc, const char **argv, void *data) { bContext *C = data; Scene *scene = CTX_data_scene(C); if (scene) { Main *bmain = CTX_data_main(C); if (argc > 1) { Render *re = RE_NewRender(scene->id.name); int frame; ReportList reports; switch (*argv[1]) { case '+': frame = scene->r.sfra + atoi(argv[1] + 1); break; case '-': frame = (scene->r.efra - atoi(argv[1] + 1)) + 1; break; default: frame = atoi(argv[1]); break; } BLI_begin_threaded_malloc(); BKE_reports_init(&reports, RPT_PRINT); frame = CLAMPIS(frame, MINAFRAME, MAXFRAME); RE_SetReports(re, &reports); RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step); RE_SetReports(re, NULL); BLI_end_threaded_malloc(); return 1; } else { printf("\nError: frame number must follow '-f / --render-frame'.\n"); return 0; } } else { printf("\nError: no blend loaded. cannot use '-f / --render-frame'.\n"); return 0; } }
static int render_animation(int UNUSED(argc), const char **UNUSED(argv), void *data) { bContext *C = data; Scene *scene = CTX_data_scene(C); if (scene) { Main *bmain = CTX_data_main(C); Render *re = RE_NewRender(scene->id.name); ReportList reports; BLI_begin_threaded_malloc(); BKE_reports_init(&reports, RPT_PRINT); RE_SetReports(re, &reports); RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step); RE_SetReports(re, NULL); BLI_end_threaded_malloc(); } else { printf("\nError: no blend loaded. cannot use '-a'.\n"); } return 0; }