Menu

poor FPS

Lazarus
pl
2023-01-12
2023-01-13
  • pl

    pl - 2023-01-12

    hi all friends.
    I'm using Lazarus 2.2.4 and GLscene.
    I've built a basic scene with 1 GLcube only. My FPS is about 66 (Mode=cmASAP)
    What's wrong with my settings there ? My old delphi demos run at 1000 FPS.
    intel xeon(R) CPU E3-1245 v6 3.7 GHz. 8G0 RAM.W10 pro 64bits

     

    Last edit: pl 2023-01-12
  • pl

    pl - 2023-01-12

    when Lazarus only is open, it runs at 60 FPS in average. Then if I open my web browser (while the app still runs) it increases at 300 FPS. If I close the app and run it again (while the browser is still open) it's still 300 FPS sometimes up to 480 FPS. when I close the browser and restart the demo it's 60FPS again.

     

    Last edit: pl 2023-01-12
  • shine world

    shine world - 2023-01-12

    Are you on Windows ?

     
  • pl

    pl - 2023-01-12

    yes w10
    GeForce GTX 1050Ti
    run without debugging (maj+ctrl+f9) all optimization options tested for compil

     

    Last edit: pl 2023-01-12
  • shine world

    shine world - 2023-01-12

    Try to place this line at start of your program:

    ~~~
    var
    TimeCaps: TTimeCaps;
    NeedToChangeTimerPrecsion: Boolean;

    // starts high precision timer
    if timeGetDevCaps(@TimeCaps, SizeOf(TTimeCaps)) = TIMERR_NOERROR then
      NeedToChangeTimerPrecsion := timeBeginPeriod(TimeCaps.wPeriodMin) = TIMERR_NOERROR;
    
    ... main loop
    
     ... before to exit program
    
    // stops high precision timer
    if NeedToChangeTimerPrecsion then
      timeEndPeriod(TimeCaps.wPeriodMin);
    

    ~~~

    This improve precision and quantum of single tick time ...

     

    Last edit: shine world 2023-01-12
  • pl

    pl - 2023-01-12

    TimeCaps: TTimeCaps;
    what is it for a class ? identifier not found

     
  • pl

    pl - 2023-01-12

    mode=cmApplicationIdle => 3000 FPS

     

    Last edit: pl 2023-01-12
  • shine world

    shine world - 2023-01-12

    in Delphi the unit MMSystem permits to change the timecaps of system (in W10/11 the timecaps of process).

    Usually any timing in W10 uses 50ms so also if you set a timer at 1ms the OS will raise it in >50ms time.
    Some program, however, force the timeEndPeriod to 1ms or at minimum accepted value, to imporve performances.

    Delphi IDE does that.
    So if you run a common program code in IDE run moooore fast than run it with IDE not running.
    I guess browser does same thing.

    https://learn.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timeendperiod

     

    Last edit: shine world 2023-01-12
  • shine world

    shine world - 2023-01-12

    This is with Lazarus:

     
  • pl

    pl - 2023-01-12
    Error: identifier not found "TTimecaps"
    

    you may be use a lib that I don't

     
  • shine world

    shine world - 2023-01-12

    Check the previous image: add MMSystem to the list of uses.

     

    Last edit: shine world 2023-01-12
    • Pavel Vassiliev

      Pavel Vassiliev - 2023-01-13

      Shine world,
      by the way, in the Landscape package by Alex Hirtzel in the last LandscapeArchipelago demo now Idle:0 after moving from delphi 7 to rad studio and the sea waves almost froze in place.
      https://sourceforge.net/p/glscene/code/HEAD/tree/branches/Examples/Terrains/LandscapePackage/04-FractalArchipelago/
      I can't find the reason. Send a hint if you have any ideas about how to improve the FPS there.

       
      • shine world

        shine world - 2023-01-13

        I've have only to change GLAsyncTimer1 from 700ms to 1ms.
        With timeBeginPeriod, that you have already inserted in sources, you say to Windows:
        "Hey OS, I want more precision in ticks that you use to send WM_TIMER messages, i THREAD switch contexts, etc, don't use your 50ms base default timings".

        DO NOT PLACE timeBeginPeriod/timeEndPeriod in a LIBRARY.
        It's a System(Till W10 21Hxxx)/Process(W10 22Hxx and W11) singleton setting.
        Just place, when you want in EXE program.

        You can try the exe and sea animation is very FLUID.

        I've tried FPS with and without timeBeginPeriod:

        WITHOUT = FPS 65
        WITH = FPS 328

        In zip changes and two 32-bits exe (with and without)

         

        Last edit: shine world 2023-01-13
        • Pavel Vassiliev

          Pavel Vassiliev - 2023-01-13

          Ok, fast FPS and good waves in the sea, but in this case now problems appear with navigation keys and running stops with shift + forward key.
          Pavel

           
          • shine world

            shine world - 2023-01-13

            I saw....
            This happens when moving with cursors one of coords back to 0 value...
            I guess is a bug in code.

            Moving back an Exception is raised:

             

            Last edit: shine world 2023-01-13
            • shine world

              shine world - 2023-01-13

              Disabilig this line seem to work:
              I don't know what FractalArchip.Update do inner but seem a TLlist wrong Index (-1)

               

              Last edit: shine world 2023-01-13
              • shine world

                shine world - 2023-01-13

                Moving BACK a List index become negative (-1) and raise an excaption wich block all.
                I've inserted a conditional breakpoint with maxi < 0 to catch it.

                 
                • Pavel Vassiliev

                  Pavel Vassiliev - 2023-01-13

                  Shine world,
                  Ok, you're very fast with GExpert so good. I'm planning to use this fractal landscape procedure to generate the surfaces of exoplanets instead of manual/or together editing like in AIPlanets, that is on spheres type like TGLFreeform, but we need to adapt the GLS.RandomHDS for this. Thanks.
                  Pavel

                   

                  Last edit: Pavel Vassiliev 2023-01-13
  • pl

    pl - 2023-01-13

    You are right. This really helps (I remember now having used MMsystem many years ago with Delphi for memory management). With your tip, in mode cmASAP it runs at 500 FPS instead of 60 FPS. Thks

     

    Last edit: pl 2023-01-13

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.