[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15963] branches/soc-2007-joeedh/source/ blender: commit of working copy code

Joseph Eagar joeedh at gmail.com
Tue Aug 5 02:59:45 CEST 2008


Revision: 15963
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15963
Author:   joeedh
Date:     2008-08-05 02:59:44 +0200 (Tue, 05 Aug 2008)

Log Message:
-----------
commit of working copy code

Modified Paths:
--------------
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
    branches/soc-2007-joeedh/source/blender/render/intern/include/dsm.h
    branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.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_soft.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/pipeline.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/shadeoutput.c

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h	2008-08-04 23:27:06 UTC (rev 15962)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h	2008-08-05 00:59:44 UTC (rev 15963)
@@ -104,7 +104,7 @@
 
 //angle limit of strands.  is in degrees, so
 //code has to convert.ss
-#define DSM_STRAND_ADAPTCOS 15.0
+#define DSM_STRAND_ADAPTCOS 8.0
 
 #define DSM_LINEAR	1
 #define DSM_SOFT	0

Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/dsm.h	2008-08-04 23:27:06 UTC (rev 15962)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/dsm.h	2008-08-05 00:59:44 UTC (rev 15963)
@@ -56,7 +56,7 @@
 } _ClrEntry;
 
 
-void DSM_getSoftShadow(ShadBuf *shb, struct ShadeInput *shi, LampRen *lar, float *rco, float *dxco, float *dyco, float inp, float *shadowclr);
+void DSM_getSoftShadow(Render *re, 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);

Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.h	2008-08-04 23:27:06 UTC (rev 15962)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/qmc.h	2008-08-05 00:59:44 UTC (rev 15963)
@@ -73,5 +73,6 @@
 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);
+void release_thread_qmcsampler(Render *re, int thread, QMCSampler *qsa);
 
 #endif /* QMC_H */

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-08-04 23:27:06 UTC (rev 15962)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h	2008-08-05 00:59:44 UTC (rev 15963)
@@ -543,5 +543,9 @@
 #define R_TRANSFORMED		(1|2)
 #define R_NEED_VECTORS		4
 
+//set this to 1 to use the main thread
+//if threads == 1, for e.g. profiling purposes.
+#define RE_USE_MAIN_THREAD 1
+
 #endif /* RENDER_TYPES_H */
 

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-08-04 23:27:06 UTC (rev 15962)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-08-05 00:59:44 UTC (rev 15963)
@@ -584,8 +584,8 @@
 		ImBuf *visbuf = dsm_make_vis_imbuf(shb->dsmbuffer);
 		visbuf->ftype |= PNG;
 		IMB_saveiff(visbuf, "dsm_vis.png", 0);
-		MEM_freeN(visbuf->rect_float);
-		visbuf->rect_float = NULL;
+		MEM_freeN(visbuf->rect_float);
+		visbuf->rect_float = NULL;
 		IMB_freeImBuf(visbuf);
 	}
 }
@@ -642,13 +642,6 @@
 	shade_input_set_viewco(&shi, screenco[0], screenco[1], screenco[2]);
 	Normalize(shi.view);
 	
-	/*{
-		//float inv[4][4];
-		//MTC_Mat4Invert(inv, viewinv);
-		//MTC_Mat4MulVecfl(inv, shi.co);
-		//memset(shi.co, 0, sizeof(float)*4*4);
-	}*/
-
 	// Osa structs we leave unchanged now
 	SWAP(int, osatex, shi.osatex);
 
@@ -1155,11 +1148,11 @@
 							clr[1] = ssamp.shr[0].diff[1];
 							clr[2] = ssamp.shr[0].diff[2];
 							clr[3] = ssamp.shr[0].alpha;
