[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11584] branches/soc-2007-mosani/source/ blender: Fixed memory errors in plugin API and render pipeline.

Aaron Moore two.a.ron at gmail.com
Tue Aug 14 09:52:32 CEST 2007


Revision: 11584
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11584
Author:   mosani
Date:     2007-08-14 09:52:32 +0200 (Tue, 14 Aug 2007)

Log Message:
-----------
Fixed memory errors in plugin API and render pipeline.

Modified Paths:
--------------
    branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_core_api.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_renderapi.h
    branches/soc-2007-mosani/source/blender/blenpluginapi/intern/pluginapi.c
    branches/soc-2007-mosani/source/blender/render/intern/source/RND_convertblender.c
    branches/soc-2007-mosani/source/blender/render/intern/source/RND_initrender.c
    branches/soc-2007-mosani/source/blender/render/intern/source/pipeline.c
    branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c
    branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h
    branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI_helpers.h
    branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI_internal.h
    branches/soc-2007-mosani/source/blender/render/render_api/plugins/aqsis/aqsis.c
    branches/soc-2007-mosani/source/blender/render/render_api/source/RND_helpers.c
    branches/soc-2007-mosani/source/blender/render/render_api/source/RND_internal.c
    branches/soc-2007-mosani/source/blender/render/render_api/source/RND_settings.c
    branches/soc-2007-mosani/source/blender/src/SConscript
    branches/soc-2007-mosani/source/blender/src/usiblender.c

Modified: branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_core_api.h
===================================================================
--- branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_core_api.h	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_core_api.h	2007-08-14 07:52:32 UTC (rev 11584)
@@ -23,7 +23,8 @@
            structure, that is already present from file restore. 
 	   Does it only on first call, so call as often you like.
 	   Check return value! 1 = OK, 0 = load failed! (plugin not available)
-      
+   
+   plugin_shutdown: releases all memory associated with the plugin api.
 */
 
 extern plugin_descriptor_t * plugin_enumerate(
@@ -50,5 +51,7 @@
 extern int plugin_set_property(plugin_control_t * control,
 			       plp_type_t prop_type, const char * name, 
 			       void * data);
+  
+extern void plugin_shutdown();
 
 #endif

Modified: branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_renderapi.h
===================================================================
--- branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_renderapi.h	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/blenpluginapi/PLU_renderapi.h	2007-08-14 07:52:32 UTC (rev 11584)
@@ -63,6 +63,7 @@
 	
 	int (*is_animation)( RNDScene scene );
 	int (*has_motion_blur)( RNDScene scene );
+	int (*has_pixel_filter)( RNDScene scene );
 	int (*get_image_width)( RNDScene scene );
 	int (*get_image_height)( RNDScene scene );
 	char *(*get_file_type)( RNDScene scene );
@@ -70,6 +71,11 @@
 	RND_FILTER_TYPE (*get_pixel_filter_type)( RNDScene scene );
 	int (*get_pixel_filter_sample_number)( RNDScene scene );
 	float (*get_motion_blur_factor)( RNDScene scene );
+	int (*get_thread_count)( RNDScene scene );
+	int (*get_part_count)( RNDScene scene, char axis );
+	void (*get_horizon_color)( RNDScene scene, float color[] );
+	void (*get_zenith_color)( RNDScene scene, float color[] );
+	void (*get_ambient_color)( RNDScene scene, float color[] );
 
 	int (*is_perspective)( RNDScene scene );
 	float (*get_lens)( RNDScene scene );

Modified: branches/soc-2007-mosani/source/blender/blenpluginapi/intern/pluginapi.c
===================================================================
--- branches/soc-2007-mosani/source/blender/blenpluginapi/intern/pluginapi.c	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/blenpluginapi/intern/pluginapi.c	2007-08-14 07:52:32 UTC (rev 11584)
@@ -1871,6 +1871,20 @@
 	freeN(c);
 }
 
+void plugin_shutdown()
+{
+	int i;
+	plugin_descriptor_t * d = 0;
+	
+	for( i = 0; i < PLUGIN_SIZEOF_TYPE; i++ )
+	{
+		for( d = desc_lists[i].first; d; d = d->next )
+			delete_descriptor( d );
+	}
+	
+	MEM_freeN( desc_lists );
+}
+
 /* ---------------------------------------------------------------------- */
 /* - old obsoleted plugin interface, needed for backward compatibility - */
 
