diff options
author | Matt Ebb <matt@mke3.net> | 2010-05-27 12:22:16 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-05-27 12:22:16 +0400 |
commit | 6e92ddf8b37dbfae733a9738a20777917610b4a0 (patch) | |
tree | 4f92654d234a24a85918f5ec37ad1a9e4d819e63 /source/blender/render | |
parent | ec70356424d687cb1cdb8cb80095a5593937e03a (diff) |
Progress indicators for threaded jobs
Now, rather than the bit-too-alarming stop sign, threaded wmJobs
display a progress indicator in the header. This is an optional feature
for each job type and still uses the same hardcoded ui template
(could use further work here...).
Currently implemented for:
Render - parts completed, then nodes comped
Compositor - nodes comped
Fluid Sim - frames simulated
Texture Bake - faces baked
Example: http://mke3.net/blender/devel/2.5/progress.mov
Diffstat (limited to 'source/blender/render')
5 files changed, 27 insertions, 18 deletions
diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 0d8161c9a7a..b72ba8e0c40 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -230,7 +230,7 @@ void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle void RE_display_clear_cb(struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); void RE_display_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr, volatile struct rcti *rect)); void RE_stats_draw_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderStats *rs)); -void RE_timecursor_cb (struct Render *re, void *handle, void (*f)(void *handle, int)); +void RE_progress_cb (struct Render *re, void *handle, void (*f)(void *handle, float)); void RE_test_break_cb (struct Render *re, void *handle, int (*f)(void *handle)); void RE_error_cb (struct Render *re, void *handle, void (*f)(void *handle, char *str)); diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h index 742eb851c50..6cab4a7ce03 100644 --- a/source/blender/render/extern/include/RE_shader_ext.h +++ b/source/blender/render/extern/include/RE_shader_ext.h @@ -199,7 +199,7 @@ struct Image; struct Object; void RE_shade_external(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr); -int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update); +int RE_bake_shade_all_selected(struct Render *re, int type, struct Object *actob, short *do_update, float *progress); struct Image *RE_bake_shade_get_image(void); #endif /* RE_SHADER_EXT_H */ diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 127fbce20eb..1abc431fc6d 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -234,8 +234,8 @@ struct Render void (*stats_draw)(void *handle, RenderStats *ri); void *sdh; - void (*timecursor)(void *handle, int i); - void *tch; + void (*progress)(void *handle, float i); + void *prh; int (*test_break)(void *handle); void *tbh; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index e990331b3ca..180f8a960db 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -131,7 +131,7 @@ static int thread_break(void *unused) static void result_nothing(void *unused, RenderResult *rr) {} static void result_rcti_nothing(void *unused, RenderResult *rr, volatile struct rcti *rect) {} static void stats_nothing(void *unused, RenderStats *rs) {} -static void int_nothing(void *unused, int val) {} +static void float_nothing(void *unused, float val) {} static void print_error(void *unused, char *str) {printf("ERROR: %s\n", str);} static int default_break(void *unused) {return G.afbreek == 1;} @@ -1162,7 +1162,7 @@ Render *RE_NewRender(const char *name) re->display_init= result_nothing; re->display_clear= result_nothing; re->display_draw= result_rcti_nothing; - re->timecursor= int_nothing; + re->progress= float_nothing; re->test_break= default_break; re->error= print_error; if(G.background) @@ -1170,7 +1170,7 @@ Render *RE_NewRender(const char *name) else re->stats_draw= stats_nothing; /* clear callback handles */ - re->dih= re->dch= re->ddh= re->sdh= re->tch= re->tbh= re->erh= NULL; + re->dih= re->dch= re->ddh= re->sdh= re->prh= re->tbh= re->erh= NULL; /* init some variables */ re->ycor= 1.0f; @@ -1374,10 +1374,10 @@ void RE_stats_draw_cb(Render *re, void *handle, void (*f)(void *handle, RenderSt re->stats_draw= f; re->sdh= handle; } -void RE_timecursor_cb(Render *re, void *handle, void (*f)(void *handle, int)) +void RE_progress_cb(Render *re, void *handle, void (*f)(void *handle, float)) { - re->timecursor= f; - re->tch= handle; + re->progress= f; + re->prh= handle; } void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle)) @@ -1694,6 +1694,7 @@ static void threaded_tile_processor(Render *re) free_render_result(&pa->fullresult, pa->result); pa->result= NULL; re->i.partsdone++; + re->progress(re->prh, re->i.partsdone / (float)re->i.totpart); hasdrawn= 1; } } @@ -2376,8 +2377,11 @@ static void do_render_composite_fields_blur_3d(Render *re) if(!re->test_break(re->tbh)) { ntree->stats_draw= render_composit_stats; ntree->test_break= re->test_break; + ntree->progress= re->progress; ntree->sdh= re->sdh; ntree->tbh= re->tbh; + ntree->prh= re->prh; + /* in case it was never initialized */ R.sdh= re->sdh; R.stats_draw= re->stats_draw; @@ -2393,7 +2397,8 @@ static void do_render_composite_fields_blur_3d(Render *re) ntree->stats_draw= NULL; ntree->test_break= NULL; - ntree->tbh= ntree->sdh= NULL; + ntree->progress= NULL; + ntree->tbh= ntree->sdh= ntree->prh= NULL; } } else if(re->r.scemode & R_FULL_SAMPLE) diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 760ce5636bb..8e1a959abef 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2619,7 +2619,7 @@ static void *do_bake_thread(void *bs_v) /* using object selection tags, the faces with UV maps get baked */ /* render should have been setup */ /* returns 0 if nothing was handled */ -int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_update) +int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_update, float *progress) { BakeShade *handles; ListBase threads; @@ -2680,12 +2680,18 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up /* wait for everything to be done */ a= 0; while(a!=re->r.threads) { - PIL_sleep_ms(50); - for(a=0; a<re->r.threads; a++) + /* calculate progress */ + for(vdone=0, a=0; a<re->r.threads; a++) + vdone+= handles[a].vdone; + if (progress) + *progress = (float)(vdone / (float)re->totvlak); + + for(a=0; a<re->r.threads; a++) { if(handles[a].ready==0) break; + } } /* filter and refresh images */ @@ -2733,12 +2739,10 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up } /* calculate return value */ - for(a=0; a<re->r.threads; a++) { - vdone+= handles[a].vdone; - + for(a=0; a<re->r.threads; a++) { zbuf_free_span(handles[a].zspan); MEM_freeN(handles[a].zspan); - } + } MEM_freeN(handles); |