[Bf-blender-cvs] [ec0ba40] master: Fix T44979: Crash when rendering with more threads than the system ones

Sergey Sharybin noreply at git.blender.org
Mon Jun 8 13:54:21 CEST 2015


Commit: ec0ba4095f9e60057309e6a72e6661170a22a7ee
Author: Sergey Sharybin
Date:   Mon Jun 8 13:46:33 2015 +0200
Branches: master
https://developer.blender.org/rBec0ba4095f9e60057309e6a72e6661170a22a7ee

Fix T44979: Crash when rendering with more threads than the system ones

Revert "Nodes: Remove hardcoded BLENDER_MAX_THREADS number of threads"

This reverts commit fdc653e8ce77a188138dc707207139c3d1e6b166.

The threads override is not affected by the scene, and hence the limit of the
threads was not giving correct result. Need to re-consider some things here.

===================================================================

M	source/blender/nodes/intern/node_exec.c
M	source/blender/nodes/intern/node_exec.h
M	source/blender/nodes/shader/node_shader_tree.c
M	source/blender/nodes/texture/node_texture_tree.c

===================================================================

diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index 0782668..2347564 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -29,7 +29,6 @@
  *  \ingroup nodes
  */
 
-#include <stdlib.h>  /* for abort() */
 
 #include "DNA_node_types.h"
 
@@ -263,7 +262,7 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread)
 {
 	ListBase *lb = &exec->threadstack[thread];
 	bNodeThreadStack *nts;
-	BLI_assert(thread < exec->tot_thread);
+	
 	for (nts = lb->first; nts; nts = nts->next) {
 		if (!nts->used) {
 			nts->used = true;
diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h
index 8bb8c77..a0023d0 100644
--- a/source/blender/nodes/intern/node_exec.h
+++ b/source/blender/nodes/intern/node_exec.h
@@ -65,7 +65,6 @@ typedef struct bNodeTreeExec {
 	int stacksize;
 	struct bNodeStack *stack;		/* socket data stack */
 	/* only used by material and texture trees to keep one stack for each thread */
-	int tot_thread;
 	ListBase *threadstack;			/* one instance of the stack for each thread */
 } bNodeTreeExec;
 
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index a49d6ea..cd2c6f6 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -235,8 +235,7 @@ bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNod
 	exec = ntree_exec_begin(context, ntree, parent_key);
 	
 	/* allocate the thread stack listbase array */
-	exec->tot_thread = BLI_system_thread_count();
-	exec->threadstack = MEM_callocN(exec->tot_thread * sizeof(ListBase), "thread stack array");
+	exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
 	
 	for (node = exec->nodetree->nodes.first; node; node = node->next)
 		node->need_exec = 1;
@@ -273,7 +272,7 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec)
 	int a;
 	
 	if (exec->threadstack) {
-		for (a = 0; a < exec->tot_thread; a++) {
+		for (a = 0; a < BLENDER_MAX_THREADS; a++) {
 			for (nts = exec->threadstack[a].first; nts; nts = nts->next)
 				if (nts->stack) MEM_freeN(nts->stack);
 			BLI_freelistN(&exec->threadstack[a]);
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 3482227..d716c25 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -232,8 +232,7 @@ bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context, bNodeTr
 	exec = ntree_exec_begin(context, ntree, parent_key);
 	
 	/* allocate the thread stack listbase array */
-	exec->tot_thread = BLI_system_thread_count();
-	exec->threadstack = MEM_callocN(exec->tot_thread * sizeof(ListBase), "thread stack array");
+	exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
 	
 	for (node = exec->nodetree->nodes.first; node; node = node->next)
 		node->need_exec = 1;
@@ -271,7 +270,7 @@ static void tex_free_delegates(bNodeTreeExec *exec)
 	bNodeStack *ns;
 	int th, a;
 	
-	for (th = 0; th < exec->tot_thread; th++)
+	for (th = 0; th < BLENDER_MAX_THREADS; th++)
 		for (nts = exec->threadstack[th].first; nts; nts = nts->next)
 			for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++)
 				if (ns->data && !ns->is_copy)
@@ -286,7 +285,7 @@ void ntreeTexEndExecTree_internal(bNodeTreeExec *exec)
 	if (exec->threadstack) {
 		tex_free_delegates(exec);
 		
-		for (a = 0; a < exec->tot_thread; a++) {
+		for (a = 0; a < BLENDER_MAX_THREADS; a++) {
 			for (nts = exec->threadstack[a].first; nts; nts = nts->next)
 				if (nts->stack) MEM_freeN(nts->stack);
 			BLI_freelistN(&exec->threadstack[a]);




More information about the Bf-blender-cvs mailing list