-							
-							if (G.rt == 26) {
-								printf("clr rgba %f %f %f %f\n", clr[0], clr[1], clr[2], clr[3]);
-								printf("rgba %f %f %f %f\n", ssamp.shr->diff[0], ssamp.shr->diff[1], ssamp.shr->diff[2], ssamp.shr->alpha);
-							}
+							
+							if (G.rt == 26) {
+								printf("clr rgba %f %f %f %f\n", clr[0], clr[1], clr[2], clr[3]);
+								printf("rgba %f %f %f %f\n", ssamp.shr->diff[0], ssamp.shr->diff[1], ssamp.shr->diff[2], ssamp.shr->alpha);
+							}
 						} 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;
@@ -1268,12 +1261,10 @@
 }
 #define lerp flerp3i
 
-//float *dsm_bsearch(DSMSample *sample, int zs, int bias);
-
 float DSM_getBilinearShadow(ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp, int component)
 {
 	DSMBuffer *buf = shb->dsmbuffer;
-	float fac, co[4], d, siz; //, *clr; //*jit, *weight, *rz,  note: these three might be needed, look into it
+	float fac, co[4], d, siz;
 	float xs, ys, a, b, res;
 	int zs, bias;
 	float corners[4];
@@ -1424,7 +1415,7 @@
 	DSMBuffer *buf = shb->dsmbuffer;
 	DSMLayerSample *sample = NULL;
 	DSMFunction *func = NULL;
-	float alpha; //, *clr; //*jit, *weight, *rz,  note: these three might be needed, look into it
+	float alpha;
 	int newbias, tilex, tiley, i;
 
 	/* with inp==1.0, bias is half the size. correction value was 1.1, giving errors
@@ -1553,13 +1544,8 @@
 	}
 
 	samp = &func->samples[i];
-/*	if ((i == 0 && z < samp->depth+bias) || func->totsamples == 1) return samp->value;
-	if ((i == func->totsamples-1 && z > samp->depth+bias) || func->totsamples == 1) return samp->value;
+	samp2 = z < samp->depth+bias ? samp - 1 : samp + 1;
 	
-	if (i == 0) samp2 = &func->samples[1];
-	else if (i == func->totsamples-1) samp2 = &func->samples[func->totsamples-2];
-	else */ samp2 = z < samp->depth+bias ? samp - 1 : samp + 1;
-	
 	if (samp2 < func->samples || samp2 >= func->samples+func->totsamples) return samp->value;
 	
 	/*swap if samp2 is less than samp in memory*/
@@ -1570,5 +1556,5 @@
 	}
 
 	return lerp(samp->depth+bias, samp2->depth+bias, z, samp->value, samp2->value);
-}
-
+}
+

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_soft.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_soft.c	2008-08-04 23:27:06 UTC (rev 15962)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_soft.c	2008-08-05 00:59:44 UTC (rev 15963)
@@ -85,7 +85,7 @@
 static void DSM_ProcessPixel(DSMFunction *func, int index, int zenter, int zexit, float *shadclr, int bias)
 {
 	DSMLayerSample *samp;
-	int zthresh = G.rt*20000; // 20000000; //bias/4;
+	int zthresh = bias/2; //G.rt*20000; // 20000000; //bias/4;
 	int i;
 	
 	if (!func) return;
@@ -279,7 +279,7 @@
 	v2[2] = v1[2] + vec[2]*t;
 }
 
