diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-28 17:48:11 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-28 17:48:11 +0400 |
commit | 7aab31430fc1bd1b45dfcd15d257bf8ba9e188b8 (patch) | |
tree | cb2940312f15f9b453151e473187d46f3547844e /source/blender | |
parent | 46895ab1f2786c2347d0d42b192197fca6d04bf5 (diff) |
External render engines can now render previews as well, disabled by
default, set RenderEngine property bl_preview = True to enable it.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/render/render_preview.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_render.c | 4 | ||||
-rw-r--r-- | source/blender/render/extern/include/RE_pipeline.h | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/envmap.c | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 119 | ||||
-rw-r--r-- | source/blender/render/intern/source/sss.c | 2 |
6 files changed, 52 insertions, 93 deletions
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 13f8b07c405..1a9e70518bc 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -299,6 +299,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->r.alphamode= R_ADDSKY; sce->r.cfra= scene->r.cfra; + strcpy(sce->r.engine, scene->r.engine); if(id_type==ID_MA) { Material *mat= (Material *)id; @@ -780,7 +781,7 @@ void BIF_view3d_previewrender(Scene *scene, ScrArea *sa) /* OK, can we enter render code? */ if(ri->status==(PR_DISPRECT|PR_DBASE|PR_PROJECTED|PR_ROTATED)) { //printf("curtile %d tottile %d\n", ri->curtile, ri->tottile); - RE_TileProcessor(ri->re, ri->curtile, 0); + RE_TileProcessor(ri->re); //, ri->curtile, 0); if(ri->rect==NULL) ri->rect= MEM_mallocN(sizeof(int)*ri->pr_rectx*ri->pr_recty, "preview view3d rect"); @@ -915,7 +916,9 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs else sizex= sp->sizex; /* allocates or re-uses render result */ - RE_InitState(re, NULL, &sce->r, NULL, sizex, sp->sizey, NULL); + sce->r.xsch= sizex; + sce->r.ysch= sp->sizey; + sce->r.size= 100; /* callbacs are cleared on GetRender() */ if(sp->pr_method==PR_BUTS_RENDER) { @@ -928,10 +931,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs ((Camera *)sce->camera->data)->lens *= (float)sp->sizey/(float)sizex; /* entire cycle for render engine */ - RE_SetCamera(re, sce->camera); - RE_Database_FromScene(re, sce, sce->lay, 1); - RE_TileProcessor(re, 0, 1); // actual render engine - RE_Database_Free(re); + RE_PreviewRender(re, sce); ((Camera *)sce->camera->data)->lens= oldlens; diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 710a22ba17a..28d309c2d37 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -279,6 +279,10 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_property_string_sdna(prop, NULL, "type->name"); RNA_def_property_flag(prop, PROP_REGISTER); + prop= RNA_def_property(srna, "bl_preview", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "type->flag", RE_DO_PREVIEW); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_define_verify_sdna(1); } diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 2a653724051..9373b3e20c9 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -202,12 +202,15 @@ void RE_set_max_threads(int threads); void RE_init_threadcount(Render *re); /* the main processor, assumes all was set OK! */ -void RE_TileProcessor(struct Render *re, int firsttile, int threaded); +void RE_TileProcessor(struct Render *re); /* only RE_NewRender() needed, main Blender render calls */ void RE_BlenderFrame(struct Render *re, struct Scene *scene, struct SceneRenderLayer *srl, unsigned int lay, int frame); void RE_BlenderAnim(struct Render *re, struct Scene *scene, unsigned int lay, int sfra, int efra, int tfra, struct ReportList *reports); +/* main preview render call */ +void RE_PreviewRender(struct Render *re, struct Scene *scene); + void RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); void RE_WriteRenderResult(RenderResult *rr, char *filename, int compress); struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty); @@ -252,6 +255,7 @@ struct Scene *RE_GetScene(struct Render *re); #define RE_INTERNAL 1 #define RE_GAME 2 +#define RE_DO_PREVIEW 4 extern ListBase R_engines; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index a3d6eddb192..1a34868b9fd 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -447,7 +447,7 @@ static void render_envmap(Render *re, EnvMap *env) env_set_imats(envre); if(re->test_break(re->tbh)==0) { - RE_TileProcessor(envre, 0, 0); + RE_TileProcessor(envre); } /* rotate back */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index e814a6b1b45..f2b58c5dc0f 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1456,61 +1456,6 @@ static void *do_part_thread(void *pa_v) return NULL; } -/* returns with render result filled, not threaded, used for preview now only */ -static void render_tile_processor(Render *re, int firsttile) -{ - RenderPart *pa; - - if(re->test_break(re->tbh)) - return; - - BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); - - /* hrmf... exception, this is used for preview render, re-entrant, so render result has to be re-used */ - if(re->result==NULL || re->result->layers.first==NULL) { - if(re->result) RE_FreeRenderResult(re->result); - re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); - } - - BLI_rw_mutex_unlock(&re->resultmutex); - - re->stats_draw(re->sdh, &re->i); - - if(re->result==NULL) - return; - - initparts(re); - - /* assuming no new data gets added to dbase... */ - R= *re; - - for(pa= re->parts.first; pa; pa= pa->next) { - if(firsttile) { - re->i.partsdone++; /* was reset in initparts */ - firsttile--; - } - else { - do_part_thread(pa); - - if(pa->result) { - if(!re->test_break(re->tbh)) { - if(render_display_draw_enabled(re)) - re->display_draw(re->ddh, pa->result, NULL); - - re->i.partsdone++; - re->stats_draw(re->sdh, &re->i); - } - RE_FreeRenderResult(pa->result); - pa->result= NULL; - } - if(re->test_break(re->tbh)) - break; - } - } - - freeparts(re); -} - /* calculus for how much 1 pixel rendered should rotate the 3d geometry */ /* is not that simple, needs to be corrected for errors of larger viewplane sizes */ /* called in initrender.c, initparts() and convertblender.c, for speedvectors */ @@ -1784,43 +1729,20 @@ static void threaded_tile_processor(Render *re) } /* currently only called by preview renders and envmap */ -void RE_TileProcessor(Render *re, int firsttile, int threaded) +void RE_TileProcessor(Render *re) { - /* the partsdone variable has to be reset to firsttile, to survive esc before it was set to zero */ - - re->i.partsdone= firsttile; - - if(!re->sss_points) - re->i.starttime= PIL_check_seconds_timer(); - - if(threaded) - threaded_tile_processor(re); - else - render_tile_processor(re, firsttile); - - if(!re->sss_points) - re->i.lastframetime= PIL_check_seconds_timer()- re->i.starttime; - re->stats_draw(re->sdh, &re->i); + threaded_tile_processor(re); } - /* ************ This part uses API, for rendering Blender scenes ********** */ -static void external_render_3d(Render *re, RenderEngineType *type); +static int external_render_3d(Render *re); static void do_render_3d(Render *re) { - RenderEngineType *type; - /* try external */ - for(type=R_engines.first; type; type=type->next) - if(strcmp(type->idname, re->r.engine) == 0) - break; - - if(type && type->render) { - external_render_3d(re, type); + if(external_render_3d(re)) return; - } /* internal */ @@ -2988,6 +2910,23 @@ void RE_BlenderAnim(Render *re, Scene *scene, unsigned int lay, int sfra, int ef G.rendering= 0; } +void RE_PreviewRender(Render *re, Scene *sce) +{ + int winx, winy; + + winx= (sce->r.size*sce->r.xsch)/100; + winy= (sce->r.size*sce->r.ysch)/100; + + RE_InitState(re, NULL, &sce->r, NULL, winx, winy, NULL); + + re->scene = sce; + re->lay = sce->lay; + + RE_SetCamera(re, sce->camera); + + do_render_3d(re); +} + /* note; repeated win/disprect calc... solve that nicer, also in compo */ /* only the temp file! */ @@ -3193,10 +3132,20 @@ void RE_result_load_from_file(RenderResult *result, ReportList *reports, char *f } } -static void external_render_3d(Render *re, RenderEngineType *type) +static int external_render_3d(Render *re) { + RenderEngineType *type; RenderEngine engine; + for(type=R_engines.first; type; type=type->next) + if(strcmp(type->idname, re->r.engine) == 0) + break; + + if(!(type && type->render)) + return 0; + if((re->r.scemode & R_PREVIEWBUTS) && !(type->flag & RE_DO_PREVIEW)) + return 0; + BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); if(re->result==NULL || !(re->r.scemode & R_PREVIEWBUTS)) { RE_FreeRenderResult(re->result); @@ -3209,7 +3158,7 @@ static void external_render_3d(Render *re, RenderEngineType *type) BLI_rw_mutex_unlock(&re->resultmutex); if(re->result==NULL) - return; + return 1; /* external */ memset(&engine, 0, sizeof(engine)); @@ -3237,5 +3186,7 @@ static void external_render_3d(Render *re, RenderEngineType *type) read_render_result(re, 0); } BLI_rw_mutex_unlock(&re->resultmutex); + + return 1; } diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 6bc1153f8b3..836a60ef4f9 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -878,7 +878,7 @@ static void sss_create_tree_mat(Render *re, Material *mat) re->result= NULL; BLI_rw_mutex_unlock(&re->resultmutex); - RE_TileProcessor(re, 0, 1); + RE_TileProcessor(re); BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); if(!(re->r.scemode & R_PREVIEWBUTS)) { |