[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17903] branches/soc-2007-joeedh/source/ blender: more speed tweaks and improvements, and some bug fixes.

Joseph Eagar joeedh at gmail.com
Wed Dec 17 10:09:34 CET 2008


Revision: 17903
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17903
Author:   joeedh
Date:     2008-12-17 10:09:33 +0100 (Wed, 17 Dec 2008)

Log Message:
-----------
more speed tweaks and improvements, and some bug fixes.  also made dsm use the same buttons for osa that normla shadow buffers do.

Modified Paths:
--------------
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
    branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
    branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_func.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/shadeoutput.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/source/blender/blenkernel/BKE_dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h	2008-12-17 06:00:17 UTC (rev 17902)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h	2008-12-17 09:09:33 UTC (rev 17903)
@@ -97,17 +97,17 @@
 
 #define DSM_FINAL_TILESIZE		50
 #define DSM_TILE_MEMARENASIZE	(1<<16)
-#define DSM_AASAMPLES		(shb->samp > 5? 5: shb->samp)
+#define DSM_AASAMPLES		(shb->osasamp)
 #define DSM_AAWIDTH			1.5f;
 #define DSM_MAXSAMPLES		25
 
-#define DSM_SAMPLEMERGE_LIMIT	(0x7FFFFFFF) //20000000
+#define DSM_SAMPLEMERGE_LIMIT	4000000 //(G.rt*1000000) //((G.rt!=103&&G.rt!=104)?200000000 : 0) //20000000
 
 //angle limit of strands.  is in degrees, so
 //code has to convert.ss
 #define DSM_STRAND_ADAPTCOS 8.0
 