-void DSM_getSoftShadow(ShadBuf *shb, ShadeInput *shi, LampRen *lar, float *rco, float *dxco, float *dyco, float inp, float *shadowclr)
+void DSM_getSoftShadow(Render *re, ShadBuf *shb, ShadeInput *shi, LampRen *lar, float *rco, float *dxco, float *dyco, float inp, float *shadowclr)
 {
 	DSMBuffer *buf = shb->dsmbuffer;
 	QMCSampler *qsa=NULL;
@@ -413,6 +413,7 @@
 		 * for anti-aliasing sharp shadow edges. */
 		VECCOPY(pos, shi->co);
 		
+		/*
 		if (shi->vlr && !full_osa) {
 			QMC_sampleRect(jit, qsa_jit, shi->thread, samples, 1.0, 1.0);
 			
@@ -420,6 +421,7 @@
 			pos[1] += shi->dxco[1]*jit[0] + shi->dyco[1]*jit[1];
 			pos[2] += shi->dxco[2]*jit[0] + shi->dyco[2]*jit[1];
 		}
+		*/
 
 		if (do_soft) {
 			/* sphere shadow source */
@@ -462,8 +464,9 @@
 		VECCOPY(raystart, pos);		
 		
 		/* trace the ray */
+		MTC_Mat4MulVecfl(re->viewinv, raystart);
 		MTC_Mat4MulVecfl(shb->viewmat, raystart);
-
+		
 		VecClipLine3f(raystart, sco, 2, -shb->clipsta-0.06f);
 		
 		//BSE_Add3DVisPoint(raystart, BSE_Yellow, 0);
@@ -531,10 +534,10 @@
 		shadclr[2] *= div;
 	}
 
-	if (qsa_jit) QMC_freeSampler(qsa_jit);
-	if ((qsa) && (qsa->type == SAMP_TYPE_HALTON)) QMC_freeSampler(qsa);
-	
 	VECCOPY(shadowclr, shadclr);
+	if (qsa) release_thread_qmcsampler(&R, shi->thread, qsa);
+	if (qsa_jit) release_thread_qmcsampler(&R, shi->thread, qsa_jit);
+
 	//BSE_PopMatrix();
 #else
 {

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/pipeline.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/pipeline.c	2008-08-04 23:27:06 UTC (rev 15962)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/pipeline.c	2008-08-05 00:59:44 UTC (rev 15963)
@@ -1493,7 +1493,7 @@
 		}
 	}
 	
-	BLI_init_threads(&threads, do_part_thread, re->r.threads);
+	if (re->r.threads > 1) BLI_init_threads(&threads, do_part_thread, re->r.threads);
 	
 	/* assuming no new data gets added to dbase... */
 	R= *re;
@@ -1506,69 +1506,107 @@
 		nextpa= find_next_pano_slice(re, &minx, &viewplane);
 	else
 		nextpa= find_next_part(re, 0);
-	
-	while(rendering) {
-		
-		if(re->test_break())
-			PIL_sleep_ms(50);
-		else if(nextpa && BLI_available_threads(&threads)) {
-			drawtimer= 0;
-			nextpa->nr= counter++;	/* for nicest part, and for stats */
-			nextpa->thread= BLI_available_thread_index(&threads);	/* sample index */
-			BLI_insert_thread(&threads, nextpa);
 
-			nextpa= find_next_part(re, minx);
+	if (re->r.threads == 1 && RE_USE_MAIN_THREAD) {
+		while (rendering) {
+			if (re->test_break()) {
+				break;
+			} else if (nextpa) {
+				nextpa->nr= counter++;
+				nextpa->thread= 0;
+				
+				do_part_thread(nextpa);
+
+				if(re->r.mode & R_PANORAMA)
+					nextpa= find_next_pano_slice(re, &minx, &viewplane);
+				else
+					nextpa= find_next_part(re, 0);
+			}
+
+			/* check for ready ones to display, and if we need to continue */
+			rendering= 0;
+			hasdrawn= 0;
+			for(pa= re->parts.first; pa; pa= pa->next) {
+				if(pa->ready) {					
+					if(pa->result) {
+						if(render_display_draw_enabled(re))
+							re->display_draw(pa->result, NULL);
+						print_part_stats(re, pa);
+						
+						free_render_result(&pa->fullresult, pa->result);
+						pa->result= NULL;
+						re->i.partsdone++;
+						hasdrawn= 1;
+					}
+				}
+				else {
+					rendering= 1;
+				}
+			}		
 		}
-		else if(re->r.mode & R_PANORAMA) {
-			if(nextpa==NULL && BLI_available_threads(&threads)==re->r.threads)
-				nextpa= find_next_pano_slice(re, &minx, &viewplane);
+	} else {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list