Replace all glFinish() with glFlush().
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Wed, 16 Jun 2004 11:34:45 +0000 (11:34 +0000)
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>
Wed, 16 Jun 2004 11:34:45 +0000 (11:34 +0000)
This is supposed to fix gradual slowdown of Blender interface on ATI cards.

13 files changed:
source/blender/src/drawmesh.c
source/blender/src/drawobject.c
source/blender/src/drawview.c
source/blender/src/editmesh.c
source/blender/src/editscreen.c
source/blender/src/editview.c
source/blender/src/filesel.c
source/blender/src/glutil.c
source/blender/src/interface.c
source/blender/src/mywindow.c
source/blender/src/previewrender.c
source/blender/src/swapbuffers.c
source/blender/src/toolbox.c

index 873b3c9ab9f0febba339be18e21442e204f68ce2..854f474f6bb395168f0964ec9ba38b2471d64f19 100644 (file)
@@ -386,10 +386,13 @@ int set_tpage(TFace *tface)
 
                glGenTextures(1, (GLuint *)bind);
                
-               if(G.f & G_DEBUG) {
-                       printf("var1: %s\n", ima->id.name+2);
-                       printf("var1: %d, var2: %d\n", *bind, tpx);
-                       printf("var1: %d, var2: %d\n", fCurtile, tilemode);
+               if((G.f & G_DEBUG) || !*bind) {
+                       GLenum error = glGetError();
+                       printf("Texture: %s\n", ima->id.name+2);
+                       printf("name: %d, tpx: %d\n", *bind, tpx);
+                       printf("tile: %d, mode: %d\n", fCurtile, tilemode);
+                       if (error)
+                               printf("error: %d\n", error);
                }
                glBindTexture( GL_TEXTURE_2D, *bind);
 
@@ -416,8 +419,6 @@ int set_tpage(TFace *tface)
        }
        else glBindTexture( GL_TEXTURE_2D, *bind);
        
-       
-
        glEnable(GL_TEXTURE_2D);
 
        fCurpage= ima;
index 48c02654fe1534468327b2ecd291541db95d6c89..dc22eda64bcb00b4c82b50a7a38778ad6b9b8207 100644 (file)
@@ -240,7 +240,7 @@ static void draw_icon_centered(float *pos, unsigned int *rect, int rectsize)
                /* use bitmap to shift rasterpos in pixels */
        glBitmap(0, 0, 0.0, 0.0, -hsize, -hsize, &dummy);
 #if defined (__sun__) || defined ( __sun ) || defined (__sparc) || defined (__sparc__)
-       glFinish(); 
+       glFlush(); 
 #endif 
        glDrawPixels(rectsize, rectsize, GL_RGBA, GL_UNSIGNED_BYTE, rect);
 }
@@ -270,7 +270,7 @@ void helpline(float *vec)
        setlinestyle(0);
        
        persp(PERSP_VIEW);
-       glFinish(); // flush display for frontbuffer
+       glFlush(); // flush display for frontbuffer
        glDrawBuffer(GL_BACK);
 }
 
@@ -3830,7 +3830,7 @@ void draw_object_ext(Base *base)
 
        G.f &= ~G_DRAW_EXT;
 
