[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28165] branches/render25/source: Render Branch: https://svn.blender.org/svnroot/bf-blender/trunk/ blender -r28156:28164

Brecht Van Lommel brecht at blender.org
Tue Apr 13 18:19:04 CEST 2010


Revision: 28165
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28165
Author:   blendix
Date:     2010-04-13 18:19:04 +0200 (Tue, 13 Apr 2010)

Log Message:
-----------
Render Branch: https://svn.blender.org/svnroot/bf-blender/trunk/blender -r28156:28164

Modified Paths:
--------------
    branches/render25/source/blender/blenlib/BLI_threads.h
    branches/render25/source/blender/blenlib/intern/threads.c
    branches/render25/source/blender/gpu/intern/gpu_draw.c
    branches/render25/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
    branches/render25/source/creator/creator.c

Modified: branches/render25/source/blender/blenlib/BLI_threads.h
===================================================================
--- branches/render25/source/blender/blenlib/BLI_threads.h	2010-04-13 14:46:19 UTC (rev 28164)
+++ branches/render25/source/blender/blenlib/BLI_threads.h	2010-04-13 16:19:04 UTC (rev 28165)
@@ -40,6 +40,9 @@
 
 /* Threading API */
 
+/*this is run once at startup*/
+void BLI_threadapi_init(void);
+
 void	BLI_init_threads	(struct ListBase *threadbase, void *(*do_thread)(void *), int tot);
 int		BLI_available_threads(struct ListBase *threadbase);
 int		BLI_available_thread_index(struct ListBase *threadbase);
@@ -48,6 +51,7 @@
 void	BLI_remove_thread_index(struct ListBase *threadbase, int index);
 void	BLI_remove_threads(struct ListBase *threadbase);
 void	BLI_end_threads		(struct ListBase *threadbase);
+int BLI_thread_is_main(void);
 
 /* System Information */
 

Modified: branches/render25/source/blender/blenlib/intern/threads.c
===================================================================
--- branches/render25/source/blender/blenlib/intern/threads.c	2010-04-13 14:46:19 UTC (rev 28164)
+++ branches/render25/source/blender/blenlib/intern/threads.c	2010-04-13 16:19:04 UTC (rev 28165)
@@ -107,6 +107,7 @@
 static pthread_mutex_t _viewer_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t _custom1_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t _rcache_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_t mainid;
 static int thread_levels= 0;	/* threads can be invoked inside threads */
 
 /* just a max for security reasons */
@@ -130,6 +131,11 @@
 	pthread_mutex_unlock(&_malloc_lock);
 }
 
+void BLI_threadapi_init(void)
+{
+	mainid = pthread_self();
+}
+
 /* tot = 0 only initializes malloc mutex in a safe way (see sequence.c)
    problem otherwise: scene render will kill of the mutex!
 */
@@ -137,7 +143,7 @@
 void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
 {
 	int a;
-	
+
 	if(threadbase != NULL && tot > 0) {
 		threadbase->first= threadbase->last= NULL;
 	
@@ -205,6 +211,13 @@
 	return tslot->do_thread(tslot->callerdata);
 }
 
+int BLI_thread_is_main(void) {
+	pthread_t  tid;
+	tid = pthread_self();
+
+	return !memcmp(&tid, &mainid, sizeof(pthread_t));
+}
+
 void BLI_insert_thread(ListBase *threadbase, void *callerdata)
 {
 	ThreadSlot *tslot;

Modified: branches/render25/source/blender/gpu/intern/gpu_draw.c
===================================================================
--- branches/render25/source/blender/gpu/intern/gpu_draw.c	2010-04-13 14:46:19 UTC (rev 28164)
+++ branches/render25/source/blender/gpu/intern/gpu_draw.c	2010-04-13 16:19:04 UTC (rev 28165)
@@ -62,6 +62,9 @@
 #include "BKE_object.h"
 #include "BKE_utildefines.h"
 
+#include "BLI_threads.h"
+#include "BLI_blenlib.h"
+
 #include "GPU_extensions.h"
 #include "GPU_material.h"
 #include "GPU_draw.h"
@@ -781,8 +784,42 @@
 	smd->domain->tex_shadow = GPU_texture_create_3D(smd->domain->res[0], smd->domain->res[1], smd->domain->res[2], smd->domain->shadow);
 }
 
+ListBase image_free_queue = {NULL, NULL};
+static void flush_queued_free(void)
+{
+	Image *ima, *imanext;
+
+	BLI_lock_thread(LOCK_IMAGE);
+
+	ima = image_free_queue.first;
+	image_free_queue.first = image_free_queue.last = NULL;
+	for (; ima; ima=imanext) {
+		imanext = (Image*)ima->id.next;
+		GPU_free_image(ima);
+		MEM_freeN(ima);
+	}
+
+	BLI_unlock_thread(LOCK_IMAGE);
+}
+
+static void queue_image_for_free(Image *ima)
+{
+    Image *cpy = MEM_dupallocN(ima);
+
+    BLI_lock_thread(LOCK_IMAGE);
+	BLI_addtail(&image_free_queue, cpy);
+    BLI_unlock_thread(LOCK_IMAGE);
+}
+
 void GPU_free_image(Image *ima)
 {
+	if (!BLI_thread_is_main()) {
+		queue_image_for_free(ima);
+		return;
+	} else if (image_free_queue.first) {
+		flush_queued_free();
+	}
+
 	/* free regular image binding */
 	if(ima->bindcode) {
 		glDeleteTextures(1, (GLuint *)&ima->bindcode);

Modified: branches/render25/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
===================================================================
--- branches/render25/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c	2010-04-13 14:46:19 UTC (rev 28164)
+++ branches/render25/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c	2010-04-13 16:19:04 UTC (rev 28165)
@@ -60,7 +60,6 @@
 	
 	CLAMP(hsv[0], 0.f, 1.f);
 	CLAMP(hsv[1], 0.f, 1.f);
-	CLAMP(hsv[2], 0.f, 1.f);
 	
 	/* convert back to rgb */
 	hsv_to_rgb(hsv[0], hsv[1], hsv[2], out, out+1, out+2);
@@ -89,7 +88,6 @@
 	
 	CLAMP(hsv[0], 0.f, 1.f);
 	CLAMP(hsv[1], 0.f, 1.f);
-	CLAMP(hsv[2], 0.f, 1.f);
 	
 	/* convert back to rgb */
 	hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);

Modified: branches/render25/source/creator/creator.c
===================================================================
--- branches/render25/source/creator/creator.c	2010-04-13 14:46:19 UTC (rev 28164)
+++ branches/render25/source/creator/creator.c	2010-04-13 16:19:04 UTC (rev 28165)
@@ -50,6 +50,7 @@
 #endif
 
 #include "BLI_args.h"
+#include "BLI_threads.h"
 
 #include "GEN_messaging.h"
 
@@ -964,6 +965,8 @@
     strip_quotes(build_type);
 #endif
 
+	BLI_threadapi_init();
+
 	RNA_init();
 	RE_engines_init();
 





More information about the Bf-blender-cvs mailing list