[uae] Re: SDL and Vsync

  • From: Richard Drummond <evilrich@xxxxxxxxxxxxxx>
  • To: uae@xxxxxxxxxxxxx
  • Date: Fri, 17 Feb 2006 23:42:20 -0500

Hi Fari

On Friday 17 February 2006 03:56, fari mueller wrote:
> Well what to say ... we have a slightly different
> focus in this point. My arcademonitor is running at
> 50Hz, that means I wont have any timing problems or
> performance decrease - my problem is just implementing
> the doublebuffering in SDL, that's why I'm bothering
> you with this stuff - Yes, I know I'm selfish, shame
> on me ;-)

Hehe! Fair enough. Try the attached patch.

If your display is 50Hz, then you'll probably find that you'll end up waiting 
twice per frame (E-UAE waits once, SDL_Flip() waits once for each frame).

If that happens, you should be able fix that by setting somewhere

currprefs.gfx_vsync = 1
currprefs.gfx_refreshrate = 50

You could hack these into the start of the function init_hz() in custom.c, for 
instance.

Cheers,
Rich
Index: src/gfx-sdl/sdlgfx.c
===================================================================
RCS file: /cvsroot/uaedev/uae/src/gfx-sdl/sdlgfx.c,v
retrieving revision 1.27
diff -u -r1.27 sdlgfx.c
--- src/gfx-sdl/sdlgfx.c        22 Aug 2005 04:43:12 -0000      1.27
+++ src/gfx-sdl/sdlgfx.c        18 Feb 2006 04:39:30 -0000
@@ -365,6 +365,7 @@
 
 static void sdl_flush_screen (struct vidbuf_description *gfxinfo, int 
first_line, int last_line)
 {
+       SDL_Flip(prSDLScreen);
 }
 
 
@@ -485,7 +486,9 @@
     if (bitdepth == 8)
        uiSDLVidModFlags |= SDL_HWPALETTE;
     if (fullscreen)
-       uiSDLVidModFlags |= SDL_FULLSCREEN;
+       uiSDLVidModFlags |= SDL_FULLSCREEN | SDL_HWSURFACE;
+    if (!screen_is_picasso)
+       uiSDLVidModFlags |= SDL_DOUBLEBUF;
 #ifdef PICASSO96
    if (hwsurface_is_profitable && screen_is_picasso)
        uiSDLVidModFlags |= SDL_HWSURFACE;
@@ -519,7 +522,7 @@
            gfxvidinfo.lockscr     = sdl_lock;
            gfxvidinfo.unlockscr   = sdl_unlock;
            gfxvidinfo.flush_block = sdl_flush_block;
-       } else {
+       } else {
            gfxvidinfo.lockscr     = sdl_lock_nolock;
            gfxvidinfo.unlockscr   = sdl_unlock_nolock;
            gfxvidinfo.flush_block = sdl_flush_block_nolock;
@@ -547,17 +550,27 @@
 #endif
            /* Initialize structure for Amiga video modes */
            if (is_hwsurface) {
-               gfxvidinfo.bufmem       = 0;
-               gfxvidinfo.emergmem     = malloc (prSDLScreen->pitch);
-           } else {
-               gfxvidinfo.bufmem       = prSDLScreen->pixels;
-               gfxvidinfo.emergmem     = 0;
+              if (SDL_MUSTLOCK(prSDLScreen) && (SDL_LockSurface(prSDLScreen) < 
0))
+                  is_hwsurface = FALSE;
+               else {
+                   gfxvidinfo.flush_screen  = sdl_flush_screen;
+                   gfxvidinfo.bufmem        = 0;
+                   gfxvidinfo.emergmem      = malloc (prSDLScreen->pitch);
+                   gfxvidinfo.maxblocklines = 0;
+                   SDL_UnlockSurface(prSDLScreen);
+               }
+           }
+
+           if (!is_hwsurface) {
+               gfxvidinfo.bufmem        = prSDLScreen->pixels;
+               gfxvidinfo.emergmem      = 0;
+               gfxvidinfo.maxblocklines = 1000;
            }
            gfxvidinfo.linemem          = 0;
            gfxvidinfo.pixbytes         = prSDLScreen->format->BytesPerPixel;
            bit_unit                    = prSDLScreen->format->BytesPerPixel * 
8;
            gfxvidinfo.rowbytes         = prSDLScreen->pitch;
-           gfxvidinfo.maxblocklines    = 1000;
+
 
            SDL_SetColors (prSDLScreen, arSDLColors, 0, 256);
 

Other related posts: