[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13613] branches/soc-2007-joeedh/source/ blender: Commit of working copy; be warned, this is only so I can work on
Joseph Eagar
joeedh at gmail.com
Sat Feb 9 01:08:07 CET 2008
Revision: 13613
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13613
Author: joeedh
Date: 2008-02-09 01:08:07 +0100 (Sat, 09 Feb 2008)
Log Message:
-----------
Commit of working copy; be warned, this is only so I can work on
this branch on my laptop, there may be bugs or something.
Modified Paths:
--------------
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c 2008-02-08 22:09:47 UTC (rev 13612)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c 2008-02-09 00:08:07 UTC (rev 13613)
@@ -545,7 +545,10 @@
if (tile->file == NULL || (tile->buffer->flag & TCS_READONLY)==0) {
seek_to_tile_pos(tile, pool);
BASSERT(tile->file);
- if (!tile->file) break;
+ if (!tile->file) {
+ printf("Error occured while cacheing!\n");
+ break;
+ }
TCS_fwrite(&tile->compressed_memfile->length, sizeof(unsigned long), 1, tile->file);
TCS_fwrite(tile->compressed_memfile->ptr, tile->compressed_memfile->length, 1, tile->file);
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-02-08 22:09:47 UTC (rev 13612)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-02-09 00:08:07 UTC (rev 13613)
@@ -334,121 +334,6 @@
TCS_FreeBuffer(bucketbuf);
}
-#if 0
-void DSM_CreateBuffer(Render *re, float projmat[4][4], ShadBuf *shb, int tilesize)
-{
- DSMBuffer *dbuf = MEM_mapallocN(sizeof(DSMBuffer), "DSMBuffer");
- DSMTile *tile;
- _ClrEntry *rowscratch;
- RE_BucketBuffer *bucketbuf;
- RE_BucketTile *buckettile;
- char *mergescratch;
- float fac;
- int x, y, lastsizex, lastsizey;
- int mergescratchlen, lay = (1<<20)-1;
-
- /*use 30,000 max elements per pixel for the 2 preallocated
- pixel arrays DSM_DoTile() allocates. the *6
- iirc is because the visibilty function calculation
- kindof expands things (note this is usually more then
- compensated by the final visibility function compression).*/
-
- if (G.rt==71)
- dbuf->max_depth = 2000*6;
- else
- dbuf->max_depth = 30000*6;
-
- dbuf->max_layers = 0;
-
- mergescratchlen = sizeof(_ClrEntry) > sizeof(DSMLayerSample) ? sizeof(_ClrEntry)*dbuf->max_depth : sizeof(DSMLayerSample)*dbuf->max_depth;
- rowscratch = MEM_mallocN(sizeof(_ClrEntry)*dbuf->max_depth, "_ClrEntry");
- mergescratch = MEM_mapallocN(mergescratchlen, "mergescratch in zbuf.c");
- dbuf->s2 = MEM_mallocN(mergescratchlen, "dbuf->s2");
- dbuf->s3 = MEM_mallocN(mergescratchlen, "dbuf->s3");
-
- if (tilesize > shb->size) tilesize = shb->size;
-
- TCS_InitBuffer(&TCS_DeepShadowBuffer, dbuf);
-
- if (deepbuffer_pool == NULL) printf("oh EVVVIL!\n");
-
- dbuf->tsizex = dbuf->tsizey = tilesize;
- dbuf->sizex = dbuf->sizey = shb->size;
- dbuf->tilex = dbuf->tiley = shb->size / tilesize;
-
- /*add extra tiles if necassary.
-
- python tests indicated the + 0.000001 is needed; I have no idea why,
- some sort of numerical error I assume. of course python uses doubles and
- not floats, but I rather doubt that floats are going to behave any better.*/
- fac = ((float)shb->size/(float)tilesize) + 0.0000001;
-
- if ((int)((fac - (int)fac)*(float)tilesize) > 0.000001) {
- dbuf->tilex += 1;
- dbuf->tiley += 1;
- }
-
- bucketbuf = RE_BucketData(re, projmat, shb->size, shb->size,
- tilesize, tilesize, shb->soft, shb->soft, lay);
-
- dbuf->vfunc_rect = MEM_mapallocN(sizeof(DSMTile)*dbuf->tilex*dbuf->tiley, "dsm tiles");
-
- shb->dsmbuffer = dbuf;
-
- /*allocate pointer array needed by zbuffer system.*/
- lastsizex = lastsizey = tilesize;
- dbuf->lastbuf = MEM_callocN(sizeof(void*)*tilesize*tilesize, "lastbuf");
- dbuf->lastbufstrand = MEM_callocN(sizeof(void*)*tilesize*tilesize, "lastbufstrand");
-
- for (y=0; y<dbuf->tiley; y++) {
- for (x=0; x<dbuf->tilex; x++) {
- tile = &dbuf->vfunc_rect[y*dbuf->tilex+x];
-
- /*right and top border tiles arn't always the same size as the others*/
- if (x == dbuf->tilex-1) tile->sizex = dbuf->sizex - dbuf->tsizex*x; //dbuf->sizex - dbuf->tsizex*(x-1); //tilesize - (tilesize*x - dbuf->sizex);
- else tile->sizex = dbuf->tsizex;
-
- if (y == dbuf->tiley-1) tile->sizey = dbuf->sizey - dbuf->tsizey*y;//tilesize - (tilesize*y - dbuf->sizey);
- else tile->sizey = dbuf->tsizey;
-
- tile->x = x;
- tile->y = y;
-
- 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);
-
- 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);
-
- buckettile = TCS_GetTile(bucketbuf, x, y, 0);
- DSM_DoTile(re, projmat, shb, tile, dbuf, mergescratch, rowscratch,
- buckettile, dbuf->lastbuf, dbuf->lastbufstrand);
-
- _DSM_maketile((TCS_TileBuffer*)dbuf, deepbuffer_pool, (TCS_Tile*)tile);
- }
- }
- }
-
- MEM_freeN(dbuf->s2);
- MEM_freeN(dbuf->s3);
- MEM_freeN(dbuf->lastbuf);
- MEM_freeN(dbuf->lastbufstrand);
- dbuf->lastbuf = NULL;
- dbuf->lastbufstrand = NULL;
-
- /*free bucket buffer*/
- TCS_FreeBuffer(bucketbuf);
-
- MEM_freeN(rowscratch);
- MEM_freeN(mergescratch);
-}
-#endif
-
/* comparison function for qsort, used in DSM_DoTile to sort pixel samples. */
static int dsmvergzvlak(const void *a1, const void *a2)
{
@@ -1934,44 +1819,44 @@
#endif /* #if 0 */
/* ----- static code from zbuf.c ----- */
-static APixstr *addpsmainA(ListBase *lb)
-{
- APixstrMain *psm;
-
- psm= MEM_mallocN(sizeof(APixstrMain), "addpsmainA");
- BLI_addtail(lb, psm);
- psm->ps= MEM_callocN(4096*sizeof(APixstr),"pixstr");
-
- return psm->ps;
+static APixstr *addpsmainA(ListBase *lb)
+{
+ APixstrMain *psm;
+
+ psm= MEM_mallocN(sizeof(APixstrMain), "addpsmainA");
+ BLI_addtail(lb, psm);
+ psm->ps= MEM_callocN(4096*sizeof(APixstr),"pixstr");
+
+ return psm->ps;
+}
+
+static void freepsA(ListBase *lb)
+{
+ APixstrMain *psm, *psmnext;
+
+ for(psm= lb->first; psm; psm= psmnext) {
+ psmnext= psm->next;
+ if(psm->ps)
+ MEM_freeN(psm->ps);
+ MEM_freeN(psm);
+ }
+}
+
+static APixstr *addpsA(ZSpan *zspan)
+{
+ /* make new PS */
+ if(zspan->apsmcounter==0) {
+ zspan->curpstr= addpsmainA(zspan->apsmbase);
+ zspan->apsmcounter= 4095;
+ }
+ else {
+ zspan->curpstr++;
+ zspan->apsmcounter--;
+ }
+ return zspan->curpstr;
}
-static void freepsA(ListBase *lb)
-{
- APixstrMain *psm, *psmnext;
- for(psm= lb->first; psm; psm= psmnext) {
- psmnext= psm->next;
- if(psm->ps)
- MEM_freeN(psm->ps);
- MEM_freeN(psm);
- }
-}
-
-static APixstr *addpsA(ZSpan *zspan)
-{
- /* make new PS */
- if(zspan->apsmcounter==0) {
- zspan->curpstr= addpsmainA(zspan->apsmbase);
- zspan->apsmcounter= 4095;
- }
- else {
- zspan->curpstr++;
- zspan->apsmcounter--;
- }
- return zspan->curpstr;
-}
-
-
/* based on Liang&Barsky, for clipping of pyramidical volume */
static short cliptestf(float p, float q, float *u1, float *u2)
{
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c 2008-02-08 22:09:47 UTC (rev 13612)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c 2008-02-09 00:08:07 UTC (rev 13613)
@@ -3882,8 +3882,12 @@
for (entry=tile->ventries; entry; entry=entry->next) {
for (i=0; i<entry->used; i++) {
+ int oldtotv;
+
obi = &re->objectinstance[entry->obi[i]];
obr = obi->obr;
+
+ oldtotv = obr->totvlak;
if (obr->ob==re->excludeob)
continue;
@@ -3894,6 +3898,9 @@
Mat4CpyMat4(obwinmat, winmat);
vlr = RE_findOrAddVlak(obr, (entry->nr[i]-1) & RE_QUAD_MASK);
+ if (obr->totvlak != oldtotv)
+ printf("Evil! Vlak allocation happened that shouldn't have!\n");
+
if(vlr->mat!=ma) {
ma= vlr->mat;
if((ma->mode & MA_SHADBUF)==0) dofill= 0;
@@ -3972,9 +3979,13 @@
}
for (entry=tile->sentries; entry; entry=entry->next) {
- for (i=0; i<entry->used; i++) {
+ for (i=0; i<entry->used; i++) {
+ int oldtots;
+
obi = &re->objectinstance[entry->obi[i]];
obr = obi->obr;
+
+ oldtots = obr->totstrand;
if (obr->ob==re->excludeob)
continue;
@@ -3985,6 +3996,8 @@
Mat4CpyMat4(obwinmat, winmat);
strand = RE_findOrAddStrand(obr, entry->nr[i]);
+ if (obr->totstrand != oldtots)
+ printf("Strand allocation happened that should'nt have!!\n");
sseg.obi= obi;
sseg.buffer= strand->buffer;
More information about the Bf-blender-cvs
mailing list