@@ -2209,6 +2223,7 @@
 	RND_stop_render,
 	
 	RND_is_animation,
+	RND_has_pixel_filter,
 	RND_has_motion_blur,
 	RND_get_image_width,
 	RND_get_image_height,
@@ -2217,6 +2232,11 @@
 	RND_get_pixel_filter_type,
 	RND_get_pixel_filter_sample_number,
 	RND_get_motion_blur_factor,
+	RND_get_thread_count,
+	RND_get_part_count,
+	RND_get_horizon_color,
+	RND_get_zenith_color,
+	RND_get_ambient_color,
 
 	RND_is_perspective,
 	RND_get_lens,

Modified: branches/soc-2007-mosani/source/blender/render/intern/source/RND_convertblender.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/source/RND_convertblender.c	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/render/intern/source/RND_convertblender.c	2007-08-14 07:52:32 UTC (rev 11584)
@@ -625,18 +625,20 @@
 static void render_database_free_renderdata_tables( RenderDatabase *db )
 {
 	/* free render verticies */
-	if(db->vertnodes) {
+	if( db->vertnodes ) {
 		free_renderdata_vertnodes( db->vertnodes );
 		db->vertnodes = NULL;
 		db->vertnodeslen = 0;
 	}
 	
 	/* free render faces */
-	if(db->vlaknodes) {
+	if( db->vlaknodes ) {
 		free_renderdata_vlaknodes( db->vlaknodes );
 		db->vlaknodes = NULL;
 		db->vlaknodeslen = 0;
 	}
+	
+	BLI_freelistN( &db->objecttable );
 }
 
 /**** render parts (tiles) ****/
@@ -666,8 +668,8 @@
 	xmaxb= db->disprect.xmax;
 	ymaxb= db->disprect.ymax;
 	
-	xparts= 1; /* hard coded: current API hole */
-	yparts= 1;
+	xparts= RND_get_part_count( scene, 'x' );
+	yparts= RND_get_part_count( scene, 'y' );
 	
 	/* correct size if parts are too small, 
 	   but for exr tile saving it was checked already */

Modified: branches/soc-2007-mosani/source/blender/render/intern/source/RND_initrender.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/source/RND_initrender.c	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/render/intern/source/RND_initrender.c	2007-08-14 07:52:32 UTC (rev 11584)
@@ -104,6 +104,7 @@
 RenderDatabase *render_database_initialize( RNDScene scene )
 {
 	RenderDatabase *db = NULL;
+	float color[3];
 	
 	/**** new RenderDatabase ****/
 	
@@ -120,6 +121,18 @@
 	db->r.xasp = db->r.yasp = 100;
 	
 	db->wrld.range = 1.0f;
+	RND_get_horizon_color( scene, color );
+	db->wrld.horr = color[0];
+	db->wrld.horg = color[1];
+	db->wrld.horb = color[2];
+	RND_get_zenith_color( scene, color );
+	db->wrld.zenr = color[0];
+	db->wrld.zeng = color[1];
+	db->wrld.zenb = color[2];
+	RND_get_ambient_color( scene, color );
+	db->wrld.ambr = color[0];
+	db->wrld.ambg = color[1];
+	db->wrld.ambb = color[2];
 	
 	/**** initialize rasterization properties ****/
 	
@@ -135,7 +148,7 @@
 	db->rectx = RND_get_image_width( scene );
 	db->recty = RND_get_image_height( scene );
 	
-	if( db->r.mode & (R_OSA) ) { /* currently cannot be true: render API hole */
+	if( RND_has_pixel_filter( scene ) ) {
 		db->osa = db->r.osa;
 		if( db->osa > 16 ) db->osa = 16;
 	}

Modified: branches/soc-2007-mosani/source/blender/render/intern/source/pipeline.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/source/pipeline.c	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/render/intern/source/pipeline.c	2007-08-14 07:52:32 UTC (rev 11584)
@@ -1018,7 +1018,6 @@
 /* only call this while you know it will remove the link too */
 void RE_FreeRender(Render *re)
 {
-	
 	free_renderdata_tables(re);
 	free_sample_tables(re);
 	
@@ -2477,12 +2476,17 @@
 }
 static void Render_Frame( struct Render *re )
 {
-	/**** do generic tasks for the rending of a single frame ****/\
+	/**** do generic tasks for the rending of a single frame ****/
 	
 	/* create a fresh render result */
-	RenderAPI_free_result( re->api_result );
-	re->api_result = RenderAPI_create_result( re );
+	RE_FreeRenderResult( re->result );
+	re->result = new_render_result( re, &re->disprect, 0, 
+		re->r.scemode & R_EXR_TILE_FILE );
+	BLI_freelistN( &re->api_result->pass_handlers );
+	RenderAPI_create_passes( re->api_result );
 	
+	init_render_world( re );
+	
 	if( G.scene->r.renderer == 0 ) /* if blender internal, set threadsafe
 	                                  abort-test callback */
 		re->test_break = thread_break;
@@ -2494,6 +2498,7 @@
 static void Finish( struct Render *re )
 {
 	RenderAPI_free_scene( re->api_scene );
+	RenderAPI_free_result( re->api_result );
 	re->finish( re->api_scene );
 }
 

Modified: branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c
===================================================================
--- branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/render/intern/source/rendercallbacks.c	2007-08-14 07:52:32 UTC (rev 11584)
@@ -205,7 +205,7 @@
 	RDB = *db;
 	global_image_bounds = db->disprect;
 	
-	BLI_init_threads(&threads, do_part_thread, 1); /* thread count hardcoded: current API hole */
+	BLI_init_threads(&threads, do_part_thread, RND_get_thread_count( scene ) );
 	
 	/* timer loop demands to sleep when no parts are left, 
 	   so we enter loop with a part */
@@ -273,7 +273,7 @@
 			else {
 				rendering= 1;
 				if(pa->nr && pa->result && drawtimer>20) {
-					send_image_results( result, pa );
+					//send_image_results( result, pa );
 					/* re->display_draw(pa->result, &pa->result->renrect); */
 					hasdrawn= 1;
 				}
@@ -284,10 +284,12 @@
 
 		/* on break, wait for all slots to get freed */
 		if( set_thread_break( RND_stop_render() )  && 
-				BLI_available_threads(&threads)==1 ) /* hard coded: current API hole */
+				BLI_available_threads(&threads)==RND_get_thread_count( scene ) )
 			rendering= 0;
 		
 	}
+	
+	BLI_end_threads(&threads);
 }
 
 static RenderPart *render_database_find_next_part( RenderDatabase *db, int minx )

Modified: branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h
===================================================================
--- branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h	2007-08-14 06:39:07 UTC (rev 11583)
+++ branches/soc-2007-mosani/source/blender/render/render_api/include/RenderAPI.h	2007-08-14 07:52:32 UTC (rev 11584)
@@ -110,6 +110,7 @@
 
 int RND_is_animation( RNDScene scene );
 int RND_has_motion_blur( RNDScene scene );
+int RND_has_pixel_filter( RNDScene scene );
 
 int RND_get_image_width( RNDScene scene );
 int RND_get_image_height( RNDScene scene );
@@ -118,7 +119,17 @@
 RND_FILTER_TYPE RND_get_pixel_filter_type( RNDScene scene );
 int RND_get_pixel_filter_sample_number( RNDScene scene );
 float RND_get_motion_blur_factor( RNDScene scene );
+int RND_get_thread_count( RNDScene scene );
 
+/** axis is 'x' or 'y' */
+int RND_get_part_count( RNDScene scene, char axis );
+
+/* ----------------------------  world  ----------------------------------- */
+
+void RND_get_horizon_color( RNDScene scene, float color[] );
+void RND_get_zenith_color( RNDScene scene, float color[] );
+void RND_get_ambient_color( RNDScene scene, float color[] );
+
 /* ------------------------------------------------------------------------ */
 /* ----------------------------  camera  ---------------------------------- */
 /* ------------------------------------------------------------------------ */


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list