-       glFinish();             /* reveil frontbuffer drawing */
+       glFlush();              /* reveil frontbuffer drawing */
        glDrawBuffer(GL_BACK);
        
        if(G.zbuf) {
index 96a09783630e7e766f17f1074f62253be8383dd7..5777964a803bf4a63e9d3144625c70ab60d35a62 100644 (file)
@@ -2046,7 +2046,7 @@ void drawview3d_render(struct View3D *v3d)
        
        G.f &= ~G_SIMULATION;
 
-       glFinish();
+       glFlush();
 
        glReadPixels(0, 0, R.rectx, R.recty, GL_RGBA, GL_UNSIGNED_BYTE, R.rectot);
        glLoadIdentity();
index 59c2b4206deb8a29180bb5974bc4f417977527c0..d427b38dda884e690d6a70731a612cbaba2f4bd1 100644 (file)
@@ -3369,7 +3369,7 @@ void mouse_mesh(void)
 
                        countall();
 
-                       glFinish();
+                       glFlush();
                        glDrawBuffer(GL_BACK);
                        
                        /* signal that frontbuf differs from back */
@@ -7976,7 +7976,7 @@ CutCurve *get_mouse_trail(int *len, char mode){
                if( event==ESCKEY || event==RIGHTMOUSE ) {
                        if (curve) MEM_freeN(curve);
                        *len=0;
-                       glFinish();
+                       glFlush();
                        glDrawBuffer(GL_BACK);
                        return(NULL);
                        break;
@@ -7986,7 +7986,7 @@ CutCurve *get_mouse_trail(int *len, char mode){
                        glLineWidth(2.0);
                        sdrawXORline(curve[i-1].x, curve[i-1].y,mval[0], mval[1]); 
                        glLineWidth(1.0);
-                       glFinish();
+                       glFlush();
                        rubberband=0;
                }
                
@@ -8009,7 +8009,7 @@ CutCurve *get_mouse_trail(int *len, char mode){
                        if (restart) { 
                                for(j=1;j<i;j++) sdrawXORline(curve[j-1].x, curve[j-1].y, curve[j].x, curve[j].y);
                                if (rubberband) sdrawXORline(curve[j].x, curve[j].y, mval[0], mval[1]);
-                               glFinish();
+                               glFlush();
                                rubberband=0;
                                lasti=i=0;
                                restart=0;
@@ -8031,14 +8031,14 @@ CutCurve *get_mouse_trail(int *len, char mode){
                
                if ((i>1)&&(i!=lasti)) {  /*Draw recorded part of curve */
                        sdrawline(curve[i-2].x, curve[i-2].y, curve[i-1].x, curve[i-1].y);
-                       glFinish();
+                       glFlush();
                }
                
                if ((i==lasti)&&(i>0)) { /*Draw rubberband */
                        glLineWidth(2.0);
                        sdrawXORline(curve[i-1].x, curve[i-1].y,mval[0], mval[1]);
                        glLineWidth(1.0);
-                       glFinish();
+                       glFlush();
                        rubberband=1;
                }
                lasti=i;
@@ -8056,7 +8056,7 @@ CutCurve *get_mouse_trail(int *len, char mode){
                }
        }
 
-       glFinish();
+       glFlush();
        glDrawBuffer(GL_BACK);
        persp(PERSP_VIEW);
 
@@ -9188,7 +9188,7 @@ void bevel_menu()
                        setlinestyle(0);
                        
                        persp(PERSP_VIEW);
-                       glFinish(); // flush display for frontbuffer
+                       glFlush(); // flush display for frontbuffer
                        glDrawBuffer(GL_BACK);
                }
                while(qtest()) {
index 873a709fc93b00c8a5dbddbf6212ad993e597c84..393db3c17deb80122f56d1717b49202f8bd74b2e 100644 (file)
@@ -624,7 +624,7 @@ void splash(void *data, int datasize, char *string)
                        BMF_DrawString(font, string);
                }
 
-               glFinish();
+               glFlush();
                glDrawBuffer(GL_BACK);
                
                IMB_freeImBuf(bbuf);
@@ -3019,7 +3019,7 @@ void screen_draw_info_text(bScreen *sc, char *text) {
                        glRasterPos2i(x,  y);
                        BMF_DrawString(G.fonts, text);
                        
-                       glFinish();
+                       glFlush();
                        glDrawBuffer(GL_BACK);
                        
                        sa->head_swap= WIN_FRONT_OK;
index d681c2d50b048c675678f5fd5f1fa4640f7e0e15..76bb6d56608015014b813b3a749c0e7355775b64 100644 (file)
@@ -887,7 +887,7 @@ void borderselect(void)
                                base= base->next;
                        }
                        /* frontbuffer flush */
-                       glFinish();
+                       glFlush();
                        
                        allqueue(REDRAWDATASELECT, 0);
                        
index 9597af86250a38f9e595fe800886598cb7a2efc7..8b1d60ee70367168984d963feb5d7a4bb325081f 100644 (file)
@@ -1084,7 +1084,7 @@ static void set_active_file(SpaceFile *sfile, int act)
                
                glScissor(curarea->winrct.xmin, curarea->winrct.ymin, curarea->winx, curarea->winy);
 
-               glFinish();             /* for geforce, to show it in the frontbuffer */
+               glFlush();              /* for geforce, to show it in the frontbuffer */
                glDrawBuffer(GL_BACK);
        }
        else if(redraw) {
index 328764984c1a995adcad226c9d5de9bff6c8fb7a..0464942cdd677759e2aa5eb2dfa604a227a80dd9 100644 (file)
@@ -89,7 +89,7 @@ void glutil_draw_front_xor_line(int x0, int y0, int x1, int y1)
 {
        glDrawBuffer(GL_FRONT);
        sdrawXORline(x0, y0, x1, y1);
-       glFinish();
+       glFlush();
        glDrawBuffer(GL_BACK);
 }
 
index d9ce29fad14e3bb65be07fee526e1bacfdff0407..7966355d3d378033244829719ae7590baefda22d 100644 (file)
@@ -248,7 +248,7 @@ static uiSaveUnder *ui_bgnpupdraw(int startx, int starty, int endx, int endy, in
        glDrawBuffer(GL_FRONT);
        
        /* for geforce and other cards */
-       glFinish();
+       glFlush();
 
        su= ui_save_under(startx-1, starty-1, endx-startx+2, endy-starty+6);
        if(su) su->oldwin= oldwin;
@@ -269,7 +269,7 @@ static void ui_endpupdraw(uiSaveUnder *su)
        glReadBuffer(GL_FRONT);
        glDrawBuffer(GL_FRONT);
        
-       glFinish();
+       glFlush();
 
        if(su) {
                ui_paste_under(su);
@@ -1029,7 +1029,7 @@ static int ui_do_but_BUT(uiBut *but)
 
                if (but->flag != oflag) {
                        ui_draw_but(but);
-                       glFinish(); // flush display in subloops
+                       glFlush(); // flush display in subloops
                }
                
                PIL_sleep_ms(10);
@@ -1178,7 +1178,7 @@ static int ui_do_but_TEX(uiBut *but)
        BLI_strncpy(backstr, but->poin, UI_MAX_DRAW_STR);
 
        ui_draw_but(but);
-       glFinish(); // flush display in subloops
+       glFlush(); // flush display in subloops
        
        while (get_mbut() & L_MOUSE) BIF_wait_for_statechange();
        len= strlen(str);
@@ -1274,7 +1274,7 @@ static int ui_do_but_TEX(uiBut *but)
                if(dodraw) {
                        ui_check_but(but);
                        ui_draw_but(but);
-                       glFinish(); // flush display in subloops
+                       glFlush(); // flush display in subloops
                }
        }
        
@@ -1356,7 +1356,7 @@ static int ui_do_but_NUM(uiBut *but)
 
        but->flag |= UI_SELECT;
        ui_draw_but(but);
-       glFinish(); // flush display before subloop
+       glFlush(); // flush display before subloop
        
        uiGetMouse(mywinget(), mval);
        value= ui_get_but_val(but);
@@ -1414,7 +1414,7 @@ static int ui_do_but_NUM(uiBut *but)
                                                ui_set_but_val(but, (double)temp);
                                                ui_check_but(but);
                                                ui_draw_but(but);
-                                               glFinish(); // flush display in subloops
+                                               glFlush(); // flush display in subloops
                                                
                                                uibut_do_func(but);
                                        }
@@ -1438,7 +1438,7 @@ static int ui_do_but_NUM(uiBut *but)
                                                ui_set_but_val(but, tempf);
                                                ui_check_but(but);
                                                ui_draw_but(but);
-                                               glFinish(); // flush display in subloops
+                                               glFlush(); // flush display in subloops
                                        }
                                }
 
@@ -1473,7 +1473,7 @@ static int ui_do_but_NUM(uiBut *but)
        but->flag &= ~UI_SELECT;
        ui_check_but(but);
        ui_draw_but(but);       
-       glFinish(); // flush display in subloops
+       glFlush(); // flush display in subloops
        
        return but->retval;
 }
@@ -1702,7 +1702,7 @@ static int ui_do_but_SLI(uiBut *but)
                        ui_set_but_val(but, tempf);
                        ui_check_but(but);
                        ui_draw_but(but);
-                       glFinish(); // flush display in subloops
+                       glFlush(); // flush display in subloops
                        
                        if(but->a1) {   /* color number */
                                uiBut *bt= but->prev;
@@ -1754,7 +1754,7 @@ static int ui_do_but_SLI(uiBut *but)
        }
        ui_check_but(but);
        ui_draw_but(but);
-       glFinish(); // flush display in subloops
+       glFlush(); // flush display in subloops
        
        return but->retval;
 }
@@ -2157,7 +2157,7 @@ static void edit_but(uiBlock *block, uiBut *but, uiEvent *uevent)
                        but->y2 += dy;
                        
                        ui_draw_but(but);
-                       glFinish();
+                       glFlush();
                        didit= 1;
                        but->rt[3]= 1;
 
@@ -2910,7 +2910,7 @@ static uiSaveUnder *ui_draw_but_tip(uiBut *but)
        glRasterPos2f( x1+3, y1+5);
        BIF_DrawString(but->font, but->tip, (U.transopts & USER_TR_TOOLTIPS));
        
-       glFinish();             /* to show it in the frontbuffer */
+       glFlush();              /* to show it in the frontbuffer */
        return su;
 }
 
@@ -2987,7 +2987,7 @@ int uiDoBlocks(ListBase *lb, int event)
        uevent.event= event;
        uevent.val= 1;
 
-       /* this is a caching mechanism, to prevent too many calls to glFrontBuffer and glFinish, which slows down interface */
+       /* this is a caching mechanism, to prevent too many calls to glFrontBuffer and glFlush, which slows down interface */
        block= lb->first;
        while(block) {
                block->frontbuf= UI_NEED_DRAW_FRONT;    // signal
@@ -3023,7 +3023,7 @@ int uiDoBlocks(ListBase *lb, int event)
                        
                        /* is there a glfinish cached? */
                        if(block->frontbuf == UI_HAS_DRAW_FRONT) {
-                               glFinish();
+                               glFlush();
                                glDrawBuffer(GL_BACK);
                                block->frontbuf= UI_NEED_DRAW_FRONT;
                        }
@@ -3055,7 +3055,7 @@ int uiDoBlocks(ListBase *lb, int event)
 
                        /* need to reveil drawing? (not in end of loop, because of free block */
                        if(block->frontbuf == UI_HAS_DRAW_FRONT) {
-                               glFinish();
+                               glFlush();
                                block->frontbuf= UI_NEED_DRAW_FRONT;
                        }
 
@@ -3095,7 +3095,7 @@ int uiDoBlocks(ListBase *lb, int event)
        /* cleanup frontbuffer & flags */
        block= lb->first;
        while(block) {
-               if(block->frontbuf==UI_HAS_DRAW_FRONT) glFinish();
+               if(block->frontbuf==UI_HAS_DRAW_FRONT) glFlush();
                block->frontbuf= 0;
                block= block->next;
        }
index 89b58337081c998058d7a2dee7a61f13a2a3ba46..3e0909eb99ee1bdd4239390da15c84a5032a77c7 100644 (file)
@@ -349,7 +349,7 @@ void mywinset(int wid)
        glMatrixMode(GL_MODELVIEW);
        glLoadMatrixf(&win->viewmat[0][0]);
 
-       glFinish();
+       glFlush();
        
        curswin= wid;
 }
