diff options
author | Ton Roosendaal <ton@blender.org> | 2006-02-12 02:17:41 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-02-12 02:17:41 +0300 |
commit | ed4cc927a7acfd69c01b86814facb2f566d9781e (patch) | |
tree | 2972ea2adfa2553c5dcc202ad8d97378b0aea4c6 | |
parent | 5f29f97f812d360fad295b29d2c4761eeb562e09 (diff) |
Couple of features/fixes:
- Compositor now frees memory of buffers internally used in groups
immediately. This wasn't part of the event-based cache anyway
- New option: "Free Texture Images" (in render Output panel). This
frees after each render of each scene all images and mipmaps as
used by textures. As reference it prints total amount of MB freed.
- Render stage 'creating speed vectors' had no ESC checking yet
- Made drawing scanline updates during render draw 1 scanline less...
dunno, still hunting for weird opengl crashes.
- 3D preview render didn't properly skip sequence or composit render.
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 36 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/node.c | 26 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 1 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 98 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 23 | ||||
-rw-r--r-- | source/blender/src/previewrender.c | 5 | ||||
-rw-r--r-- | source/blender/src/renderwin.c | 2 |
8 files changed, 120 insertions, 72 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 250b6dc762f..5fb9201a697 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -62,6 +62,7 @@ void converttopremul(struct ImBuf *ibuf); void tag_image_time(struct Image *ima); void free_old_images(void); +void free_all_imagetextures(void); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a4dfa9b93fe..6885cc2ce30 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -80,17 +80,17 @@ void free_image_buffers(Image *ima) if(ima->ibuf) { if (ima->ibuf->userdata) { MEM_freeN(ima->ibuf->userdata); - ima->ibuf->userdata = 0; + ima->ibuf->userdata = NULL; } IMB_freeImBuf(ima->ibuf); - ima->ibuf= 0; + ima->ibuf= NULL; } if(ima->anim) IMB_free_anim(ima->anim); - ima->anim= 0; + ima->anim= NULL; for(a=0; a<BLI_ARRAY_NELEMS(ima->mipmap); a++) { if(ima->mipmap[a]) IMB_freeImBuf(ima->mipmap[a]); - ima->mipmap[a]= 0; + ima->mipmap[a]= NULL; } free_realtime_image(ima); @@ -273,6 +273,30 @@ void free_unused_animimages() } } +void free_all_imagetextures(void) +{ + Tex *tex; + Image *ima; + unsigned int totsize= 0; + + for(ima= G.main->image.first; ima; ima= ima->id.next) + ima->id.flag &= ~LIB_DOIT; + + for(tex= G.main->tex.first; tex; tex= tex->id.next) + if(tex->ima) + tex->ima->id.flag |= LIB_DOIT; + + for(ima= G.main->image.first; ima; ima= ima->id.next) { + if(ima->ibuf && (ima->id.flag & LIB_DOIT)) { + if(ima->mipmap[0]) + totsize+= 1.33*ima->ibuf->x*ima->ibuf->y*4; + else + totsize+= ima->ibuf->x*ima->ibuf->y*4; + free_image_buffers(ima); + } + } + printf("freed total %d MB\n", totsize/(1024*1024)); +} /* *********** READ AND WRITE ************** */ @@ -474,8 +498,8 @@ struct anim *openanim(char * name, int flags) ibuf = IMB_anim_absolute(anim, 0); - if (ibuf == 0) { - printf("anim_absolute 0 failed\n"); + if (ibuf == NULL) { + printf("not an anim; %s\n", name); IMB_free_anim(anim); return(0); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7c08d4f1af1..efe17ded943 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1057,10 +1057,11 @@ void ntreeFreeCache(bNodeTree *ntree) bNode *node; if(ntree==NULL) return; - + if(ntree->type==NTREE_COMPOSIT) for(node= ntree->nodes.first; node; node= node->next) composit_free_node_cache(node); + } void ntreeMakeLocal(bNodeTree *ntree) @@ -1506,6 +1507,23 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod node->typeinfo->execfunc(data, node, nsin, nsout); } } + + /* free internal group output nodes */ + for(node= ntree->nodes.first; node; node= node->next) { + if(node->typeinfo->execfunc) { + bNodeSocket *sock; + + for(sock= node->outputs.first; sock; sock= sock->next) { + if(sock->intern) { + bNodeStack *ns= stack + sock->stack_index; + if(ns->data) { + free_compbuf(ns->data); + ns->data= NULL; + } + } + } + } + } } /* recursively called for groups */ @@ -1570,7 +1588,7 @@ static void composit_end_exec(bNodeTree *ntree) bNode *node; bNodeStack *ns; int a; - + for(node= ntree->nodes.first; node; node= node->next) { bNodeSocket *sock; @@ -1586,8 +1604,10 @@ static void composit_end_exec(bNodeTree *ntree) /* internally, group buffers are not stored */ for(ns= ntree->stack, a=0; a<ntree->stacksize; a++, ns++) { - if(ns->data) + if(ns->data) { + printf("freed leftover buffer from stack\n"); free_compbuf(ns->data); + } } } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index e2c9484bec1..149daa3ebf2 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -444,6 +444,7 @@ typedef struct Scene { #define R_NODE_PREVIEW 0x0020 #define R_DOCOMP 0x0040 #define R_COMP_CROP 0x0080 +#define R_FREE_IMAGE 0x0100 /* alphamode */ #define R_ADDSKY 0 diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index fe03dd5ed20..0b7ec712e8e 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -73,6 +73,7 @@ #include "BKE_group.h" #include "BKE_key.h" #include "BKE_ipo.h" +#include "BKE_image.h" #include "BKE_lattice.h" #include "BKE_material.h" #include "BKE_main.h" @@ -2581,6 +2582,10 @@ void RE_Database_Free(Render *re) re->totvlak=re->totvert=re->totlamp=re->tothalo= 0; re->i.convertdone= 0; + + if(re->scene->r.scemode & R_FREE_IMAGE) + free_all_imagetextures(); + } /* per face check if all samples should be taken. @@ -3070,9 +3075,11 @@ static void database_fromscene_vectors(Render *re, Scene *scene, int timeoffset) } } + if(re->test_break()) break; } - project_renderdata(re, projectverto, re->r.mode & R_PANORAMA, 0); + if(!re->test_break()) + project_renderdata(re, projectverto, re->r.mode & R_PANORAMA, 0); /* do this in end, particles for example need cfra */ G.scene->r.cfra-=timeoffset; @@ -3170,12 +3177,13 @@ void RE_Database_FromScene_Vectors(Render *re, Scene *sce) /* free dbase and make the future one */ RE_Database_Free(re); - /* creates entire dbase */ - re->i.infostr= "Calculating next frame vectors"; - re->stats_draw(&re->i); - - database_fromscene_vectors(re, sce, +1); - + if(!re->test_break()) { + /* creates entire dbase */ + re->i.infostr= "Calculating next frame vectors"; + re->stats_draw(&re->i); + + database_fromscene_vectors(re, sce, +1); + } /* copy away vertex info */ newvertnodes= re->vertnodes; newvertnodeslen= re->vertnodeslen; @@ -3189,46 +3197,50 @@ void RE_Database_FromScene_Vectors(Render *re, Scene *sce) /* free dbase and make the real one */ RE_Database_Free(re); - RE_Database_FromScene(re, sce, 1); - for(step= 0; step<2; step++) { - - if(step) { - table= &newtable; - vertnodes= newvertnodes; - } - else { - table= &oldtable; - vertnodes= oldvertnodes; - } - - oldobren= table->first; - - for(obren= re->objecttable.first; obren && oldobren; obren= obren->next, oldobren= oldobren->next) { - int ok= 1; - - /* find matching object in old table */ - if(oldobren->ob!=obren->ob || oldobren->par!=obren->par || oldobren->index!=obren->index) { - ok= 0; - for(oldobren= table->first; oldobren; oldobren= oldobren->next) - if(oldobren->ob==obren->ob && oldobren->par==obren->par && oldobren->index==obren->index) - break; - if(oldobren==NULL) - oldobren= table->first; - else - ok= 1; - } - if(ok==0) { - printf("speed table: missing object %s\n", obren->ob->id.name+2); - continue; + if(!re->test_break()) + RE_Database_FromScene(re, sce, 1); + + if(!re->test_break()) { + for(step= 0; step<2; step++) { + + if(step) { + table= &newtable; + vertnodes= newvertnodes; } - /* check if both have same amounts of vertices */ - if(obren->endvert-obren->startvert != oldobren->endvert-oldobren->startvert) { - printf("Warning: object %s has different amount of vertices on other frame\n", obren->ob->id.name+2); - continue; + else { + table= &oldtable; + vertnodes= oldvertnodes; } - calculate_speedvectors(re, vertnodes, obren->startvert, oldobren->startvert, obren->endvert, step); + oldobren= table->first; + + for(obren= re->objecttable.first; obren && oldobren; obren= obren->next, oldobren= oldobren->next) { + int ok= 1; + + /* find matching object in old table */ + if(oldobren->ob!=obren->ob || oldobren->par!=obren->par || oldobren->index!=obren->index) { + ok= 0; + for(oldobren= table->first; oldobren; oldobren= oldobren->next) + if(oldobren->ob==obren->ob && oldobren->par==obren->par && oldobren->index==obren->index) + break; + if(oldobren==NULL) + oldobren= table->first; + else + ok= 1; + } + if(ok==0) { + // printf("speed table: missing object %s\n", obren->ob->id.name+2); + continue; + } + /* check if both have same amounts of vertices */ + if(obren->endvert-obren->startvert != oldobren->endvert-oldobren->startvert) { + printf("Warning: object %s has different amount of vertices on other frame\n", obren->ob->id.name+2); + continue; + } + + calculate_speedvectors(re, vertnodes, obren->startvert, oldobren->startvert, obren->endvert, step); + } } } diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 57b20c0fe5f..2460129fda1 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -913,6 +913,7 @@ static uiBlock *edge_render_menu(void *arg_unused) return block; } +#if 0 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ static uiBlock *post_render_menu(void *arg_unused) { @@ -935,6 +936,7 @@ static uiBlock *post_render_menu(void *arg_unused) return block; } +#endif /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ static uiBlock *framing_render_menu(void *arg_unused) @@ -1246,31 +1248,18 @@ static void render_panel_output(void) uiDefButS(block, ROW, B_REDR, "DispView", 134, 10, 60, 20, &G.displaymode, 0.0, (float)R_DISPLAYVIEW, 0, 0, "Sets render output to display in 3D view"); uiBlockEndAlign(block); - uiDefButBitS(block, TOG, R_EXTENSION, 0, "Extensions", 205, 10, 105, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations"); + uiDefButBitS(block, TOG, R_EXTENSION, B_NOP, "Extensions", 205, 10, 105, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations"); /* Dither control */ uiDefButF(block, NUM,B_DIFF, "Dither:", 205,31,105,19, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)"); /* Toon shading buttons */ uiBlockBeginAlign(block); - uiDefButBitI(block, TOG, R_EDGE, 0,"Edge", 100, 94, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon edge shading"); + uiDefButBitI(block, TOG, R_EDGE, B_NOP,"Edge", 100, 94, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon edge shading"); uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 170, 94, 140, 20, "Display edge settings"); - - /* postprocess render buttons */ - uiBlockBeginAlign(block); -// if(R.rectftot) -// uiDefIconTextButBitI(block, TOG, R_FBUF, B_NOP, ICON_IMAGE_DEHLT," Fbuf", 100, 68, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render; buffer available"); -// else -// uiDefButBitI(block, TOG, R_FBUF, 0,"Fbuf", 100, 68, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render, no buffer available now"); - uiDefBlockBut(block, post_render_menu, NULL, "Post process", 170, 68, 140, 20, "Applies on RGBA floats while render or with Fbuf available"); uiBlockEndAlign(block); - - /* removed, for time being unified and normal render will use same gamma for blending (2.0) */ - //if (G.scene->r.mode & R_GAMMA) { - // uiDefButF(block, NUMSLI, B_NOP,"Gamma:", 10, 68, 142, 20, - // &(G.scene->r.gamma), 0.2, 5.0, B_GAMMASLI, 0, - // "The gamma value for blending oversampled images (1.0 = no correction)."); - //} + + uiDefButBitS(block, TOG, R_FREE_IMAGE, B_NOP, "Free Tex Images", 170, 68, 140, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Frees all Images used by Textures after each render"); } static void render_panel_render(void) diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c index bbe8cb94b20..1ef1f5804fa 100644 --- a/source/blender/src/previewrender.c +++ b/source/blender/src/previewrender.c @@ -670,9 +670,10 @@ void BIF_view3d_previewrender(ScrArea *sa) RE_stats_draw_cb(re, view3d_previewrender_stats); RE_test_break_cb(re, qtest); - /* no osa, blur, seq, for preview render */ + /* no osa, blur, seq, layers, etc for preview render */ rdata= G.scene->r; - rdata.mode &= ~(R_OSA|R_MBLUR|R_DOSEQ); + rdata.mode &= ~(R_OSA|R_MBLUR); + rdata.scemode &= ~(R_DOSEQ|R_DOCOMP|R_FREE_IMAGE); rdata.layers.first= rdata.layers.last= NULL; RE_InitState(re, &rdata, sa->winx, sa->winy, &ri->disprect); diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c index 7ab2044efcf..3ff17c1508f 100644 --- a/source/blender/src/renderwin.c +++ b/source/blender/src/renderwin.c @@ -762,7 +762,7 @@ static void renderwin_progress(RenderWin *rw, RenderResult *rr, rcti *renrect) /* if renrect argument, we only display scanlines */ if(renrect) { ymin= renrect->ymin; - ymax= renrect->ymax-ymin; + ymax= renrect->ymax-ymin - 1; /* dunno... scanline updating seems to be nasty? */ if(ymax<2) return; renrect->ymin= renrect->ymax; } |