Ray-transparent didn't pass on thread number to shading code, giving
"blothes" in render, when using node materials.

This also rewinds Campbells commit of feb 21, which tackled the error,
but not the cause.
This commit is contained in:
Ton Roosendaal 2009-04-22 17:06:47 +00:00
parent f6d27e73ee
commit 971cabc2d6
2 changed files with 8 additions and 12 deletions

@ -1982,9 +1982,9 @@ static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack)
} }
} }
/* notes below are ancient! (ton) */
/* stack indices make sure all nodes only write in allocated data, for making it thread safe */ /* stack indices make sure all nodes only write in allocated data, for making it thread safe */
/* only root tree gets the stack, to enable instances to have own stack entries */ /* only root tree gets the stack, to enable instances to have own stack entries */
/* only two threads now! */
/* per tree (and per group) unique indices are created */ /* per tree (and per group) unique indices are created */
/* the index_ext we need to be able to map from groups to the group-node own stack */ /* the index_ext we need to be able to map from groups to the group-node own stack */
@ -1999,14 +1999,9 @@ 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;
} }
} }
@ -2014,7 +2009,7 @@ static bNodeThreadStack *ntreeGetThreadStack(bNodeTree *ntree, int thread)
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;
} }

@ -1273,7 +1273,7 @@ static void addAlphaLight(float *shadfac, float *col, float alpha, float filter)
shadfac[3]= (1.0f-alpha)*shadfac[3]; shadfac[3]= (1.0f-alpha)*shadfac[3];
} }
static void ray_trace_shadow_tra(Isect *is, int depth, int traflag) static void ray_trace_shadow_tra(Isect *is, int thread, int depth, int traflag)
{ {
/* ray to lamp, find first face that intersects, check alpha properties, /* ray to lamp, find first face that intersects, check alpha properties,
if it has col[3]>0.0f continue. so exit when alpha is full */ if it has col[3]>0.0f continue. so exit when alpha is full */
@ -1291,6 +1291,7 @@ static void ray_trace_shadow_tra(Isect *is, int depth, int traflag)
shi.depth= 1; /* only used to indicate tracing */ shi.depth= 1; /* only used to indicate tracing */
shi.mask= 1; shi.mask= 1;
shi.thread= thread;
/*shi.osatex= 0; /*shi.osatex= 0;
shi.thread= shi.sample= 0; shi.thread= shi.sample= 0;
@ -1315,7 +1316,7 @@ static void ray_trace_shadow_tra(Isect *is, int depth, int traflag)
is->oborig= RAY_OBJECT_SET(&R, shi.obi); is->oborig= RAY_OBJECT_SET(&R, shi.obi);
is->faceorig= (RayFace*)shi.vlr; is->faceorig= (RayFace*)shi.vlr;
ray_trace_shadow_tra(is, depth-1, traflag | RAY_TRA); ray_trace_shadow_tra(is, thread, depth-1, traflag | RAY_TRA);
} }
} }
} }
@ -1943,7 +1944,7 @@ static void ray_shadow_qmc(ShadeInput *shi, LampRen *lar, float *lampco, float *
isec->col[0]= isec->col[1]= isec->col[2]= 1.0f; isec->col[0]= isec->col[1]= isec->col[2]= 1.0f;
isec->col[3]= 1.0f; isec->col[3]= 1.0f;
ray_trace_shadow_tra(isec, DEPTH_SHADOW_TRA, 0); ray_trace_shadow_tra(isec, shi->thread, DEPTH_SHADOW_TRA, 0);
shadfac[0] += isec->col[0]; shadfac[0] += isec->col[0];
shadfac[1] += isec->col[1]; shadfac[1] += isec->col[1];
shadfac[2] += isec->col[2]; shadfac[2] += isec->col[2];
@ -2041,7 +2042,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, float *lampco, floa
isec->col[0]= isec->col[1]= isec->col[2]= 1.0f; isec->col[0]= isec->col[1]= isec->col[2]= 1.0f;
isec->col[3]= 1.0f; isec->col[3]= 1.0f;
ray_trace_shadow_tra(isec, DEPTH_SHADOW_TRA, 0); ray_trace_shadow_tra(isec, shi->thread, DEPTH_SHADOW_TRA, 0);
shadfac[0] += isec->col[0]; shadfac[0] += isec->col[0];
shadfac[1] += isec->col[1]; shadfac[1] += isec->col[1];
shadfac[2] += isec->col[2]; shadfac[2] += isec->col[2];
@ -2122,7 +2123,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac)
isec.col[0]= isec.col[1]= isec.col[2]= 1.0f; isec.col[0]= isec.col[1]= isec.col[2]= 1.0f;
isec.col[3]= 1.0f; isec.col[3]= 1.0f;
ray_trace_shadow_tra(&isec, DEPTH_SHADOW_TRA, 0); ray_trace_shadow_tra(&isec, shi->thread, DEPTH_SHADOW_TRA, 0);
QUATCOPY(shadfac, isec.col); QUATCOPY(shadfac, isec.col);
} }
else if(RE_ray_tree_intersect(R.raytree, &isec)) shadfac[3]= 0.0f; else if(RE_ray_tree_intersect(R.raytree, &isec)) shadfac[3]= 0.0f;