[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13328] branches/soc-2007-joeedh: Made the tile system more accurately calculate memory in use.
Joseph Eagar
joeedh at gmail.com
Mon Jan 21 11:53:47 CET 2008
Revision: 13328
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13328
Author: joeedh
Date: 2008-01-21 11:53:47 +0100 (Mon, 21 Jan 2008)
Log Message:
-----------
Made the tile system more accurately calculate memory in use.
Also fixed a bug where part of the tile allocation code was
in the wrong place, so if you pressed ESC while creation a
large shadow map memory usage could spike. This was caused
by the ESC signal blocking the cache system but not this
allocation.
Also added a test option to materials to treat polygon
samples as volumetric samples; this is currently disabled
because the implementation code was crashing in odd ways.
Modified Paths:
--------------
branches/soc-2007-joeedh/intern/guardedalloc/MEM_guardedalloc.h
branches/soc-2007-joeedh/intern/guardedalloc/intern/mallocn.c
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
branches/soc-2007-joeedh/source/blender/blenlib/intern/BLI_memarena.c
branches/soc-2007-joeedh/source/blender/makesdna/DNA_material_types.h
branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
branches/soc-2007-joeedh/source/blender/src/buttons_shading.c
Modified: branches/soc-2007-joeedh/intern/guardedalloc/MEM_guardedalloc.h
===================================================================
--- branches/soc-2007-joeedh/intern/guardedalloc/MEM_guardedalloc.h 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/intern/guardedalloc/MEM_guardedalloc.h 2008-01-21 10:53:47 UTC (rev 13328)
@@ -128,6 +128,44 @@
void MEM_set_memory_debug(void);
+/********* Internal structs. They're only here for the MEM_OVERHEAD macro.*********/
+
+/* --------------------------------------------------------------------- */
+/* Data definition */
+/* --------------------------------------------------------------------- */
+/* all memory chunks are put in linked lists */
+typedef struct localLink
+{
+ struct localLink *next,*prev;
+} localLink;
+
+typedef struct localListBase
+{
+ void *first, *last;
+} localListBase;
+
+ /* note: keep this struct aligned (e.g., irix/gcc) - Hos */
+typedef struct MemHead {
+ int tag1;
+ int len;
+ struct MemHead *next,*prev;
+ const char * name;
+ const char * nextname;
+ int tag2;
+ int mmap; /* if true, memory was mmapped */
+} MemHead;
+
+typedef struct MemTail {
+ int tag3, pad;
+} MemTail;
+
+/*memory bias to hopefully account
+ for allocation overhead from
+ the system allocator.*/
+#define MEM_OVERHEADBIAS 32
+
+#define MEM_OVERHEAD (sizeof(MemHead) + sizeof(MemTail) + MEM_OVERHEADBIAS)
+
#ifdef __cplusplus
}
#endif
Modified: branches/soc-2007-joeedh/intern/guardedalloc/intern/mallocn.c
===================================================================
--- branches/soc-2007-joeedh/intern/guardedalloc/intern/mallocn.c 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/intern/guardedalloc/intern/mallocn.c 2008-01-21 10:53:47 UTC (rev 13328)
@@ -50,36 +50,6 @@
#include "MEM_guardedalloc.h"
/* --------------------------------------------------------------------- */
-/* Data definition */
-/* --------------------------------------------------------------------- */
-/* all memory chunks are put in linked lists */
-typedef struct localLink
-{
- struct localLink *next,*prev;
-} localLink;
-
-typedef struct localListBase
-{
- void *first, *last;
-} localListBase;
-
- /* note: keep this struct aligned (e.g., irix/gcc) - Hos */
-typedef struct MemHead {
- int tag1;
- int len;
- struct MemHead *next,*prev;
- const char * name;
- const char * nextname;
- int tag2;
- int mmap; /* if true, memory was mmapped */
-} MemHead;
-
-typedef struct MemTail {
- int tag3, pad;
-} MemTail;
-
-
-/* --------------------------------------------------------------------- */
/* local functions */
/* --------------------------------------------------------------------- */
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c 2008-01-21 10:53:47 UTC (rev 13328)
@@ -279,7 +279,7 @@
vtile->pool = pool;
vtile->buffer = self;
vtile->len = dsm_gettilelen(vtile);
- vtile->struct_overhead = sizeof(DSMTile);
+ vtile->struct_overhead = sizeof(DSMTile) + MEM_OVERHEAD;
BASSERT(pool != NULL);
if (!pool) return;
Modified: branches/soc-2007-joeedh/source/blender/blenlib/intern/BLI_memarena.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenlib/intern/BLI_memarena.c 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/source/blender/blenlib/intern/BLI_memarena.c 2008-01-21 10:53:47 UTC (rev 13328)
@@ -54,11 +54,14 @@
int used;
LinkNode *bufs;
+ int totbufs;
};
int BLI_memarena_memsize(MemArena *ma)
{
- return ma->totalsize;
+ /*MEM_OVERHEAD is doubled to account for both the LinkNode's
+ overhead plus the actual buffer's overhead.*/
+ return ma->totalsize + sizeof(MemArena)+MEM_OVERHEAD + (sizeof(LinkNode)+MEM_OVERHEAD*2)*ma->totbufs;
}
int BLI_memarena_memused(MemArena *ma)
@@ -108,6 +111,7 @@
ma->totalsize += ma->cursize;
BLI_linklist_prepend(&ma->bufs, ma->curbuf);
+ ma->totbufs++;
}
ptr= ma->curbuf;
Modified: branches/soc-2007-joeedh/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/makesdna/DNA_material_types.h 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/source/blender/makesdna/DNA_material_types.h 2008-01-21 10:53:47 UTC (rev 13328)
@@ -135,6 +135,7 @@
int YF_dsmp, YF_preset, YF_djit;
ScriptLink scriptlink;
+ int shadowvol, pad4; /*option to treat material as volumetric in deep shadow maps */
} Material;
/* **************** MATERIAL ********************* */
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-01-21 10:53:47 UTC (rev 13328)
@@ -212,13 +212,13 @@
tile->x = x;
tile->y = y;
- tile->arena = BLI_memarena_new(DSM_TILE_MEMARENASIZE); /*FIXMEGREP: tweak this to find optimal value.*/
- BLI_memarena_use_mapalloc(tile->arena);
- tile->r_rect = BLI_memarena_alloc(tile->arena, sizeof(void*)*tile->sizex*tile->sizey);
- tile->g_rect = BLI_memarena_alloc(tile->arena, sizeof(void*)*tile->sizex*tile->sizey);
- tile->b_rect = BLI_memarena_alloc(tile->arena, sizeof(void*)*tile->sizex*tile->sizey);
+ if (!(re->test_break && re->test_break())) {
+ tile->arena = BLI_memarena_new(DSM_TILE_MEMARENASIZE); /*FIXMEGREP: tweak this to find optimal value.*/
+ BLI_memarena_use_mapalloc(tile->arena);
+ tile->r_rect = BLI_memarena_alloc(tile->arena, sizeof(void*)*tile->sizex*tile->sizey);
+ tile->g_rect = BLI_memarena_alloc(tile->arena, sizeof(void*)*tile->sizex*tile->sizey);
+ tile->b_rect = BLI_memarena_alloc(tile->arena, sizeof(void*)*tile->sizex*tile->sizey);
- if (!(re->test_break && re->test_break())) {
printf("Rendering a dsm shadow tile! Tile %d of %d\n", y*dbuf->tilex+x, dbuf->tilex*dbuf->tiley);
memset(dbuf->lastbuf, 0, sizeof(void*)*tile->sizex*tile->sizey);
memset(dbuf->lastbufstrand, 0, sizeof(void*)*tile->sizex*tile->sizey);
@@ -825,19 +825,30 @@
for (a=0; a<b; a++) {
if (lastsamples[row2[a].samplenr]) {
- /*add polygon "step" to the transmittance function,
- if the last sample in this transmittance function is
- a polygon sample*/
- if (lastsamples[row2[a].samplenr]->type) {
- for (c=0; c<3; c++) {
- row[totface] = *lastsamples[row2[a].samplenr];
- row[totface].index = c;
- row[totface].type = (row[totface].type == DSM_FACE)? DSM_FACE_STEP: DSM_STRAND_STEP;
- row[totface].depth = row2[a].depth;
- row[totface].next = row[totface].prev = NULL;
- row[totface].srclist = NULL;
+ /*if (row2[a].type != DSM_NONE) {
+ if(ELEM(row[a].type, DSM_STRAND, DSM_STRAND_STEP)) {
+ strand= RE_findOrAddStrand(re->objectinstance[row2[a].obi].obr, row2[a].p);
+ mat= strand->buffer->ma;
+ } else {
+ vlak = RE_findOrAddVlak(re->objectinstance[row2[a].obi].obr, (row2[a].p-1) & RE_QUAD_MASK);
+ mat= vlak->mat;
+ }
+ }*/
+ if (1) { //row2[a].type != DSM_NONE && mat && !mat->shadowvol) {
+ /*add polygon "step" to the transmittance function,
+ if the last sample in this transmittance function is
+ a polygon sample*/
+ if (lastsamples[row2[a].samplenr]->type) {
+ for (c=0; c<3; c++) {
+ row[totface] = *lastsamples[row2[a].samplenr];
+ row[totface].index = c;
+ row[totface].type = (row[totface].type == DSM_FACE)? DSM_FACE_STEP: DSM_STRAND_STEP;
+ row[totface].depth = row2[a].depth;
+ row[totface].next = row[totface].prev = NULL;
+ row[totface].srclist = NULL;
- totface++;
+ totface++;
+ }
}
}
} else {
@@ -916,7 +927,6 @@
continue;
}
- /*clear shr, shi*/
if(ELEM(row[a].type, DSM_STRAND, DSM_STRAND_STEP)) {
strand= RE_findOrAddStrand(re->objectinstance[row[a].obi].obr, row[a].p);
mat= strand->buffer->ma;
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c 2008-01-21 10:53:47 UTC (rev 13328)
@@ -3562,7 +3562,7 @@
minx /= tilesizex; miny /= tilesizey;
maxx /= tilesizex; maxy /= tilesizey;
- printf("bounds: [%f, %f, %f, %f]\n", minx, miny, maxx, maxy);
+ //printf("bounds: [%f, %f, %f, %f]\n", minx, miny, maxx, maxy);
for (x=minx; x<maxx; x++) {
for (y=miny; y<maxy; y++) {
tile = TCS_GetAndLockTile((TCS_TileBuffer*)bucketbuf, x, y, 0);
@@ -3796,7 +3796,6 @@
}
- printf("tots: %d\n", tile->tots);
for (entry=tile->sentries; entry; entry=entry->next) {
for (i=0; i<entry->used; i++) {
obi = &re->objectinstance[entry->obi[i]];
Modified: branches/soc-2007-joeedh/source/blender/src/buttons_shading.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/src/buttons_shading.c 2008-01-21 08:34:18 UTC (rev 13327)
+++ branches/soc-2007-joeedh/source/blender/src/buttons_shading.c 2008-01-21 10:53:47 UTC (rev 13328)
@@ -4109,9 +4109,10 @@
uiDefBut(block, LABEL, B_DIFF, "Render Pipeline", 10, 70, 300, 20, 0, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
- uiDefButBitI(block, TOG, MA_HALO, B_MATHALO, "Halo", 10,50,100,19, &(ma->mode), 0, 0, 0, 0, "Renders material as a halo");
- uiDefButBitI(block, TOG, MA_ZTRA, B_MATZTRANSP,"ZTransp", 110,50,100,19, &(ma->mode), 0, 0, 0, 0, "Enables Z-Buffering of transparent faces");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list