Mac OSX Vsync

Help
stan
2013-06-18
2013-06-25
  • stan

    stan - 2013-06-18

    I don't get vsync with the Mac OSX HexenII version.

    Maybe this might help some OSX HexenII users.

    The only way I've been able to get vsync on my Macbook 1,1 with Intel GMA 950 inbuilt video, is by using Quartz Debug from the Xcode Developers Tools and choosing the Force Beam Sync option, which writes a com.apple.windowserver.plist file into /Library/Preferences with a deferredUpdate value of 2 but it only works if I run Quartz Debug and not if I manually edit deferredUpdate to 2 and when Quartz Debug quits it's back to no vsync.

    Then after enabling vsync (Force Beam Sync) HexenII has to run with a -vsync or -sync option from the terminal using the inside binary which is in it's MacOS folder inside the HexenII app.

    Like this

    exec /Applications/Hexen\ II/Hexen\ II\ gl.app/Contents/MacOS/Hexen_II-gl -sync

    So enabling vsync (Beam Sync) with Quartz Debug and running HexenII with the -sync option from the terminal gives me vsync, otherwise I don't get vsync and the graphics are not that great.

     
    • Levent Yavas

      Levent Yavas - 2013-06-18

      AFAIK in macosx frame rate is always capped to vertical refresh rate aka
      vsync. I have to increase to resolution to bring game refresh rate to 30-50
      fps to measure performance between macosx dos and windows. This was in 10.4
      - 10.5 days.

      If you get same frame rate in 320x240 and 800x600 in recent macosxs' then
      vsync is enabled.

      Levent Yavaş
      KULE Tech. Ltd.
      www.kule.biz
      +90 505 577 0478

      On Tue, Jun 18, 2013 at 7:52 AM, stan maciimacii@users.sf.net wrote:

      I don't get vsync with the Mac OSX HexenII version.

      Maybe this might help some OSX HexenII users.

      The only way I've been able to get vsync on my Macbook 1,1 with Intel GMA
      950 inbuilt video, is by using Quartz Debug from the Xcode Developers Tools
      and choosing the Force Beam Sync option, which writes a
      com.apple.windowserver.plist file into /Library/Preferences with a
      deferredUpdate value of 2 but it only works if I run Quartz Debug and not
      if I manually edit deferredUpdate to 2 and when Quartz Debug quits it's
      back to no vsync.

      Then after enabling vsync (Force Beam Sync) HexenII has to run with a
      -vsync or -sync option from the terminal using the inside binary which is
      in it's MacOS folder inside the HexenII app.

      Like this

      exec /Applications/Hexen\ II/Hexen\ II\ gl.app/Contents/MacOS/Hexen_II-gl
      -sync

      So enabling vsync (Beam Sync) with Quartz Debug and running HexenII with
      the -sync option from the terminal gives me vsync, otherwise I don't get
      vsync and the graphics are not that great.


      Mac OSX Vsynchttps://sourceforge.net/p/uhexen2/discussion/425207/thread/ad200c39/?limit=50#12b0

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/uhexen2/discussion/425207/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • stan

    stan - 2013-06-18

    I'm using Snow Leopard 10.6.8.

    On My Mac, the OSX vsync has some sort of disconnect with the HexenII vsync unless I force "Beam Sync" on with Quartz Debug.

    Funnily enough, the older Carbon version of HexenII has a vsync option in the HexenII options menu and it syncs to vsync just fine on OSX without having to force "Beam Sync" on with Quartz Debug.

    Also on my Linux Mint PC's (Mate versions), I have to enable Nvidia vsync to get smooth graphics with HexenII and on the Linux Mint Cinnamon version I have to also sync the window manager to vsync otherwise there is a vsync disconnect between the window manager and HexenII, very similar to my OSX Mac case.

     
    Last edit: stan 2013-06-18
    • Levent Yavas

      Levent Yavas - 2013-06-19

      ok, could you do a timedemo test in lowest resolution of your system
      allows? (open up hexen 2 console and write "timedemo demo1" and press
      enter. after completing demo it will write how many frames per second it
      could display)

      Levent Yavaş
      KULE Tech. Ltd.
      www.kule.biz
      +90 505 577 0478

      On Tue, Jun 18, 2013 at 6:29 PM, stan maciimacii@users.sf.net wrote:

      I'm using Snow Leopard 10.6.8.

      On My Mac, the OSX vsync has some sort of disconnect with the HexenII
      vsync unless I force "Beam Sync" on with Quart Debug.

      Funnily enough, the older Carbon version of HexenII has a vsync option in
      the HexenII options menu and it syncs to vsync just fine.

      Also on my Linux Mint PC's (Mate versions), I have to enable Nvidia vsync
      to get smooth graphics with HexenII and on the Linux Mint Cinnamon version
      I have to also sync the window manager to vsync otherwise there is a vsync
      disconnect between the window manager and HexenII, very similar to my OSX
      Mac case.


      Mac OSX Vsynchttps://sourceforge.net/p/uhexen2/discussion/425207/thread/ad200c39/?limit=25#2e9b

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/uhexen2/discussion/425207/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • stan

    stan - 2013-06-21

    Intel Core Duo 1.83 Ghz, inbuilt Intel GMA950 Graphics set at 1280x800, Snow Leopard 10.6.8, 1GB Ram.

    Vsync (Beam Sync) forced on and Quartz2D enabled.

    Vsync forced on smooths out graphics in window mode.


    Fullscreen 640x480

    2498 frames

    15.4 sec

    161.8 fps


    Fullscreen 800x600

    2498 frames

    18.7 sec

    133.4 fps


    Window 640x480

    2498 frames

    43.5 sec

    57.5 fps


    Window 800x600

    2498 frames

    68.5 sec

    36.5 fps

     
    Last edit: stan 2013-06-21
    • Levent Yavas

      Levent Yavas - 2013-06-21

      Results are weird. Fullscreen mode really seems to doesn't do vsync. But
      windowed modes are far too slow. Especially windowed mode 800x600 mode seem
      too slow for your kind of machine. These results are from OpenGL versions
      aren't they? Thank you by the way.

      Levent Yavaş
      KULE Tech. Ltd.
      www.kule.biz
      +90 505 577 0478

      On Fri, Jun 21, 2013 at 10:20 AM, stan maciimacii@users.sf.net wrote:

      Intel Core Duo 1.83 Ghz, inbuilt Intel GMA950 Graphics, Snow Leopard
      10.6.8, 1GB Ram.

      Vsync (Beam Sync) forced on and Quartz2D enabled.

      Vsync forced on smooths out graphics in window mode.

      Fullscreen 640x480

      2498 frames

      15.4 sec

      161.8 fps

      Fullscreen 800x600

      2498 frames

      18.7 sec

      133.4 fps

      Window 640x480

      2498 frames

      43.5 sec

      57.5 fps

      Window 800x600

      2498 frames

      68.5 sec

      36.5 fps

      Mac OSX Vsynchttps://sourceforge.net/p/uhexen2/discussion/425207/thread/ad200c39/?limit=50#1b65

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/uhexen2/discussion/425207/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • stan

    stan - 2013-06-22

    Yeah, the results are weird.

    They are for the openGL version.

    I really don't think I've got vsync enabled, but I thought I did have vsync enabled but it seems that something has gone a bit strange in the drivers maybe, and the window modes just slowed down a lot for some reason when I was trying to get vsync enabled.

    On my other Mac which is the same spec, I get much faster windowed frames per second and I also can't enable vsync on it and I get the old screen smudged graphics routine.

    When I've had the smudged graphics on LCD displays on Linux, enabling vsync fixes it.

    Vsync on the Mac is a bit of a mystery.

     
    Last edit: stan 2013-06-22
  • stan

    stan - 2013-06-22

    I looked into the source code and it appears that HexenIIgl is using SDL for opengl.

    I then looked into the SDL vsync function

    SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);

    and it doesn't work on OSX.

    Then I tried this code below which does enable vsync on OSX.


    include OpenGL/CGLTypes.h (I had to drop the usual # and <> from the header file text because of formatting problems when posting code in this forum)

    CGLContextObj ctx = CGLGetCurrentContext();
    const long interval = 1;

    CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);

    // And to disable vsync set interval = 0.


    I've currently put the code at the end of the

    static int VID_SetMode (int modenum)

    function in the gl_vidsdl.c source file


    SDL_WM_SetCaption(WM_TITLEBAR_TEXT, WM_ICON_TEXT);
    
    //SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
    
    CGLContextObj   ctx = CGLGetCurrentContext();
    const long   interval = 1;
    
    CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);
    
    IN_HideMouse ();
    
    in_mode_set = false;
    
    return true;
    

    }


    because I don't currently know the best place to put it in the code.

    Anyway it works and there is no more screen tearing in fullscreen or window modes.

    The vsync code could be tied into a HexenII menu option.

     
    Last edit: stan 2013-06-22
    • Levent Yavas

      Levent Yavas - 2013-06-22

      alright, congratulations :) and thank you.

      Ozkan or Steven will merge your code into sources I think.

      After merge I would like to know how FPS's will changed.

      Levent Yavaş
      KULE Tech. Ltd.
      www.kule.biz
      +90 505 577 0478

      On Sat, Jun 22, 2013 at 6:23 PM, stan maciimacii@users.sf.net wrote:

      I looked into the source code and it appears that HexenIIgl is using SDL
      for opengl.

      I then looked into the SDL vsync function

      SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);

      and it doesn't work on OSX.

      Then I tried this code below which does enable vsync on OSX.
      include CGLTypes.h>

      CGLContextObj ctx = CGLGetCurrentContext();
      const long interval = 1;

      CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);

      // And to disable vsync I set interval = 0.

      I've currently put the code at the end of the

      static int VID_SetMode (int modenum)

      function

      SDL_WM_SetCaption(WM_TITLEBAR_TEXT, WM_ICON_TEXT);
      //SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
      CGLContextObj ctx = CGLGetCurrentContext();const long interval = 1;
      CGLSetParameter(ctx, kCGLCPSwapInterval, &interval);
      IN_HideMouse ();
      in_mode_set = false;
      return true;

      }

      because I don't currently know the best place to put it in the code.

      Anyway it works and there is no more screen tearing in fullscreen or
      window modes.

      The vsync code could be tied into a HexenII menu option.

      Mac OSX Vsynchttps://sourceforge.net/p/uhexen2/discussion/425207/thread/ad200c39/?limit=25#1da1

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/uhexen2/discussion/425207/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • stan

    stan - 2013-06-23

    Thanks for your help.

     
  • Ozkan Sezer

    Ozkan Sezer - 2013-06-24

    Thanks for the suggested code.

    The problem with SDL_GL_SetAttribute() is that, AFAICS, it needs
    calling before SDL_SetVideoMode() and not after it. This is the
    thing we do in QuakeSpasm, and it is reported to work on OSX, and
    I am willing to merge a similar code in uHexen2. Can you please
    test that? If it fails, I'll go using your suggestion.

     
  • stan

    stan - 2013-06-24

    I put SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); just before

    screen = SDL_SetVideoMode (modelist[modenum].width, modelist[modenum].height, bpp, flags);

    in gl_vidsdl.c

    and vsync worked.

    if (multisample)
    {
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multisample);
    }
    
    Con_SafePrintf ("Requested mode %d: %dx%dx%d\n", modenum, modelist[modenum].width, modelist[modenum].height, bpp);
    
    VID_SetIcon();
    
    SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
    
    screen = SDL_SetVideoMode (modelist[modenum].width, modelist[modenum].height, bpp, flags);
    if (!screen)
    {
        if (!multisample)
        {
            Sys_Error ("Couldn't set video mode: %s", SDL_GetError());
        }
        else
        {
            Con_SafePrintf ("multisample window failed\n");
            multisample = 0;
            SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
            SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, multisample);
            screen = SDL_SetVideoMode (modelist[modenum].width, modelist[modenum].height, bpp, flags);
            if (!screen)
                Sys_Error ("Couldn't set video mode: %s", SDL_GetError());
        }
    }
    
     
    Last edit: stan 2013-06-24
  • Ozkan Sezer

    Ozkan Sezer - 2013-06-24

    Thanks. I'll prepare a patch and update the svn as soon as I am
    able to. When I do it, I will prepare a test-build for OSX and
    report back here.

     
  • stan

    stan - 2013-06-25

    I've done a HexenII OSX only version with the vsync option in the Options/ Video Modes menu just below the Antialising item.

    It sets vsync on or off and then the vsync state gets applied on the fly through the apply changes item and there is no need for a restart of the game or HexenII.

    The reset changes item also changes the vsync state back to what it was originally.

    Seems to work ok.

    The changes are just in the gl_vidsdl.c file.

    The changes are in the Hexen2 1.5.6 source gl_vidsdl.c.zip attachment below in the #if defined(PLATFORM_OSX) sections.

     
    Last edit: stan 2013-06-25

Log in to post a comment.