RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    New emulation method to eliminate input lag

    Scheduled Pinned Locked Moved General Discussion and Gaming
    libretroinput lag
    44 Posts 11 Posters 20.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mediamogulM
      mediamogul Global Moderator @tekn0
      last edited by mediamogul

      @tekn0 said in New emulation method to eliminate input lag:

      I personally just keep it at 2 frames. That seems to be a sweet spot for all the games I tested.

      There's talk of including the amount of lag each game has in a downloadable database that would set each automatically. You should be fine with 2 frames in many, maybe even most situations. However, keep in mind that by overextending the run-ahead, you're still going to run into timing problems in some games. The only difference is that your character will overreact a frame or two early by skipping frames of action instead of the normal problem of being a frame or two late. Still, having your timing off by such a small amount in either direction isn't that big of a deal in most games.

      RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

      1 Reply Last reply Reply Quote 0
      • mediamogulM
        mediamogul Global Moderator @mediamogul
        last edited by mediamogul

        @mediamogul said in New emulation method to eliminate input lag:

        After running the test, 'Mike Tyson's Punch-Out!!' had a whopping, yet unsurprising five frames of lag.

        After playing a few rounds against 'Kid Dynamite' last night, I started to notice that on occasion, he would nail me with an uppercut before my character had actually moved back from a successful dodge. I believe this is happening because the current lag test fails to consider an animation cycle with intentional delay. By me employing a run-ahead of five frames, based on viewing the basic jab animation, of which three frames were apparently intended to be inactive, my run-ahead was over-extended for those three frames, which led to 'Iron Mike' punching me from a future that wasn't supposed to exist.

        If I'm correct, this illustrates the timing problems that can arise by having run-ahead over-extended. The solution is to test for lag on a clear cut example of a visual cue taking place when a button is pressed. For 'Mike Tyson's Punch-Out!!', I retested at the title card screen, where pressing 'start' is obviously intended to roll the card upward and start the match. Here, the game showed only two frames of lag that, while much less than before, is still twice that of most other NES titles.

        RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

        quicksilverQ 1 Reply Last reply Reply Quote 1
        • quicksilverQ
          quicksilver @mediamogul
          last edited by

          @mediamogul said in New emulation method to eliminate input lag:

          @mediamogul said in New emulation method to eliminate input lag:
          By me employing a run-ahead of five frames, based on viewing the basic jab animation, of which three frames were apparently intended to be inactive, my run-ahead was over-extended for those three frames, which led to 'Iron Mike' punching me from a future that wasn't supposed to exist.

          0_1526658497831_495012a1-126d-43c8-9649-6007e2bdf21b-image.png

          1 Reply Last reply Reply Quote 2
          • mediamogulM
            mediamogul Global Moderator @tekn0
            last edited by mediamogul

            @tekn0 said in New emulation method to eliminate input lag:

            Hopefully one day a snes9x patch could allow this feature to run on the pi3.

            I believe lr-snes9x may have room to be optimized for this feature. After reading a bit about it directly over at the libretro forums, it seems that most SNES games have an inherent 2 frames of lag. Once run-ahead was enabled, my framerate dropped to between 32 and 37 FPS. What's interesting though, is once I enabled a second instance, the framerate picked up to a steady 53-58 FPS.

            Prior to release, everyone assumed the real killer to Pi performance would be the second instance, but while admittedly taxing, it doesn't appear to be a huge problem. In fact, I've found that it irons out quite a few issues, such as speed, corrupted graphics and sound. If lr-snes9x and it's counter-parts were to perhaps be further optimized for the necessary barrage of save states it requires to run this, SNES run-ahead on the Pi could be a real possibility. What's more, it would likely have the side-affect of allowing much smoother Pi Netplay support.

            In the interest of transparency, I tested lr-snes9x2010 with no shaders or overlays enabled, at my typical render size of 800x600 with a run-ahead of two frames, both with and without a second instance. Here, I only used one test game, which was 'Super Star Wars'. I imagine framerate would be further impacted by Super FX/2 chip titles, as well as games utilizing transparency blending, such as 'Jurassic Park' and 'Kirby’s Dreamland 3'.

            RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

            1 Reply Last reply Reply Quote 0
            • mediamogulM
              mediamogul Global Moderator
              last edited by mediamogul

              Here's a very positive development for lr-snes2010 on the Pi3b. I had read that some improvements were recently made to optimize for run-ahead, so I updated from source and was surprised to find that almost all games will now run at 60FPS. I did see the occasional momentary dip to 59.7, but it didn't happen often. This time I did all my tests at 1920x1080 and everything still managed to hold up as long as I had a second instance enabled. Once the second instance was deactivated, the frame rate plummeted. I also tested a few of the potential troublemakers noted above and there's no surprise that they didn't do nearly as well. Below are the lowest and highest frame rate I got with each of those tests.

              'Star Fox' - 52-58 FPS
              'Star Fox 2' - 43-51 FPS
              'Super Mario World 2: Yoshi's Island' - 43-56 FPS
              'Jurassic Park' - 50-57 FPS (With transparency blending) 59.7- 60.2 (Without)
              'Kirby's Dream Land 3' - 46-55 FPS (With transparency blending) 59.7- 60.2 (Without)

              Every other game tried (ten or so) - 59.7- 60.2

              RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

              1 Reply Last reply Reply Quote 0
              • DarksaviorD
                Darksavior
                last edited by Darksavior

                I tried Genesis Plus GX again from source and that works. Again, like fceumm, it gets jerky in controls and tearing when the screen scrolls if you go to 3-4 (and it's 60fps all the time) so I keep it at 2.

                For snes9x-2010 (built from source), I'll keep it off. It varies way too much per game and I'm lazy to thoroughly test each one. My usual go-to game to test is Megaman X 1's Octopus water level. ~45fps with run-ahead set to 1. I also have speed hacks on "compatible" which is a bigger game changer than this run-ahead thing:P

                pce-fast (also from source) works with 2 but I get frame drops at 3 which means this emulator is probably not optimized for it.

                I'm using a pi3b+ oc'd to 1.5ghz at 1080p with crt-pi shader.

                mediamogulM 1 Reply Last reply Reply Quote 0
                • mediamogulM
                  mediamogul Global Moderator @Darksavior
                  last edited by mediamogul

                  @darksavior said in New emulation method to eliminate input lag:

                  like fceumm, it gets jerky in controls and tearing when the screen scrolls if you go to 3-4
                  For snes9x-2010 (built from source), I'll keep it off. It varies way too much per game
                  pce-fast (also from source) works with 2 but I get frame drops at 3

                  Are you activating the second core instance for these situations? It's probably a good idea just to leave it on in all situations, as the benefits are huge and according to the developer, there aren't really any drawbacks. If there's still an issue, it may be the crt-pi shader.

                  RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                  DarksaviorD 1 Reply Last reply Reply Quote 0
                  • DarksaviorD
                    Darksavior @mediamogul
                    last edited by

                    @mediamogul I'm not enabling the second core. Is there a difference?

                    mediamogulM 1 Reply Last reply Reply Quote 0
                    • mediamogulM
                      mediamogul Global Moderator @Darksavior
                      last edited by mediamogul

                      @darksavior said in New emulation method to eliminate input lag:

                      Is there a difference?

                      Definitely. Without it being active, I get a drop of 20-30 FPS past a 2 frame run-ahead in both lr-fceumm and lr-snes2010 (The only two cores I've tested). I'm actually able to get a steady 60 FPS with no stutter in lr-fceumm with 5 frames of run-ahead and rewind enabled, which of course is a decent hit to the processor in and of itself.

                      RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                      DarksaviorD 1 Reply Last reply Reply Quote 0
                      • DarksaviorD
                        Darksavior @mediamogul
                        last edited by Darksavior

                        @mediamogul Ah ok, that helps a bit. Unfortunately, even with the crt-pi shader off, I still notice and feel the jerkyness when set to 3 or 4 (really noticeable at 4) on fceumm/genesis gx so I'll leave both instances enabled at 2. I have the overclock setting on for NES which it's really needed in megaman 3 and probably tons of others.

                        It also doesn't help when I enable the fix slowdown hack in snes9x2010, which I'll need to turn off and actually look into what games actually need it. So far it's just super rtype.

                        mediamogulM 1 Reply Last reply Reply Quote 0
                        • mediamogulM
                          mediamogul Global Moderator @Darksavior
                          last edited by mediamogul

                          @darksavior

                          Interesting. Results with run-ahead on the Pi may end up varying greatly with users, depending on a number of factors. Fortunately for you specifically, if you do plan to continue using it, 1-2 frames generally seems to be all that is needed in most cases.

                          RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                          1 Reply Last reply Reply Quote 0
                          • Keltron3030K
                            Keltron3030
                            last edited by

                            Are these input lag settings available on 1.7.1?

                            dankcushionsD 1 Reply Last reply Reply Quote 0
                            • dankcushionsD
                              dankcushions Global Moderator @Keltron3030
                              last edited by

                              @keltron3030 no

                              1 Reply Last reply Reply Quote 0
                              • Keltron3030K
                                Keltron3030
                                last edited by

                                Shouldn't updating retroarch from source get me to 1.7.3? It still shows 1.7.1 on the GUI. Sorry for a likely dumb question.

                                dankcushionsD 1 Reply Last reply Reply Quote 0
                                • dankcushionsD
                                  dankcushions Global Moderator @Keltron3030
                                  last edited by

                                  @keltron3030 you have to update your retropie-setup script first.

                                  Keltron3030K 2 Replies Last reply Reply Quote 0
                                  • Keltron3030K
                                    Keltron3030 @dankcushions
                                    last edited by

                                    @dankcushions

                                    Oh, got it thanks. Now I'm on 1.7.3 and I see latency settings; thanks. Now my hot keys don't work, dammit! 🤪

                                    1 Reply Last reply Reply Quote 0
                                    • mediamogulM
                                      mediamogul Global Moderator
                                      last edited by mediamogul

                                      In trying to read as much as I can to understand run-ahead better, I found where the developer of the feature (Dwedit) has stated that a setting of 1 frame of run-ahead "should almost always be safe" in games that have inherent latency. This likely only excludes Atari 2600 titles, as there is no inherent latency for those games, by nature of how they were programmed, so naturally run-ahead would have no benefit there.

                                      RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                                      1 Reply Last reply Reply Quote 0
                                      • Keltron3030K
                                        Keltron3030 @dankcushions
                                        last edited by

                                        @dankcushions

                                        Oh, it's awesome. Totally fixed Contra and MegaMan 2 for me. Thanks guys for pointing this out.

                                        mediamogulM 1 Reply Last reply Reply Quote 0
                                        • mediamogulM
                                          mediamogul Global Moderator @Keltron3030
                                          last edited by

                                          @keltron3030 said in New emulation method to eliminate input lag:

                                          Totally fixed Contra and MegaMan 2 for me.

                                          Last night I held my own and survived all three rounds against Mike Tyson for my first time ever. Of course he won by decision, but my next goal is to "git gud" and send him to the mat with a second round TKO.

                                          RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                                          1 Reply Last reply Reply Quote 0
                                          • pjftP
                                            pjft @mediamogul
                                            last edited by

                                            @mediamogul Thank you for the detailed response. I was hoping there'd be a stable "default-ish" setup that would work for the majority of cases in each system, and then I'd adjust the ones for which it didn't work.

                                            From reading your developments, I believe 2 might hopefully be the right value for nes, genesis, and potentially snes as you're describing - with the 2nd core, of course.

                                            I'll dig into that in the coming week, many thanks all!

                                            mediamogulM 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.