[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15711] branches/soc-2007-joeedh/source/ blender: update, ui fixes, speedup in dsm lookup

Joseph Eagar joeedh at gmail.com
Wed Jul 23 13:50:51 CEST 2008


Revision: 15711
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15711
Author:   joeedh
Date:     2008-07-23 13:50:51 +0200 (Wed, 23 Jul 2008)

Log Message:
-----------
update, ui fixes, speedup in dsm lookup

Modified Paths:
--------------
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h
    branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.h
    branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h
    branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/rendercore.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
    branches/soc-2007-joeedh/source/blender/src/usiblender.c

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h	2008-07-23 10:19:08 UTC (rev 15710)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_blender.h	2008-07-23 11:50:51 UTC (rev 15711)
@@ -41,7 +41,7 @@
 struct MemFile;
 
 #define BLENDER_VERSION			246
-#define BLENDER_SUBVERSION		0
+#define BLENDER_SUBVERSION		20
 
 #define BLENDER_MINVERSION		245
 #define BLENDER_MINSUBVERSION	15

Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.h	2008-07-23 10:19:08 UTC (rev 15710)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.h	2008-07-23 11:50:51 UTC (rev 15711)
@@ -72,5 +72,6 @@
 QMCINLINE int adaptive_sample_contrast_val(int samples, float prev, float val, float thresh);
 QMCINLINE float get_avg_speed(struct ShadeInput *shi);
 QMCINLINE int adaptive_sample_variance(int samples, float *col, float *colsq, float thresh);
+QMCSampler *get_thread_qmcsampler(Render *re, int thread, int type, int tot);
 
 #endif /* QMC_H */

Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h	2008-07-23 10:19:08 UTC (rev 15710)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h	2008-07-23 11:50:51 UTC (rev 15711)
@@ -33,7 +33,6 @@
 #define SHADBUF_EXT_H
 
 #include "render_types.h"
-#include "BKE_dsm.h"
 
 struct ObjectRen;
 
@@ -67,16 +66,7 @@
 struct MemArena;
 struct APixstr;
 
-/**
- * Deep Shadow Buffer
- */
 
-void DSM_getSoftShadow(ShadBuf *shb, struct ShadeInput *shi, LampRen *lar, float *rco, float *dxco, float *dyco, float inp, float *shadowclr);
-float DSM_getShadow(ShadBuf *buf, float *rco, float *dxco, float *dyco, float inp, int component);
-float DSM_getBilinearShadow(ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp, int component);
-float DSM_sampleMap(ShadBuf *shb, int xs, int ys, int zs, int bias, float inp, int component);
-
-
 /**
  * Irregular shadowbuffer
  */

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-07-23 10:19:08 UTC (rev 15710)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-07-23 11:50:51 UTC (rev 15711)
@@ -65,6 +65,7 @@
 #include "sss.h"
 #include "zbuf.h"
 #include "qmc.h"
+#include "dsm.h"
 
 #include "MEM_guardedalloc.h"
 
@@ -79,46 +80,6 @@
 extern Render R;
 static TCS_TilePool *deepbuffer_pool = NULL;
 
-/* prototypes */
-struct _ClrEntry;
-void DSM_DoTile(Render *re, float projmat[4][4], ShadBuf *shb, DSMTile *tile, 
-				DSMBuffer *dbuf, RE_BucketTile *btile, int threadnr, float viewinv[4][4]);
-
-int zbuffer_dsm(Render *re, RenderPart *pa, float winmat[4][4], APixstr **lastbuf, 
-				APixstr **lastbufstrand, APixstr *APixbuf, APixstr *APixbufstrand, 
-				ListBase *apsmbase, unsigned int lay, ShadBuf *shb, 
-				RE_BucketTile *buckettile);
-
-static APixstr *addpsmainA(ListBase *lb);
-static void freepsA(ListBase *lb);
-static APixstr *addpsA(ZSpan *zspan);
-
-/* Modified zbufclipwire from zbuf.c
-  v1 and v2 are in homogenous coordinates.  returns true if 
-  drawing should happen.  v1 and v2 are modified (clipped).*/
-int DSM_zbufclipwire(float clipsta, float clipend, int rectx, int recty, float *v1, float *v2);
-
-#define DSM_NONE			0
-#define DSM_FACE			1
-#define DSM_FACE_STEP		2
-#define DSM_STRAND			3
-#define DSM_STRAND_STEP		4
-#define DSM_VOLUME_SAMPLE	5
-
-/*internal structures*/
-typedef struct _ClrEntry {
-	struct _ClrEntry *next, *prev;
-	ListBase *srclist;
-	int depth;
-	int p;
-	int mask;
-	int obi;
-	int type;
-	int samplenr;
-	float value;
-	int index; /* color component index */
-} _ClrEntry;
-
 void DSM_MakeTilePool(int maxbytes)
 {
 	deepbuffer_pool = TCS_MakePool(maxbytes, "dsm");
@@ -216,6 +177,7 @@
 	return g_break;
 }
 
+/*used after retransforming the renderscene*/
 void DSM_set_imats(Render *re)
 {
 	Base *base;
@@ -229,8 +191,15 @@
 	}
 }
 
-/*this function not based off the envmap equavilent env_rotate_scene, 
-  which turned out not to work at all for the purpose, for some reason*/
+/*like envmap, dsm performs material evaluation.  since the render data
+  is pre-rotated into camera space, it must be unrotated and rerotated
+  to lamp space in order for dsm to render correctly.  after the dsm
+  map has finished rendering, the scene is rerotated back into camera
+  space (note this happens for every dsm map in the scene individually).
+
+  this function is not based off the envmap equavilent env_rotate_scene, 
+  which turned out not to work at all, though I can't figure out why
+  it works for envmap but not for dsm.*/
 static void retransform_renderscene(Render *re, float newview[4][4], float oldview[4][4], ShadBuf *buf, int mode)
 {
 	VlakRen *vlak;
@@ -265,11 +234,10 @@
 	}
 }
 
-/* copied and trimmed down from env_copy_render()*/
+/* initialize the dsm render data.
+   copied and trimmed down from env_copy_render()*/
 static Render *init_dsm_render(Render *re, Render *envre, ShadBuf *shb)
 {
-	int cuberes;
-
 	/* this flag has R_ZTRA in it for example */
 	envre->flag= re->flag;
 	
@@ -288,14 +256,16 @@
 
 	envre->clipsta= shb->clipsta;
 	envre->clipend= shb->clipend;
+
+	return envre;
 }
 
 #define MAX(x, y) (x) > (y) ? (x) : (y)
 
+/*make a visualization of a dsm map for debugging purposes.*/
 static ImBuf *dsm_make_vis_imbuf(DSMBuffer *buf)
 {
 	DSMTile *tile;
-	DSMFunction *func;
 	ImBuf *imbuf = NULL;
 	int maxsamples[3]={1, 1, 1};
 	int x, y, x2, y2, sx=buf->sizex, sy=buf->sizey;
@@ -347,9 +317,11 @@
 	Render *re2 = MEM_callocN(sizeof(Render), "Render");
 	DeepThreadData thread_data[BLENDER_MAX_THREADS];
 	float fac, shbview[4][4], review[4][4], mat[4][4];
-	int x, y, lastsizex, lastsizey, stop=0;
+	int x, y, lastsizex, lastsizey, stop=0, done=0, lastdone=0;
 	int mergescratchlen, lay = (1<<20)-1;
-	
+	char rendertitle[300];
+	rendertitle[0] = 0;
+
 	/*use 30,000 max elements per pixel for the 4*total_threads
 	  preallocated pixel arrays DSM_DoTile() allocates.  the *6
 	  iirc is because the visibilty function calculation
@@ -530,14 +502,24 @@
 
 		while (!stop && (g_break=re->test_break())==0) {
 			stop = 1;
+			done = 0;
 			for (threadtile=threadtiles.first; threadtile; threadtile=threadtile->next) {
 				/*we shouldn't need to lock this, since thread conflicts arnen't going
 				  to cause anything bad to happen, other then perhaps 1 extra loop iteration.*/
 				if (threadtile->ready==0) {
 					stop = 0;
-					break;
+				} else {
+					done += 1;
 				}
 			}