index 9cf3caa92c9d20e4e92379e3d14d6989e10a0156..cb94d0b327a994316d4e99956212ed93ad7a2eb0 100644 (file)
@@ -288,7 +288,7 @@ static void display_pr_scanline(unsigned int *rect, int recty)
        /* flush opengl for cards with frontbuffer slowness */
        if(recty==PR_RECTY-1 || (PIL_check_seconds_timer() - lasttime > 0.05)) {
                lasttime= PIL_check_seconds_timer();
-               glFinish();
+               glFlush();
        }
 }
 
index 8cc25254a294ea43b2c4c94b0f90183db60dd1aa..3cedfdf6302a57b88d5706781cbc538ca03a659e 100644 (file)
@@ -82,12 +82,12 @@ static void copy_back_to_front(void)
        glDrawBuffer(GL_FRONT);
        glCopyPixels(0, 0, winx, winy, GL_COLOR);
        glDrawBuffer(GL_BACK);
-       glFinish();
+       glFlush();
 
        if (actually_swap) {
                glRasterPos2f(-0.5,-0.5);
                glDrawPixels(winx, winy, GL_RGBA, GL_UNSIGNED_BYTE, data);
-               glFinish();
+               glFlush();
                free(data);
        }
 }
index dc5adb4bc6800988d881de0986bbee9437cf226b..26a947d7022c53e6d2ef6c98907c252224cd9ad7 100644 (file)
@@ -500,7 +500,7 @@ void bgnpupdraw(int startx, int starty, int endx, int endy)
        glReadBuffer(GL_FRONT);
        glDrawBuffer(GL_FRONT);
 
-       glFinish();
+       glFlush();
 
        my_get_frontbuffer_image(startx-1, starty-4, endx-startx+5, endy-starty+6);
 
@@ -512,7 +512,7 @@ void bgnpupdraw(int startx, int starty, int endx, int endy)
 
 void endpupdraw(void)
 {
-       glFinish();
+       glFlush();
        my_put_frontbuffer_image();
        
        if(tboldwin) {
@@ -939,7 +939,7 @@ void drawtoolbox(void)
                        
                }
        }
-       glFinish();             /* for geforce, to show it in the frontbuffer */
+       glFlush();              /* for geforce, to show it in the frontbuffer */
 
 }
 
@@ -1020,7 +1020,7 @@ void toolbox(void)
                                tbox_drawelem(actx, acty, 3);
                        }
                        
-                       glFinish();             /* for geforce, to show it in the frontbuffer */
+                       glFlush();              /* for geforce, to show it in the frontbuffer */
                        
                        xo= actx;
                        yo= acty;