[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15036] branches/soc-2008-unclezeiv/source /blender/render/intern/source/lightcuts.c: Optimization: the pool of cut nodes is now allocated only once per rendering, instead of once per sample.

Davide Vercelli davide.vercelli at gmail.com
Thu May 29 02:15:19 CEST 2008


Revision: 15036
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15036
Author:   unclezeiv
Date:     2008-05-29 02:15:17 +0200 (Thu, 29 May 2008)

Log Message:
-----------
Optimization: the pool of cut nodes is now allocated only once per rendering, instead of once per sample. Threading has been taken into account.

Modified Paths:
--------------
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c

Modified: branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c	2008-05-28 23:41:47 UTC (rev 15035)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c	2008-05-29 00:15:17 UTC (rev 15036)
@@ -91,6 +91,9 @@
 	float error_rate;
 	int max_lights;
 	int max_cut;
+	
+	CutNode *cut_nodes;
+	int cut_nodes_size;
 } LightcutsData;
 
 #define VEC_LEN_SQ(v) (v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
@@ -431,6 +434,9 @@
 		lightcuts_fill_array(lcd, pointlights);
 		lightcuts_build_tree(lcd);
 	}
+	
+	lcd->cut_nodes_size= (lcd->max_lights * 2 + 1);
+	lcd->cut_nodes= MEM_callocN(sizeof(CutNode) * lcd->cut_nodes_size * re->r.threads, "cut_nodes");
 }
 
 /* error bound: geometric term */
@@ -482,7 +488,7 @@
 	float totest[3]= {0.0f, 0.0f, 0.0f};
 	float totest_noshad[3]= {0.0f, 0.0f, 0.0f};
 	
-	cut_nodes= MEM_callocN(sizeof(CutNode) * (lcd->max_lights * 2 + 1), "cut_nodes");
+	cut_nodes= lcd->cut_nodes + shi->thread * lcd->cut_nodes_size;
 	
 	{
 		CutNode *root= &cut_nodes[0];
@@ -605,8 +611,6 @@
 	}
 	
 	BLI_heap_free(cut, 0);
-	
-	MEM_freeN(cut_nodes);
 }
 
 void lightcuts_free(LightcutsData **p)
@@ -616,6 +620,7 @@
 		if (lcd->array_local)
 			MEM_freeN(lcd->array_local);
 		BLI_freelistN(&lcd->pointlights);
+		MEM_freeN(lcd->cut_nodes);
 		MEM_freeN(lcd);
 	}
 	*p= NULL;





More information about the Bf-blender-cvs mailing list