forked from bartvdbraak/blender
Carefully went over all scanline updating while rendering, to ensure only
updates are allowed to draw when a part is within a scanline rendering loop. Might solve threads issues with opengl...
This commit is contained in:
parent
02dc8de55d
commit
a2a2ad98e2
@ -103,7 +103,7 @@ typedef struct RenderResult {
|
||||
|
||||
/* optional saved endresult on disk */
|
||||
char exrfile[FILE_MAXDIR];
|
||||
int filehandle;
|
||||
void *exrhandle;
|
||||
|
||||
} RenderResult;
|
||||
|
||||
|
@ -283,9 +283,6 @@ static RenderResult *new_render_result(Render *re, rcti *partrct, int crop)
|
||||
re->r.actlay= 0;
|
||||
}
|
||||
|
||||
/* display active layer */
|
||||
rr->renlay= render_get_active_layer(re, rr);
|
||||
|
||||
return rr;
|
||||
}
|
||||
|
||||
@ -806,7 +803,7 @@ static void threaded_tile_processor(Render *re)
|
||||
{
|
||||
ListBase threads;
|
||||
RenderPart *pa, *nextpa;
|
||||
int maxthreads, rendering=1, counter= 1, hasdrawn, drawtimer=0;
|
||||
int maxthreads, rendering=1, counter= 1, drawtimer=0;
|
||||
|
||||
if(re->result==NULL)
|
||||
return;
|
||||
@ -831,6 +828,7 @@ static void threaded_tile_processor(Render *re)
|
||||
while(rendering) {
|
||||
|
||||
if(nextpa && BLI_available_threads(&threads) && !re->test_break()) {
|
||||
drawtimer= 0;
|
||||
nextpa->nr= counter++; /* for nicest part, and for stats */
|
||||
nextpa->thread= BLI_available_thread_index(&threads); /* sample index */
|
||||
BLI_insert_thread(&threads, nextpa);
|
||||
@ -843,7 +841,6 @@ static void threaded_tile_processor(Render *re)
|
||||
}
|
||||
|
||||
/* check for ready ones to display, and if we need to continue */
|
||||
hasdrawn= 0;
|
||||
rendering= 0;
|
||||
for(pa= re->parts.first; pa; pa= pa->next) {
|
||||
if(pa->ready) {
|
||||
@ -857,21 +854,18 @@ static void threaded_tile_processor(Render *re)
|
||||
free_render_result(pa->result);
|
||||
pa->result= NULL;
|
||||
re->i.partsdone++;
|
||||
hasdrawn= 1;
|
||||
drawtimer= 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
rendering= 1;
|
||||
if(pa->nr && pa->result && drawtimer>20) {
|
||||
re->display_draw(pa->result, &pa->result->renrect);
|
||||
hasdrawn= 1;
|
||||
drawtimer= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(hasdrawn)
|
||||
drawtimer= 0;
|
||||
|
||||
/* on break, wait for all slots to get freed */
|
||||
if( (g_break=re->test_break()) && BLI_available_threads(&threads)==maxthreads)
|
||||
rendering= 0;
|
||||
|
@ -2910,7 +2910,8 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl)
|
||||
/* scanline updates have to be 2 lines behind */
|
||||
rr->renrect.ymin= 0;
|
||||
rr->renrect.ymax= -2*crop;
|
||||
|
||||
rr->renlay= rl;
|
||||
|
||||
for(y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) {
|
||||
rf= rectf;
|
||||
rd= rectdaps;
|
||||
@ -2994,6 +2995,9 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl)
|
||||
if(y&1) if(R.test_break()) break;
|
||||
}
|
||||
|
||||
/* disable scanline updating */
|
||||
rr->renlay= NULL;
|
||||
|
||||
if(R.do_gamma) {
|
||||
rectf= rl->rectf;
|
||||
for(y= pa->rectx*pa->recty; y>0; y--, rectf+=4) {
|
||||
@ -3104,9 +3108,6 @@ void zbufshadeDA_tile(RenderPart *pa)
|
||||
if(R.r.mode & R_EDGE) edgerect= MEM_callocT(sizeof(float)*pa->rectx*pa->recty, "rectedge");
|
||||
|
||||
for(rl= rr->layers.first; rl; rl= rl->next) {
|
||||
/* indication for scanline updates */
|
||||
rr->renlay= rl;
|
||||
rr->renrect.ymin=rr->renrect.ymax= 0;
|
||||
|
||||
/* initialize pixelstructs */
|
||||
addpsmain(&psmlist);
|
||||
@ -3175,6 +3176,7 @@ void zbufshadeDA_tile(RenderPart *pa)
|
||||
if(edgerect) MEM_freeT(edgerect);
|
||||
|
||||
/* display active layer */
|
||||
rr->renrect.ymin=rr->renrect.ymax= 0;
|
||||
rr->renlay= render_get_active_layer(&R, rr);
|
||||
}
|
||||
|
||||
@ -3198,9 +3200,6 @@ void zbufshade_tile(RenderPart *pa)
|
||||
shpi.thread= pa->thread;
|
||||
|
||||
for(rl= rr->layers.first; rl; rl= rl->next) {
|
||||
/* indication for scanline updates */
|
||||
rr->renlay= rl;
|
||||
rr->renrect.ymin=rr->renrect.ymax= 0;
|
||||
|
||||
/* fill shadepixel info struct */
|
||||
shpi.lay= rl->lay;
|
||||
@ -3218,6 +3217,10 @@ void zbufshade_tile(RenderPart *pa)
|
||||
float *fcol= rl->rectf;
|
||||
int x, y, *rp= pa->rectp, *rz= pa->rectz, offs=0;
|
||||
|
||||
/* initialize scanline updates for main thread */
|
||||
rr->renrect.ymin= 0;
|
||||
rr->renlay= rl;
|
||||
|
||||
for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++, rr->renrect.ymax++) {
|
||||
for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, rp++, fcol+=4, offs++) {
|
||||
shadepixel_sky(&shpi, (float)x, (float)y, *rz, *rp, 0);
|
||||
@ -3230,6 +3233,9 @@ void zbufshade_tile(RenderPart *pa)
|
||||
if(y&1)
|
||||
if(R.test_break()) break;
|
||||
}
|
||||
|
||||
/* disable scanline updating */
|
||||
rr->renlay= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3278,6 +3284,7 @@ void zbufshade_tile(RenderPart *pa)
|
||||
}
|
||||
|
||||
/* display active layer */
|
||||
rr->renrect.ymin=rr->renrect.ymax= 0;
|
||||
rr->renlay= render_get_active_layer(&R, rr);
|
||||
|
||||
MEM_freeT(pa->rectp); pa->rectp= NULL;
|
||||
|
@ -2686,9 +2686,9 @@ void zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pass)
|
||||
/* init scanline updates */
|
||||
rr->renrect.ymin= 0;
|
||||
rr->renrect.ymax= -pa->crop;
|
||||
|
||||
rr->renlay= rl;
|
||||
|
||||
/* render the tile */
|
||||
|
||||
for(y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) {
|
||||
pass= passrect;
|
||||
ap= aprect;
|
||||
@ -2816,6 +2816,9 @@ void zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pass)
|
||||
offs+= pa->rectx;
|
||||
}
|
||||
|
||||
/* disable scanline updating */
|
||||
rr->renlay= NULL;
|
||||
|
||||
MEM_freeT(APixbuf);
|
||||
freepsA(&apsmbase);
|
||||
|
||||
|
@ -761,9 +761,13 @@ static void renderwin_progress(RenderWin *rw, RenderResult *rr, rcti *renrect)
|
||||
|
||||
/* if renrect argument, we only display scanlines */
|
||||
if(renrect) {
|
||||
/* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
|
||||
if(rr->renlay==NULL || renrect->ymax>=rr->recty)
|
||||
return;
|
||||
|
||||
ymin= renrect->ymin;
|
||||
ymax= renrect->ymax-ymin;
|
||||
if(ymax<2 || renrect->ymax>=rr->recty) /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
|
||||
if(ymax<2)
|
||||
return;
|
||||
renrect->ymin= renrect->ymax;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user