forked from bartvdbraak/blender
Render API: add self.report() function for RenderEngine, for reporting warnings and errors.
This commit is contained in:
parent
8da594c861
commit
0a1223c87e
@ -446,11 +446,15 @@ static int screen_render_exec(bContext *C, wmOperator *op)
|
|||||||
since sequence rendering can call that recursively... (peter) */
|
since sequence rendering can call that recursively... (peter) */
|
||||||
seq_stripelem_cache_cleanup();
|
seq_stripelem_cache_cleanup();
|
||||||
|
|
||||||
|
RE_SetReports(re, op->reports);
|
||||||
|
|
||||||
if(is_animation)
|
if(is_animation)
|
||||||
RE_BlenderAnim(re, mainp, scene, camera_override, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports);
|
RE_BlenderAnim(re, mainp, scene, camera_override, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step);
|
||||||
else
|
else
|
||||||
RE_BlenderFrame(re, mainp, scene, NULL, camera_override, lay, scene->r.cfra, is_write_still);
|
RE_BlenderFrame(re, mainp, scene, NULL, camera_override, lay, scene->r.cfra, is_write_still);
|
||||||
|
|
||||||
|
RE_SetReports(re, NULL);
|
||||||
|
|
||||||
// no redraw needed, we leave state as we entered it
|
// no redraw needed, we leave state as we entered it
|
||||||
ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1);
|
ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1);
|
||||||
|
|
||||||
@ -591,10 +595,14 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro
|
|||||||
rj->do_update= do_update;
|
rj->do_update= do_update;
|
||||||
rj->progress= progress;
|
rj->progress= progress;
|
||||||
|
|
||||||
|
RE_SetReports(rj->re, rj->reports);
|
||||||
|
|
||||||
if(rj->anim)
|
if(rj->anim)
|
||||||
RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->camera_override, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports);
|
RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->camera_override, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step);
|
||||||
else
|
else
|
||||||
RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->camera_override, rj->lay, rj->scene->r.cfra, rj->write_still);
|
RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->camera_override, rj->lay, rj->scene->r.cfra, rj->write_still);
|
||||||
|
|
||||||
|
RE_SetReports(rj->re, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void render_endjob(void *rjv)
|
static void render_endjob(void *rjv)
|
||||||
|
@ -43,6 +43,8 @@
|
|||||||
#include "DNA_view3d_types.h"
|
#include "DNA_view3d_types.h"
|
||||||
#include "DNA_world_types.h"
|
#include "DNA_world_types.h"
|
||||||
|
|
||||||
|
#include "BLI_utildefines.h"
|
||||||
|
|
||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
#include "BKE_depsgraph.h"
|
#include "BKE_depsgraph.h"
|
||||||
#include "BKE_icons.h"
|
#include "BKE_icons.h"
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "DNA_scene_types.h"
|
#include "DNA_scene_types.h"
|
||||||
|
|
||||||
#include "RNA_define.h"
|
#include "RNA_define.h"
|
||||||
|
#include "RNA_enum_types.h"
|
||||||
|
|
||||||
#include "rna_internal.h"
|
#include "rna_internal.h"
|
||||||
|
|
||||||
@ -373,6 +374,12 @@ static void rna_def_render_engine(BlenderRNA *brna)
|
|||||||
prop= RNA_def_string(func, "info", "", 0, "Info", "");
|
prop= RNA_def_string(func, "info", "", 0, "Info", "");
|
||||||
RNA_def_property_flag(prop, PROP_REQUIRED);
|
RNA_def_property_flag(prop, PROP_REQUIRED);
|
||||||
|
|
||||||
|
func= RNA_def_function(srna, "report", "RE_engine_report");
|
||||||
|
prop= RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", "");
|
||||||
|
RNA_def_property_flag(prop, PROP_REQUIRED);
|
||||||
|
prop= RNA_def_string(func, "message", "", 0, "Report Message", "");
|
||||||
|
RNA_def_property_flag(prop, PROP_REQUIRED);
|
||||||
|
|
||||||
/* registration */
|
/* registration */
|
||||||
RNA_define_verify_sdna(0);
|
RNA_define_verify_sdna(0);
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ LIBEXPORT void RE_engine_end_result(RenderEngine *engine, struct RenderResult *r
|
|||||||
|
|
||||||
LIBEXPORT int RE_engine_test_break(RenderEngine *engine);
|
LIBEXPORT int RE_engine_test_break(RenderEngine *engine);
|
||||||
LIBEXPORT void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
|
LIBEXPORT void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char *info);
|
||||||
|
LIBEXPORT void RE_engine_report(RenderEngine *engine, int type, const char *msg);
|
||||||
|
|
||||||
int RE_engine_render(struct Render *re, int do_all);
|
int RE_engine_render(struct Render *re, int do_all);
|
||||||
|
|
||||||
|
@ -214,7 +214,10 @@ void RE_TileProcessor(struct Render *re);
|
|||||||
|
|
||||||
/* only RE_NewRender() needed, main Blender render calls */
|
/* only RE_NewRender() needed, main Blender render calls */
|
||||||
void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay, int frame, const short write_still);
|
void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay, int frame, const short write_still);
|
||||||
void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, struct Object *camera_override, unsigned int lay, int sfra, int efra, int tfra, struct ReportList *reports);
|
void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, struct Object *camera_override, unsigned int lay, int sfra, int efra, int tfra);
|
||||||
|
|
||||||
|
/* error reporting */
|
||||||
|
void RE_SetReports(struct Render *re, struct ReportList *reports);
|
||||||
|
|
||||||
/* main preview render call */
|
/* main preview render call */
|
||||||
void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene);
|
void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene);
|
||||||
|
@ -60,6 +60,7 @@ struct RenderBuckets;
|
|||||||
struct ObjectInstanceRen;
|
struct ObjectInstanceRen;
|
||||||
struct RayObject;
|
struct RayObject;
|
||||||
struct RayFace;
|
struct RayFace;
|
||||||
|
struct ReportList;
|
||||||
struct Main;
|
struct Main;
|
||||||
|
|
||||||
#define TABLEINITSIZE 1024
|
#define TABLEINITSIZE 1024
|
||||||
@ -256,6 +257,8 @@ struct Render
|
|||||||
void *erh;
|
void *erh;
|
||||||
|
|
||||||
RenderStats i;
|
RenderStats i;
|
||||||
|
|
||||||
|
struct ReportList *reports;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
@ -209,6 +209,11 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char
|
|||||||
re->i.statstr= NULL;
|
re->i.statstr= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RE_engine_report(RenderEngine *engine, int type, const char *msg)
|
||||||
|
{
|
||||||
|
BKE_report(engine->re->reports, type, msg);
|
||||||
|
}
|
||||||
|
|
||||||
/* Render */
|
/* Render */
|
||||||
|
|
||||||
int RE_engine_render(Render *re, int do_all)
|
int RE_engine_render(Render *re, int do_all)
|
||||||
|
@ -128,7 +128,7 @@ Render R;
|
|||||||
|
|
||||||
/* ********* alloc and free ******** */
|
/* ********* alloc and free ******** */
|
||||||
|
|
||||||
static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, ReportList *reports, const char *name_override);
|
static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const char *name_override);
|
||||||
|
|
||||||
static volatile int g_break= 0;
|
static volatile int g_break= 0;
|
||||||
static int thread_break(void *UNUSED(arg))
|
static int thread_break(void *UNUSED(arg))
|
||||||
@ -2911,6 +2911,11 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RE_SetReports(Render *re, ReportList *reports)
|
||||||
|
{
|
||||||
|
re->reports= reports;
|
||||||
|
}
|
||||||
|
|
||||||
/* general Blender frame render call */
|
/* general Blender frame render call */
|
||||||
void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, Object *camera_override, unsigned int lay, int frame, const short write_still)
|
void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, Object *camera_override, unsigned int lay, int frame, const short write_still)
|
||||||
{
|
{
|
||||||
@ -2933,7 +2938,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
|
|||||||
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
|
BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE);
|
||||||
|
|
||||||
/* reports only used for Movie */
|
/* reports only used for Movie */
|
||||||
do_write_image_or_movie(re, scene, NULL, NULL, name);
|
do_write_image_or_movie(re, scene, NULL, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2942,7 +2947,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr
|
|||||||
G.rendering= 0;
|
G.rendering= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, ReportList *reports, const char *name_override)
|
static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, const char *name_override)
|
||||||
{
|
{
|
||||||
char name[FILE_MAX];
|
char name[FILE_MAX];
|
||||||
RenderResult rres;
|
RenderResult rres;
|
||||||
@ -2960,7 +2965,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R
|
|||||||
dofree = 1;
|
dofree = 1;
|
||||||
}
|
}
|
||||||
RE_ResultGet32(re, (unsigned int *)rres.rect32);
|
RE_ResultGet32(re, (unsigned int *)rres.rect32);
|
||||||
ok= mh->append_movie(&re->r, scene->r.cfra, rres.rect32, rres.rectx, rres.recty, reports);
|
ok= mh->append_movie(&re->r, scene->r.cfra, rres.rect32, rres.rectx, rres.recty, re->reports);
|
||||||
if(dofree) {
|
if(dofree) {
|
||||||
MEM_freeN(rres.rect32);
|
MEM_freeN(rres.rect32);
|
||||||
}
|
}
|
||||||
@ -3033,7 +3038,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* saves images to disk */
|
/* saves images to disk */
|
||||||
void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra, ReportList *reports)
|
void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra)
|
||||||
{
|
{
|
||||||
bMovieHandle *mh= BKE_get_movie_handle(scene->r.imtype);
|
bMovieHandle *mh= BKE_get_movie_handle(scene->r.imtype);
|
||||||
int cfrao= scene->r.cfra;
|
int cfrao= scene->r.cfra;
|
||||||
@ -3046,21 +3051,21 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
|
|||||||
/* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */
|
/* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */
|
||||||
/* is also set by caller renderwin.c */
|
/* is also set by caller renderwin.c */
|
||||||
G.rendering= 1;
|
G.rendering= 1;
|
||||||
|
|
||||||
if(BKE_imtype_is_movie(scene->r.imtype))
|
if(BKE_imtype_is_movie(scene->r.imtype))
|
||||||
if(!mh->start_movie(scene, &re->r, re->rectx, re->recty, reports))
|
if(!mh->start_movie(scene, &re->r, re->rectx, re->recty, re->reports))
|
||||||
G.afbreek= 1;
|
G.afbreek= 1;
|
||||||
|
|
||||||
if (mh->get_next_frame) {
|
if (mh->get_next_frame) {
|
||||||
while (!(G.afbreek == 1)) {
|
while (!(G.afbreek == 1)) {
|
||||||
int nf = mh->get_next_frame(&re->r, reports);
|
int nf = mh->get_next_frame(&re->r, re->reports);
|
||||||
if (nf >= 0 && nf >= scene->r.sfra && nf <= scene->r.efra) {
|
if (nf >= 0 && nf >= scene->r.sfra && nf <= scene->r.efra) {
|
||||||
scene->r.cfra = re->r.cfra = nf;
|
scene->r.cfra = re->r.cfra = nf;
|
||||||
|
|
||||||
do_render_all_options(re);
|
do_render_all_options(re);
|
||||||
|
|
||||||
if(re->test_break(re->tbh) == 0) {
|
if(re->test_break(re->tbh) == 0) {
|
||||||
if(!do_write_image_or_movie(re, scene, mh, reports, NULL))
|
if(!do_write_image_or_movie(re, scene, mh, NULL))
|
||||||
G.afbreek= 1;
|
G.afbreek= 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -3115,7 +3120,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri
|
|||||||
|
|
||||||
if(re->test_break(re->tbh) == 0) {
|
if(re->test_break(re->tbh) == 0) {
|
||||||
if(!G.afbreek)
|
if(!G.afbreek)
|
||||||
if(!do_write_image_or_movie(re, scene, mh, reports, NULL))
|
if(!do_write_image_or_movie(re, scene, mh, NULL))
|
||||||
G.afbreek= 1;
|
G.afbreek= 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -782,7 +782,9 @@ static int render_frame(int argc, const char **argv, void *data)
|
|||||||
|
|
||||||
frame = MIN2(MAXFRAME, MAX2(MINAFRAME, frame));
|
frame = MIN2(MAXFRAME, MAX2(MINAFRAME, frame));
|
||||||
|
|
||||||
RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step, &reports);
|
RE_SetReports(re, &reports);
|
||||||
|
RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step);
|
||||||
|
RE_SetReports(re, NULL);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
printf("\nError: frame number must follow '-f / --render-frame'.\n");
|
printf("\nError: frame number must follow '-f / --render-frame'.\n");
|
||||||
@ -803,7 +805,9 @@ static int render_animation(int UNUSED(argc), const char **UNUSED(argv), void *d
|
|||||||
Render *re= RE_NewRender(scene->id.name);
|
Render *re= RE_NewRender(scene->id.name);
|
||||||
ReportList reports;
|
ReportList reports;
|
||||||
BKE_reports_init(&reports, RPT_PRINT);
|
BKE_reports_init(&reports, RPT_PRINT);
|
||||||
RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, &reports);
|
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);
|
||||||
} else {
|
} else {
|
||||||
printf("\nError: no blend loaded. cannot use '-a'.\n");
|
printf("\nError: no blend loaded. cannot use '-a'.\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user