+			if (done != lastdone) {
+				printf("bleh!\n");
+				sprintf(rendertitle, "Shadow tiles %d out of %d completed", done, dbuf->tilex*dbuf->tiley);
+				re->i.infostr= rendertitle;
+				re->stats_draw(&re->i);
+				re->i.infostr= NULL;
+			}
+			lastdone = done;
 			PIL_sleep_ms(300);
 		}
 
@@ -586,6 +568,7 @@
 	}
 }
 
+/*this is used to shade a dsm pixel sample.*/
 static void shade_dsmsample(Render *re, VlakRen *vlr, int facenr, int obi,
 							float *diff, float *screenco, ShadBuf *buf,
 							Material *mat, float viewinv[4][4], int thread)
@@ -691,468 +674,10 @@
 	}
 }
 
-static void DSM_CompressFunction(MemArena *arena, DSMFunction *func, float error);
 
-/*The Loop of Doom.
-  One loop to merge them all, One loop to find them;
-  One loop to compress them all, and in the darkness, bind them!*/
-#define COMPSTATE_PROCESSING	0
-#define COMPSTATE_PROCESSING2	1
-#define COMPSTATE_COMPRESSING	2
-#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)
-{
-	DSMFunction *func[3];
-	DSMLayerSample *cursamp[3]={NULL, NULL, NULL}, *samp;
-	DSMLayerSample *sout[3] = {scratchmem1, scratchmem2, scratchmem3};
-	_ClrEntry *csamp, *lastcsamp[3]={NULL, NULL, NULL};
-	double slope[3]={0.0, 0.0, 0.0}, accum[3] = {1.0, 1.0, 1.0}, s1, s2;
-	double start[3], end[3], ostartpoint[3], oendpoint[3];
-	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};
-
-	/*first alloc, then assign, as internally the function
-	  array may be reallocated to increase its size (thus invalidating
-	  existing pointers).*/
-	for (i=0; i<3; i++) {
-		switch (i) {
-			case 0:
-				dsm_function_alloc(tile, &tile->r_rect[y*tile->sizex+x]);
-				break;
-			case 1:
-				dsm_function_alloc(tile, &tile->g_rect[y*tile->sizex+x]);
-				break;
-			case 2:
-				dsm_function_alloc(tile, &tile->b_rect[y*tile->sizex+x]);
-				break;
-		}
-	}
-
-	for (i=0; i<3; i++) {
-		switch (i) {
-			case 0:
-				func[i] = &tile->funcarray[tile->r_rect[y*tile->sizex+x]];
-				break;
-			case 1:
-				func[i] = &tile->funcarray[tile->g_rect[y*tile->sizex+x]];
-				break;
-			case 2:
-				func[i] = &tile->funcarray[tile->b_rect[y*tile->sizex+x]];
-				break;
-		}
-		memset(func[i], 0, sizeof(DSMFunction));
-
-		func[i]->samples = (DSMLayerSample*) sout[i];
-		cursamp[i] = sout[i];
-		func[i]->totsamples = 0;
-		func[i]->zmin = 0x7FFFFFFF;
-		func[i]->zmax = -0x7FFFFFFF;
-	}
-
-	/*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;
-		BASSERT(ci >= 0 && ci < 3);
-		samp = func[ci]->samples + totfaces[ci];
-
-		/*we've hit a sample in one of the other rgb color component
-		  visibility functions, or we've hit an excluded sample, so continue*/
-		if (!csamp->srclist) {
-			continue;
-		}
-
-		samp->orig_totsamples = 0;
-		samp->depth = csamp->depth;
-		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];

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list