-#define DSM_LINEAR	1
+#define DSM_LINEAR	(G.rt != 102 && G.rt != 103)
 #define DSM_SOFT	0
 #define DSM_VIS		0
 //#define DOQMCDEBUG

Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h	2008-12-17 06:00:17 UTC (rev 17902)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h	2008-12-17 09:09:33 UTC (rev 17903)
@@ -237,7 +237,7 @@
 
 typedef struct ShadBuf {
 	/* regular shadowbuffer */
-	short samp, shadhalostep, totbuf;
+	short samp, osasamp, shadhalostep, totbuf;
 	float persmat[4][4];
 	float viewmat[4][4];
 	float winmat[4][4];

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-12-17 06:00:17 UTC (rev 17902)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-12-17 09:09:33 UTC (rev 17903)
@@ -1000,7 +1000,7 @@
 				
 				/*add the first header samples, which are at -0x7FFFFFF z and
 				  have a visibility of 1.0f.*/
-				for (d=0; d<shb->samp*shb->samp; d++) {
+				for (d=0; d<DSM_AASAMPLES*DSM_AASAMPLES; d++) {
 					for (a=0; a<3; a++) {
 						row[totface].p = -1;
 						row[totface].value = 1.0f;
@@ -1083,13 +1083,6 @@
 						printf("EVVVVIIIL! one: %d, two: %d\n", row[a].depth, row[a+1].depth);
 					}
 					
-					/*for (b=0; b<3; b++) {
-						if (accum[row[a].samplenr][b] < 0.001 && samp_totlayers[row[a].samplenr][b] < dbuf->max_layers) {
-							samp_totlayers[row[a].samplenr][b] += 1;
-							accum[row[a].samplenr][b] = 1.0f;
-						}
-					}*/
-					
 					if (accum[row[a].samplenr][0] > 0.001 || accum[row[a].samplenr][1] > 0.001 || accum[row[a].samplenr][2] > 0.001) {
 						float clr[4];
 
@@ -1145,8 +1138,12 @@
 							}
 						} else if (row[a].type == DSM_FACE) {
 							float sco[3];
-							sco[0] = (float)(x+tile->x*dbuf->tsizex) + shb->jit[2*row[a].samplenr]*shb->soft + 0.5f;
-							sco[1] = (float)(y+tile->y*dbuf->tsizey) + shb->jit[2*row[a].samplenr+1]*shb->soft + 0.5f;
+							sco[0] = (float)(x+tile->x*dbuf->tsizex)
+							         + shb->jit[2*row[a].samplenr]
+								 * shb->soft + 0.5f;
+							sco[1] = (float)(y+tile->y*dbuf->tsizey)
+							         + shb->jit[2*row[a].samplenr+1]
+								 * shb->soft + 0.5f;
 							sco[2] = row[a].depth;
 
 							vlak =  RE_findOrAddVlak(re->objectinstance[row[a].obi].obr, (row[a].p-1) & RE_QUAD_MASK);

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_func.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_func.c	2008-12-17 06:00:17 UTC (rev 17902)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_func.c	2008-12-17 09:09:33 UTC (rev 17903)
@@ -89,8 +89,8 @@
 #define COMPSTATE_DONE			3
 
 void DSM_MergeLayerListNew(DSMTile *tile, int x, int y, _ClrEntry *row, ListBase (*transfuncs)[3],
-								   int totface, void *scratchmem1, void *scratchmem2, void *scratchmem3,
-								   int scratchlen, float *weight, int samplewid, float error)
+                           int totface, void *scratchmem1, void *scratchmem2, void *scratchmem3,
+                           int scratchlen, float *weight, int samplewid, float error)
 {
 	DSMFunction *func[3];
 	DSMLayerSample *cursamp[3]={NULL, NULL, NULL}, *samp;
@@ -101,7 +101,7 @@
 	double startpoint[3] = {-1.0, -1.0, -1.0}, endpoint[3] = {-1.0, -1.0, -1.0}, err=error; // /2.0;
 	int i, ci, totfaces[3] = {0, 0, 0}, cursor[3]={0, 0, 0};
 	int state[3] = {COMPSTATE_PROCESSING, COMPSTATE_PROCESSING, COMPSTATE_PROCESSING};
-	int totface2[3] = {0, 0, 0}, count[3]={0, 0, 0};
+	int totface2[3] = {0, 0, 0}, count[3]={0, 0, 0}, done = 0;
 
 	/*first alloc, then assign, as internally the function
 	  array may be reallocated to increase its size (thus invalidating
@@ -144,6 +144,8 @@
 	/*we add 1 to totface to compensate for how compression must lag behind merging.*/
 	for (i=0, csamp=row; i<totface; i++, csamp++) {
 		ci = csamp->index;
+		if (done & (1<<(ci+3))) continue;
+
 		BASSERT(ci >= 0 && ci < 3);
 		samp = func[ci]->samples + totfaces[ci];
 
@@ -158,7 +160,8 @@
 		if (samp->depth > func[ci]->zmax) func[ci]->zmax = csamp->depth;
 		if (samp->depth < func[ci]->zmin) func[ci]->zmin = csamp->depth;
 
-		if (lastcsamp[ci]) accum[ci] = accum[ci] + (double)(csamp->depth-lastcsamp[ci]->depth)*slope[ci];
+		if (lastcsamp[ci]) 
+			accum[ci] = accum[ci] + (double)(csamp->depth-lastcsamp[ci]->depth)*slope[ci];
 		samp->value = (float) accum[ci];
 		
 		if (csamp->next && csamp->next->depth == csamp->depth) {
@@ -167,10 +170,12 @@
 
 		if (csamp->next) {
 			if (csamp->next->depth != csamp->depth) {
-				s2 = ((double)(csamp->next->value - csamp->value)) / (double)(csamp->next->depth - csamp->depth);
+				s2 = ((double)(csamp->next->value - csamp->value))
+				     / (double)(csamp->next->depth - csamp->depth);
 				if (csamp->prev) {
 					if (csamp->prev->depth != csamp->depth) {
-						s1 = ((double)(csamp->value - csamp->prev->value)) / (double)(csamp->depth - csamp->prev->depth);
+						s1 = ((double)(csamp->value - csamp->prev->value)) 
+						      / (double)(csamp->depth - csamp->prev->depth);
 						slope[ci] += weight[csamp->samplenr]*(s2 - s1);
 					} else {
 						slope[ci] += weight[csamp->samplenr]*s2;
@@ -190,12 +195,15 @@
 				if (csamp->prev->depth == csamp->depth) {
 					//accum[ci] += weight[csamp->samplenr]*(csamp->value-csamp->prev->value);
 				} else {
-					s1 = ((double)(csamp->value - csamp->prev->value)) / (double)(csamp->depth - csamp->prev->depth);
+					s1 = ((double)(csamp->value - csamp->prev->value)) 
+					/ (double)(csamp->depth - csamp->prev->depth);
+
 					slope[ci] -= weight[csamp->samplenr]*s1;
 				}
-			}			
+			}
 		}
-
+		
+		
 		if (accum[ci] < -0.001f) {
 			printf("EVIL! accum: %f\n", accum[ci]);
 			accum[ci] = 0.0f;
@@ -206,82 +214,16 @@
 		}
 
 		lastcsamp[ci] = csamp;
-
 		totfaces[ci]++;
 		
-		/*
-		//continue;
-		//compression has to lag behind merging by 1 samples.
-		if (totfaces[ci] <= 1) continue;
-
-		if (state[ci] == COMPSTATE_PROCESSING) {
-			*cursamp[ci] = sout[ci][cursor[ci]];
-			
-			//store the number of original samples between this one and
-			//the last, this is actually used by the (probably coded post-
-			//GSoC) soft shadow method.
-			cursamp[ci]->orig_totsamples = 0;
-
-			if (state[ci] != COMPSTATE_DONE && cursor[ci] >= totfaces[ci]) { //func[ci]->totsamples - 1) {
-				totface2[ci]++;
-				state[ci] = COMPSTATE_DONE;
-				continue;
-			}
-
-			start[ci] = (sout[ci][cursor[ci]+1].value+err) - cursamp[ci]->value;
-			end[ci]   = (sout[ci][cursor[ci]+1].value-err) - cursamp[ci]->value;
-			if (sout[ci][cursor[ci]+1].depth != cursamp[ci]->depth) {
-				start[ci] /= (double)(sout[ci][cursor[ci]+1].depth - cursamp[ci]->depth);
-				end[ci]   /= (double)(sout[ci][cursor[ci]+1].depth - cursamp[ci]->depth);
-			}
-			cursor[ci] += 1;
-
-			state[ci] = COMPSTATE_COMPRESSING;
+		if (done == 32) break;
+		if (done & (1<<ci)) {
+			done |= (1<<(ci+3));
 		}
-		
-		if (state[ci] == COMPSTATE_COMPRESSING) {
-			ostartpoint[ci] = startpoint[ci];
-			oendpoint[ci] = endpoint[ci];
-			if (sout[ci][cursor[ci]].depth == cursamp[ci]->depth) {
-				//startpoint = cursamp->value + err;
-				//endpoint = cursamp->value - err;
-				break;
-			} else {
-				startpoint[ci] = cursamp[ci]->value + start[ci] * (double)(sout[ci][cursor[ci]].depth - cursamp[ci]->depth);
-				endpoint[ci]   = cursamp[ci]->value + end[ci] * (double)(sout[ci][cursor[ci]].depth - cursamp[ci]->depth);
-			}
-			if (startpoint[ci] > sout[ci][cursor[ci]].value && endpoint[ci] < sout[ci][cursor[ci]].value) {
-				if (startpoint[ci] > sout[ci][cursor[ci]].value+err) {
-					start[ci] = (sout[ci][cursor[ci]].value+err) - cursamp[ci]->value;
-					if (sout[ci][cursor[ci]].depth != cursamp[ci]->depth) {
-						start[ci] /= (double)(sout[ci][cursor[ci]].depth - cursamp[ci]->depth);
-					}
-				}
-				if (endpoint[ci] < sout[ci][cursor[ci]].value-err) {
-					end[ci] = (sout[ci][cursor[ci]].value-err) - cursamp[ci]->value;
-					if (sout[ci][cursor[ci]].depth != cursamp[ci]->depth) {
-						end[ci] /= (double)(sout[ci][cursor[ci]].depth - cursamp[ci]->depth);
-					}
-				}	
-			} else {
-				cursor[ci] -= 1;
-				state[ci] = COMPSTATE_PROCESSING2;
-			}
-			cursamp[ci]->orig_totsamples++;
-			cursor[ci] += 1;
+		if (accum[ci] < 0.005) {
+			done |= 1<<ci;			
+			//all functions have hit zero visibility.
 		}
-
-		if (state[ci] == COMPSTATE_PROCESSING2) {
-			cursamp[ci]++;
-			totface2[ci]++;
-
-			if (cursor[ci] >= func[ci]->totsamples) {
-				*cursamp[ci] = sout[ci][totfaces[ci]-1]; //samp[func->totsamples-1];
-				cursamp[ci]++;
-				totface2[ci]++;
-			}
-			state[ci] = COMPSTATE_PROCESSING;
-		}*/
 	}
 	
 
@@ -292,8 +234,6 @@
 		if (totfaces[i]==1) totface2[i] = 1;
 
 		func[i]->totsamples = totface2[i];
-		//func[i]->samples = BLI_memarena_alloc(tile->arena, sizeof(DSMLayerSample)*totface2[i]);
-		//memcpy(func[i]->samples, sout[i], sizeof(DSMLayerSample)*totface2[i]);
 		BASSERT(accum[i] < 1.0001);
 		
 		DSM_CompressFunction(tile->arena, func[i], error);
@@ -523,6 +463,8 @@
 
 		lastcsamp = csamp;
 		func->totsamples++;
+
+		if (accum < 0.005) break;
 	}
 	
 	BASSERT(accum < 1.0001);
@@ -570,4 +512,4 @@
 		zspan->apsmcounter--;
 	}
 	return zspan->curpstr;
-}
\ No newline at end of file
+}


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list