[#18058] Black dots appear when blender renders with multi-thread and material nodes

Without thread locking the function that allocates new threads, black dots appear in renders.

This wont affect composite nodes,
Ton/Brecht - this is possibly too many lock/unlocks but I timed the render from the bug report and it didn't make a noticeable difference.
This commit is contained in:
Campbell Barton 2009-02-21 04:42:46 +00:00
parent 7260e8fe29
commit f87a399978

@ -1999,19 +1999,23 @@ static bNodeThreadStack *ntreeGetThreadStack(bNodeTree *ntree, int thread)
{ {
ListBase *lb= &ntree->threadstack[thread]; ListBase *lb= &ntree->threadstack[thread];
bNodeThreadStack *nts; bNodeThreadStack *nts;
/* for material shading this is called quite a lot (perhaps too much locking unlocking)
* however without locking we get bug #18058 - Campbell */
BLI_lock_thread(LOCK_CUSTOM1);
for(nts=lb->first; nts; nts=nts->next) { for(nts=lb->first; nts; nts=nts->next) {
if(!nts->used) { if(!nts->used) {
nts->used= 1; nts->used= 1;
BLI_unlock_thread(LOCK_CUSTOM1);
return nts; return nts;
} }
} }
nts= MEM_callocN(sizeof(bNodeThreadStack), "bNodeThreadStack"); nts= MEM_callocN(sizeof(bNodeThreadStack), "bNodeThreadStack");
nts->stack= MEM_dupallocN(ntree->stack); nts->stack= MEM_dupallocN(ntree->stack);
nts->used= 1; nts->used= 1;
BLI_addtail(lb, nts); BLI_addtail(lb, nts);
BLI_unlock_thread(LOCK_CUSTOM1);
return nts; return nts;
} }