100% Lagless Emulation is Here!

A place where you can chat about anything that isn't to do with games!
User avatar
casualcoder
Posts: 346
Joined: Sat Apr 21, 2012 4:35 am
Location: West Coast, Canada

100% Lagless Emulation is Here!

Post by casualcoder »

I'm really not sure why I'm not seeing much talk about this. I thought this 'development' would be ALL around this forum.

What I'm referring to is 100% lagless emulation in the recent version of Retroarch.

For those that don't know: I'm not meaning zero ADDED input lag. I mean, less lag than the original hardware. Your inputs get read on frame 1 and sent to frame 1. This is huge.


I looked into it this weekend thinking it was too good to be true but, indeed all of my favorite games were reduced to zero lag.

In the most convincing cases I looked at Guwange and Metal Slug 3, both have 3 frames of built-in lag. You can easily find this out using the tools in Retroarch.

To compensate I subtracted 3 frames. The difference is immense. I can blaze through Guwange much easier (not that it was all that difficult before, but now it's even better and noticeable immediately).

On my 5ms Asus 1080p monitor I have <1 frame of total lag which is way less than you'd get on CRT + Original Hardware.


I will update this posting with some instructions/guides if you guys want (there is a bit of setup involved, including per-game settings but it's easy).

Now that I've discovered this I can't go back to the emulation alternatives (my go-to was Shmupmame).

I'll also add that this works across ALL emulation in Retroarch. It works with all core types. So you can use on FinalBurn, Mame, SNES, GBA, PS1... everything.

Also, I run it on an old dual-core system with a 6450HD AMD graphics card. Really low-level stuff and I've gotten it all to work without any frame drops (max 50% CPU usage) on even the most demanding emulations pre-2010's era.
bigbadboaz
Posts: 1135
Joined: Mon Feb 14, 2005 4:08 am
Location: Los Angeles, CA

Re: 100% Lagless Emulation is Here!

Post by bigbadboaz »

I've heard about this and have been wondering, honestly, why is this a good thing and why doesn't anyone else seem to be picking up on it?

Hasn't the goal always been accuracy? And haven't we long noted - particularly here on the Shmups forum - that games created by the very best talent were built with hardware limitations in mind? I.e., if there are 3 frames of lag on native hardware in a top shmup, the level design is probably built around that degree of sensitivity.

Changing response lag in either direction can break a game based on speed and reflexes. Naturally, as emulation has been built and improved the challenge to this point has always been to match speed with original hardware. But now that we can, apparently, actually push back in the other direction, we need to ask if this is actually a good thing.

If we can create emulation with this much speed now, the goal should be absolute accuracy/parity with real hardware - NOT to exceed. This both preserves accuracy (which will only become more important as more and more original HW dies in the coming years) and preserves developers' visions with the original games.

I'm interested to hear what others have to say, but I think it's clear that this particular advance goes too far, and easily past the point of being an improvement.
User avatar
Shepardus
Posts: 3505
Joined: Sat Dec 13, 2014 10:01 pm
Location: Ringing the bells of fortune

Re: 100% Lagless Emulation is Here!

Post by Shepardus »

bigbadboaz wrote:If we can create emulation with this much speed now, the goal should be absolute accuracy/parity with real hardware - NOT to exceed. This both preserves accuracy (which will only become more important as more and more original HW dies in the coming years) and preserves developers' visions with the original games.
People don't seem to mind the 360 port of Futari... And please, even if input lag was a known thing developers had to deal with, I would hardly call it a part of their "vision." Play the games however you want, one person pursuing lag reduction doesn't preclude another from seeking accuracy.

As for myself, I never bothered with any lag reduction techniques because I simply don't care all that much about input lag, save particularly egregious cases such as Guardian Force.
Image
NTSC-J: You know STGs are in trouble when you have threads on how to introduce them to a wider audience and get more people playing followed by threads on how to get its hardcore fan base to play them, too.
1CCs | Twitch | YouTube
User avatar
casualcoder
Posts: 346
Joined: Sat Apr 21, 2012 4:35 am
Location: West Coast, Canada

Re: 100% Lagless Emulation is Here!

Post by casualcoder »

Yeah I think the boat is being missed here.

As a developer myself I understand why lag enters the equation when creating a game. It is almost never implemented on purpose.

It's usually due to poor optimization, lack of knowledge, hardware limitations and so forth.



There are rare circumstances where lag is put in on purpose but this is usually to smooth out netplay, or asynchronous things of that nature. That's not the case here.


Actually, as an interesting sidenote the way this was developed was apparently out of rollback technologies that are used to diminish lag over netplay.

Although it's not rollback per se, it was apparently inspired by the idea.


So the end result is less lag is never a bad thing. If you can perceive it (I can definitely perceive 1 frame of lag) and you're sensitive to it then it's a no brainer.

Like playing soccer with boots vs shoes. You can definitely do both but one is at least a bit harder than the other. Still, some people will choose boots!


The biggest disadvantage here is setup. It can take some fiddling here and there. Also, for high-scores and speedruns it might pose an interesting problem because it is an obvious artificial advantage.
User avatar
casualcoder
Posts: 346
Joined: Sat Apr 21, 2012 4:35 am
Location: West Coast, Canada

Re: 100% Lagless Emulation is Here!

Post by casualcoder »

Oh, another thing to keep in mind.

In terms of "accuracy." No glitches or anomalies in the emulation will pop up if done properly.

But, paradoxically, you can get a more hardware-accurate emulation using this lag reduction technique in certain setups.

For example, if your HDTV you're playing on has 2 frames of lag built-in, you can simply compensate by reducing by -2 frames within the game emulation side of things.

The net result is precise emulation on par with playing the original hardware on CRT (not accounting for other typical emulation inaccuracies).


So, all things being equal you can stand to benefit from the lag reduction - towards the goal of emulation accuracy - even if the net result is 0 lag reduction, if that makes sense ;)
User avatar
OmegaFlareX
Posts: 884
Joined: Tue Jan 25, 2005 10:15 pm
Location: Virginia, USA

Re: 100% Lagless Emulation is Here!

Post by OmegaFlareX »

How do you set it up? What options need to be selected? A short guide would be beneficial.
User avatar
tomwhite2004
Posts: 319
Joined: Fri Mar 08, 2013 12:13 pm
Location: UK

Re: 100% Lagless Emulation is Here!

Post by tomwhite2004 »

casualcoder wrote:For example, if your HDTV you're playing on has 2 frames of lag built-in, you can simply compensate by reducing by -2 frames within the game emulation side of things.
It isn't quite that simple. You should only ever remove the amount of lag frames that an individual game exhibits. 99% of the NES, SNES and Megadrive games that I have tested only have 1 frame of lag. If you were to remove 2 frames with these titles then you will chop out a frame of animation.
User avatar
tomwhite2004
Posts: 319
Joined: Fri Mar 08, 2013 12:13 pm
Location: UK

Re: 100% Lagless Emulation is Here!

Post by tomwhite2004 »

OmegaFlareX wrote:How do you set it up? What options need to be selected? A short guide would be beneficial.
Whilst a game is running press "p" to pause the emulation. Then hold a button on your controller and press "k" to advance frames. In super mario world for example you will notice that mario moves or jumps on the third frame, this means you should remove two frames. It's always best to press all buttons, action and movement as sometimes certain attacks can have more lag than say the main movement of a character, in which case you want to remove the lowest figure.

Then it is as simple as going into the core option with f1, going into the latency options and turning on run ahead and selecting the amount of frames to remove. If you get sound issues then turn on the second instance option which runs another emulator in parallel to exclusively handle the audio.

Then either save on a per game or core basis (1 frame is a safe setting if you can't be bothered to do it on a per game basis) and return to the game. You should now have the character respond on the next frame when pausing and advancing the frames as you did initially. This along with hard gpu sync at 0, windowed fullscreen off and as much frame delay as your cpu can manage makes an absolutely huge difference.

Let me know if this is coherent! If not am happy to put a wee guide together with some screenshots and examples.
User avatar
casualcoder
Posts: 346
Joined: Sat Apr 21, 2012 4:35 am
Location: West Coast, Canada

Re: 100% Lagless Emulation is Here!

Post by casualcoder »

tomwhite2004 wrote: It isn't quite that simple. You should only ever remove the amount of lag frames that an individual game exhibits. 99% of the NES, SNES and Megadrive games that I have tested only have 1 frame of lag. If you were to remove 2 frames with these titles then you will chop out a frame of animation.
Yeah I didn't make that fully clear. Obviously if a game has only 1 frame of lag then you will not be able to subtract 2 frames. If you try to, it will cause a glitch. Obviously this is how NOT to use the feature.

But that 1 frame will still make a difference if your TV has at least 1 frame of lag.
User avatar
casualcoder
Posts: 346
Joined: Sat Apr 21, 2012 4:35 am
Location: West Coast, Canada

Re: 100% Lagless Emulation is Here!

Post by casualcoder »

OmegaFlareX wrote:How do you set it up? What options need to be selected? A short guide would be beneficial.
I'll create a guide as soon as I finish up some setup on my end but basically just install the latest Retroarch and pick a core for whatever you want to play.

I recommend starting with SNES9x core and load some SNES roms. Some mame games are a bit more tricky to get going at first, so that's why I recommend that for testing.

Once you load the game press pause with the [P] key, then press & hold an arrow key to move your character. Since you're in pause your character won't move. So, while holding the arrow down press the [K] key to advance the frame. Count the frames BEFORE you see the character move and that's what you'll want to set your latency compensation to. (IE If it takes 2 presses of the [K] key to see the character move, you'll want a latency of "1").

Press [F1] and go to "Latency." Turn it to ON, and set it to the value you determined from instructions above.

If the audio sounds odd, be sure to also turn on the "second instance" option as this will run another emulation that it will use for the audio only.

You can re-test that the settings are correct by repeating the first "pause" steps outlined above. If you see the character move on the first press of the [K] key, then you got it right. Actually, do be careful because if you didn't count the frames right advance too far ahead. Avoid this by (A) counting your frames correctly and (B) watching how the character moves on the first [K] press. If it seems the character moves too far or in an animation frame that doesn't look like the first frame, then repeat the steps to get it right.

If you're happy with your results you'll want to save it to the game specific overrides (every game will be different). So again in the [F1] menu scroll down or select the game from the favorites part of the menu and scroll until you see the part about saving overrides. Select "Save game override."


That's basically it. The exact same process can be used for any game.
User avatar
KaizaCorp
Posts: 96
Joined: Sat Oct 22, 2016 6:43 am
Location: SK, Canada

Re: 100% Lagless Emulation is Here!

Post by KaizaCorp »

It would be awesome to have a guide for setting up mame games in Retroarch. I can only play one game at a time, so it being a bit trickier isn't the worst thing.

Edit: Tried getting Battle Garegga setup. Having difficulty getting the audio correct though.
User avatar
poptart
Posts: 68
Joined: Fri Jul 27, 2018 11:20 am

Re: 100% Lagless Emulation is Here!

Post by poptart »

Can't someone just release a newer shmupmame that does this shit in a much easier fashion?
User avatar
Sumez
Posts: 8040
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: 100% Lagless Emulation is Here!

Post by Sumez »

What I'm wondering every time this comes up is, how come Super Mario World has inherent input "lag" at all? And 3 frames at that. Isn't it normal procedure to buffer the entire controller input during vblank and process it on the following frame?
User avatar
qmish
Posts: 1571
Joined: Sun Oct 26, 2014 9:40 am

Re: 100% Lagless Emulation is Here!

Post by qmish »

call me stupid, i never touch retroarch with a feet

just use same old emulators (and doing it separetely, without fancy multi- shells) i used for ages and not gonna switch horses

i'm too slow to notice lags so whatever
User avatar
tomwhite2004
Posts: 319
Joined: Fri Mar 08, 2013 12:13 pm
Location: UK

Re: 100% Lagless Emulation is Here!

Post by tomwhite2004 »

Sumez wrote:What I'm wondering every time this comes up is, how come Super Mario World has inherent input "lag" at all? And 3 frames at that. Isn't it normal procedure to buffer the entire controller input during vblank and process it on the following frame?
SMW has two frames of lag. As to why the only sort of explanation I have ever seen is in this video. " if the gamemode routine takes too long, the V-Blank routine cannot update for the next frame, so a lag frame is needed to allow the gamemode routine to finish."

https://www.youtube.com/watch?v=tD6fCPPmBMA
User avatar
Sumez
Posts: 8040
Joined: Fri Feb 18, 2011 10:11 am
Location: Denmarku
Contact:

Re: 100% Lagless Emulation is Here!

Post by Sumez »

That sounds like someone paraphrasing something they don't fully understand.
What that quote talks about is what causes slowdown in games. If Super Mario World consistently spent two frames running its game logic routine, it would be running at a constant 30fps :)
DialKnight
Posts: 95
Joined: Sat Dec 02, 2017 5:08 pm
Location: PA,USA

Re: 100% Lagless Emulation is Here!

Post by DialKnight »

This is fascinating, as I notice the lag switching between flatscreens and CRTs and it keeps me away from certain emulators and screen types for the sake of a consistent experience. This epoch makes the flatscreen barcade look a lot more appealing.
mrmccormo
Posts: 37
Joined: Fri May 05, 2017 2:52 pm

Re: 100% Lagless Emulation is Here!

Post by mrmccormo »

If I'm playing on a 480p CRT PC monitor or in 240p on a CRT through a converter, will I see any advantages?
User avatar
Zen
Banned User
Posts: 1072
Joined: Fri Jul 29, 2011 4:36 pm

Re: 100% Lagless Emulation is Here!

Post by Zen »

RetroArch. Eh . . . yeah.

Emulation's most complex CAPTCHA. Every time I come back to it, I end up like Sisyphus.
So don't even get me fucking started, on this No-Lag Mode, voodoo, time-travelling bullshit!

With that being said, I hear this new magic is very good?
I must give it a try :wink:
Image
User avatar
tomwhite2004
Posts: 319
Joined: Fri Mar 08, 2013 12:13 pm
Location: UK

Re: 100% Lagless Emulation is Here!

Post by tomwhite2004 »

Sumez wrote:That sounds like someone paraphrasing something they don't fully understand.
What that quote talks about is what causes slowdown in games. If Super Mario World consistently spent two frames running its game logic routine, it would be running at a constant 30fps :)
Shitbags, I really didnt look at that clearly enough, they are clearly talking about slowdown rather than input lag, sorry.
kaiza wrote:Edit: Tried getting Battle Garegga setup. Having difficulty getting the audio correct though.
Ditto, with both MAME and Final Burn Alpha. From what I have read and experienced it seems that it is 50/50 if a game will work properly or not with those cores. Some have the sound too fast, some too slow with no way of correcting anything if that is the case.
fandangos
Posts: 144
Joined: Tue Sep 18, 2012 3:48 am

Re: 100% Lagless Emulation is Here!

Post by fandangos »

I'm running RetroArch at 1080p@120hz here (audio sync as a frame limiter) with scanline-fract shader and I'm testing Higan with runahead and second instance.
And I'm using vulkan with a 1080 Ti, if that makes any difference. Exclusive full screen and didn't change anything else.

Is this actually too heavy for a i7 6700k overclocked at 4.5ghz?

I was trying some SA1 Snes games and I had to turn RunAhead off.
Also tried nSide which should be a lighter port of Higan but still too heavy to run using RunAhead and SA1.

Not sure if matters but I was testing a Super Mario World hack.
User avatar
orange808
Posts: 3209
Joined: Sat Aug 20, 2016 5:43 am

Re: 100% Lagless Emulation is Here!

Post by orange808 »

fandangos wrote:I'm running RetroArch at 1080p@120hz here (audio sync as a frame limiter) with scanline-fract shader and I'm testing Higan with runahead and second instance.
And I'm using vulkan with a 1080 Ti, if that makes any difference. Exclusive full screen and didn't change anything else.

Is this actually too heavy for a i7 6700k overclocked at 4.5ghz?

I was trying some SA1 Snes games and I had to turn RunAhead off.
Also tried nSide which should be a lighter port of Higan but still too heavy to run using RunAhead and SA1.

Not sure if matters but I was testing a Super Mario World hack.
Yep. That's a heavy load on your rig. It probably is too much.

Emulation depends heavily on your processor, so your GPU makes little difference. Although, you might try setting the emulator to 480p and using the GPU scaling option to get 1080p. That will offload the scaling duties to the GPU and take a task off Retroarch's plate.

Why 120Hz? Are you using black frame insertion?

Disable vsync. Use adaptive sync or try setting your video output to match the system refresh rate.

Why second instance? That's an expensive option. Were you having issues? You should get a good boost from disabling that.

Also, how many frames are you trying to claw back?

One last thing, the best answers to these questions are probably at the Libretro forums. It's not perfect over there, but it's a much better community than the usual neogaf or gbatemp shitholes (much like this fine establishment right here).
We apologise for the inconvenience
User avatar
tomwhite2004
Posts: 319
Joined: Fri Mar 08, 2013 12:13 pm
Location: UK

Re: 100% Lagless Emulation is Here!

Post by tomwhite2004 »

fandangos wrote:I'm testing Higan with runahead and second instance.
It's worth noting that both Higan and nSide have 1 frame of input lag more than any other SNES core in Retroarch as they do not have the "Brunnis lag fix". So by removing a frame from Higan you are still only at the baseline for all the other cores. As orange808 said only turn on the second instance if you have sound issues, otherwise put that extra processing power towards frame delay.
fandangos
Posts: 144
Joined: Tue Sep 18, 2012 3:48 am

Re: 100% Lagless Emulation is Here!

Post by fandangos »

orange808 wrote:

Why 120Hz? Are you using black frame insertion?
I didn't have to use frame insertion or Vsync /2 to get 60hz.
I'm using 120hz because in this mode my TV has only 16ms of lag because it's kind of a "secret mode" and many built in scalling features that can't be turned off by the TV menu and gets deactivated this way.
orange808 wrote: Also, how many frames are you trying to claw back?
I'm using 2 frames since this is what a measured here.

I get 60fps if I don't press anything if I start playing the game it drops to 55 fps and gives me audio problems.

I'll try disabling second instance or try Snes9X to see if I can get a better performance.
Also frame delay is set to zero here.
User avatar
Keade
Posts: 384
Joined: Mon Jul 16, 2007 8:44 pm

Re: 100% Lagless Emulation is Here!

Post by Keade »

Sumez wrote:What I'm wondering every time this comes up is, how come Super Mario World has inherent input "lag" at all? And 3 frames at that. Isn't it normal procedure to buffer the entire controller input during vblank and process it on the following frame?
It should be.
This is actually a very good question.
Afaik, SMW in particular has been reverse-engineered a lot, so some people probably know how it works well, and could explain it.
User avatar
Despatche
Posts: 4196
Joined: Thu Dec 02, 2010 11:05 pm

Re: 100% Lagless Emulation is Here!

Post by Despatche »

The real problem is that this is limited to RetroArch and their special brand of tyranny. No thanks. Hopefully Bizhawk gets on it soon.
Rage Pro, Rage Fury, Rage MAXX!
User avatar
orange808
Posts: 3209
Joined: Sat Aug 20, 2016 5:43 am

Re: 100% Lagless Emulation is Here!

Post by orange808 »

Keade wrote:
Sumez wrote:What I'm wondering every time this comes up is, how come Super Mario World has inherent input "lag" at all? And 3 frames at that. Isn't it normal procedure to buffer the entire controller input during vblank and process it on the following frame?
It should be.
This is actually a very good question.
Afaik, SMW in particular has been reverse-engineered a lot, so some people probably know how it works well, and could explain it.
The developers had their reasons. The game loop was designed with the latency there. It's supposed to be there.
We apologise for the inconvenience
User avatar
WelshMegalodon
Posts: 1225
Joined: Fri Dec 11, 2015 5:09 am

Re: 100% Lagless Emulation is Here!

Post by WelshMegalodon »

Despatche wrote:The real problem is that this is limited to RetroArch and their special brand of tyranny. No thanks. Hopefully Bizhawk gets on it soon.
Couldn't have said it better myself.
Indie hipsters: "Arcades are so dead"
Finite Continues? Ain't that some shit.
RBelmont wrote:A little math shows that if you overclock a Pi3 to about 3.4 GHz you'll start to be competitive with PCs from 2002. And you'll also set your house on fire
User avatar
Keade
Posts: 384
Joined: Mon Jul 16, 2007 8:44 pm

Re: 100% Lagless Emulation is Here!

Post by Keade »

orange808 wrote:The developers had their reasons. The game loop was designed with the latency there. It's supposed to be there.
It is how it was programmed (at least, according to tests), of course it is there. But supposed to be there ? It probably didn't need to be be programmed that way. Just the same, computer games made for a wide range of evolutive hardware (PC ?) do not need be capped at 30 or 60fps*, they can be made to run and feel better while still being the same game. Still, many games come capped to 60fps, just because that takes a little less effort (probably).

Anyway, it looks like there is SMW disassembly https://raw.githubusercontent.com/gnagh ... MWDisC.txt if someone with the knowledge ever feels bored enough to understand the mystery of the three frames :mrgreen:
Last edited by Keade on Mon Aug 06, 2018 7:43 pm, edited 3 times in total.
User avatar
Despatche
Posts: 4196
Joined: Thu Dec 02, 2010 11:05 pm

Re: 100% Lagless Emulation is Here!

Post by Despatche »

Input lag isn't "supposed to" be there. This is like scanline fetishism. No, sprites aren't really drawn for scanlines, and sprites often aren't drawn for the actual TV output at all. Likewise, most games aren't really "designed" for input lag, because most input lag is very minor and can easily be adapted to if it changes. Now, I greatly prefer hardware accuracy and the lag that's actually supposed to be there, but I don't blame people at all for trying to circumvent that. As long as the lag is being emulated properly and is always presented as the default, an option to go beyond the pendulum should never be an issue.

Options are good, especially in emulation. Why don't people understand this yet?
Rage Pro, Rage Fury, Rage MAXX!
Post Reply