[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34023] trunk/blender/source/blender: avoid int/ float comparisons within a number of for loops in deep shadow map compression .

Campbell Barton ideasman42 at gmail.com
Mon Jan 3 07:13:51 CET 2011


Revision: 34023
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34023
Author:   campbellbarton
Date:     2011-01-03 07:13:50 +0100 (Mon, 03 Jan 2011)

Log Message:
-----------
avoid int/float comparisons within a number of for loops in deep shadow map compression.
gives minor overall speedup.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/render/render_preview.c
    trunk/blender/source/blender/render/intern/source/shadbuf.c

Modified: trunk/blender/source/blender/editors/render/render_preview.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_preview.c	2011-01-03 06:08:17 UTC (rev 34022)
+++ trunk/blender/source/blender/editors/render/render_preview.c	2011-01-03 06:13:50 UTC (rev 34023)
@@ -1030,7 +1030,7 @@
 
 	/* handle results */
 	if(sp->pr_method==PR_ICON_RENDER) {
-		char *rct= (char *)(sp->pr_rect + 32*16 + 16);
+		// char *rct= (char *)(sp->pr_rect + 32*16 + 16);
 		
 		if(sp->pr_rect)
 			RE_ResultGet32(re, sp->pr_rect);

Modified: trunk/blender/source/blender/render/intern/source/shadbuf.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/shadbuf.c	2011-01-03 06:08:17 UTC (rev 34022)
+++ trunk/blender/source/blender/render/intern/source/shadbuf.c	2011-01-03 06:13:50 UTC (rev 34023)
@@ -300,8 +300,14 @@
 	DeepSample *ds[RE_MAX_OSA], *sampleds[RE_MAX_OSA], *dsb, *newbuf;
 	APixstr *ap, *apn;
 	APixstrand *aps, *apns;
-	float visibility, totbuf= shb->totbuf;
-	int a, b, c, tot, minz, found, size= shb->size, prevtot, newtot;
+	float visibility;
+
+	const int totbuf= shb->totbuf;
+	const float totbuf_f= (float)shb->totbuf;
+	const float totbuf_f_inv= 1.0f/totbuf_f;
+	const int size= shb->size;
+
+	int a, b, c, tot, minz, found, prevtot, newtot;
 	int sampletot[RE_MAX_OSA], totsample = 0, totsamplec = 0;
 	
 	shsample= MEM_callocN( sizeof(ShadSampleBuf), "shad sample buf");
@@ -456,9 +462,9 @@
 				}
 
 				if(sampleds[c] == ds[c])
-					visibility += 1.0f/totbuf;
+					visibility += totbuf_f_inv;
 				else
-					visibility += (ds[c]-1)->v/totbuf;
+					visibility += (ds[c]-1)->v / totbuf_f;
 			}
 
 			dsb->v= visibility;





More information about the Bf-blender-cvs mailing list