Re: [AD] BUG(?): Page flipping and vsync

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> > In fullscreen mode, page-flipping really means flipping two pages
> > of video
> > memory, i.e moving the point in video memory from which the video card
> > starts to send data to the monitor. In order to make sure that the flip
> > doesn't happen in the middle of the screen retrace, we have to
> > wait for the
> > hotspot to be at the bottom of the screen.
>
> The same is true when windowed.

Huh... no, it isn't. We simply can't flip the primary surface because we have 
not requested the DirectDraw exclusive mode. We use a couple of backbuffers 
which are alternatively block-copied onto the portion of the primary surface 
that makes up the window.

> > In windowed mode, we don't use two pages of video memory because
> > we need to
> > preserve the Windows desktop around the window. So we _emulate_
> > page-flipping by using a backbuffer which is block-copied onto the
> > screen when the flip() method is invoked. To sum up, page-flipping is
> > actually double-buffering in windowed mode and we don't need to bother
> > with the vertical retrace when double-buffering because the video card
> > does it for us.
>
> I doubt this.

Take a look at src/win/wddwin.c:gfx_directx_show_video_bitmap_win(). The 
flipping operation is not done until after the call to update_window(NULL). 
And update_window() is the update function of the underlying dirty rectangle 
mechanism

> When doing page-flipping in windowed mode I get over 300 FPS (320*240*32).
> I tested displaying two coloured buffers, one (255, 0, 255) and the other
> (0, 255, 0). When windowed it heavily flickers: green and purple bars
> moving all over the place. It's the same effect you'd get with regular
> page-flipping: A part of the videocard's buffer gets sent to the monitor,
> we update the videocard's buffer, another part is sent, ...

Ok, you probably have a fast machine/fast video card. I thought DirectDraw 
made sure that a single block-blitting operation would always be "synced" 
but it appears that I'm wrong.

> I have to call vsync manually to stop it from flickering and get a 'nice'
> grayish colour. I don't have to do this with the fullscreen driver, so the
> (added) call to vsync will do a double vsync and I get only 30 FPS.
>
> IMHO the windowed driver should implement vsync too.

Yes, I'm now leaning towards your viewpoint. Does the attached patch for the 
4.1.x series fit your needs?

-- 
Eric Botcazou
--- /cvs/allegro/src/win/wddwin.c	Thu Nov 21 23:17:12 2002
+++ allegro/src/win/wddwin.c	Tue Feb 18 19:30:48 2003
@@ -478,6 +478,7 @@
    bmp->write_bank = gfx_directx_write_bank_win;
 
    /* display the new contents */
+   gfx_directx_sync();
    update_window(NULL);
 
    return 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/