Carefully went over all scanline updating while rendering, to ensure only
authorTon Roosendaal <ton@blender.org>
Tue, 21 Feb 2006 10:47:08 +0000 (10:47 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 21 Feb 2006 10:47:08 +0000 (10:47 +0000)
updates are allowed to draw when a part is within a scanline rendering
loop. Might solve threads issues with opengl...

source/blender/render/extern/include/RE_pipeline.h
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/zbuf.c
source/blender/src/renderwin.c

index 793ef2611acec9503476ed22319efba9b5b8a074..b1dfb53e357e30cec94b3615d596ae2150bfa1d0 100644 (file)
@@ -103,7 +103,7 @@ typedef struct RenderResult {
        
        /* optional saved endresult on disk */
        char exrfile[FILE_MAXDIR];
-       int filehandle;
+       void *exrhandle;
        
 } RenderResult;
 
index a9ff228b790e8b63716a59023ee79cab16a1f71c..a0e085b8cd1ab729a2a9bb56fd322d1ac38ac14c 100644 (file)
@@ -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;
index 2b8a939e8325e6782063dc7850651e2291a9f9fd..4871cb4e027bc760d7736ce279027dc5c317bf3d 100644 (file)
@@ -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;
index ca0dfd7658a3e2f87d1a11a7807f723db05da180..133ff1afd6df2e944f502d6030778d0f454bca2d 100644 (file)
@@ -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);     
 
index b980870dfca1ae3d098d877a9b79de1368b875c3..38004e986d53cf7b03e8bfa3b71eb69eac75196a 100644 (file)
@@ -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;
        }