An input lag investigation

This isn’t about elitism, this is about you trolling someone for no reason, aside from being narrow-minded.

And who cares about what steam says ? Who talked about general gaming ? Linux is a very popular platform for emulation, especially with all the linux-based projects born over the last decade (lakka, retropie, recalbox, …) and sbc devices (raspberry pi, odroid, …). RetroArch is also available on lots of other platforms (macos, old and new consoles, smartphones, tablets, tv box, …). I wouldn’t be surprised if windows users were actually a minority as far as retroarch usage is concerned.

Oh no, no war please :wink:

As for Linux & gaming, well, it’s never been as viable as it is today – and I’ve been gaming on Linux only for 20 years. But of course there will always compatibility issues, sub-optimal use cases. But well, still, it’s incredible as it is now IMHO.

I’m pretty sure my life would have been easier if I has remained on “the other side”, but, I think it made sense at least.

Thanks a lot for the kind words, vanfanel. :blush:

I did a quick test with vulkan on Lakka a while back, but had some kind of issue. Can’t really remember what, but I think it was something major like getting a black screen when trying to run snes9x… Anyway, this sounds quite intriguing. A few questions:

  1. How does Vulkan + max swapchain 1 + no vsync not generate tearing? Isn’t this basically running single buffered?
  2. Regarding using 44.1kHz, would this make any difference for NES/SNES emulators? (sorry, haven’t really dug into any audio stuff). Is the main reason for doing this to spare precious CPU cycles?

I’ll likely check this out, but it may take a while due to everything else going on these days.

Hi Brunnis!

Vulkan is better suited for exact framerate control, so my theory is that the emulation is running exactly at the framerate of the videomode in use, so there’s no need for vsync. Try it with current stable MESA, my tests a while back didn’t give me SO good results as they give me now.

As for 44100Hz audio, it saves resampling time so it allows for lowest latencies on the Pi4, at least on my tests here.

Keep me informed on your tests with Vulkan + max_swapchains=1 + no vsync, I am sure you will be surprised as I was!

Regarding the new Automatic Frame Delay setting, if this is enabled what should the Frame Delay setting be set to??

• if you set “Frame Delay” to 0 and “Automatic Frame Delay” to ON, the starting point of the delay that is applied to the new frame will be half your “frame period”. For instance, on a typical 60hz screen with a frame time of 16.7 ms, the initial value applied will be “8”, as in 8 milliseconds of delay. Afterwards, if drops or hiccups are detected in the video performance, this value will be reduced dynamically until it reaches a stable point;

• if you set “Frame Delay” to any value higher than 0 and “Automatic Frame Delay” to ON, the starting point will be the delay value that was manually set. For instance, if “Frame Delay” is set to 10, the initial amount of delay for the processing of the new frame will be 10ms. Then, it will be adjusted downwards in case any framerate drop is detected;

So, if you want max frame delay, set it to something very high, like 15. Setting it to 0 will do a maximum of 8 ms, which is honestly probably fine, too, except for the very fastest cores (like gambatte) that can manage even higher.

Thanks, i was having it set to 4 but wasn’t sure if it was having more of a detriment effect or not.

What would the side effect be if it was set too high and the system could keep up??

shouldn’t be an problem. That is, that’s what the automatic part does is reduces the number if it’s too high.

@hunterk What about the max_swapchains when using VSync on a non-G-Sync monitor? Which one is the best? 1, 2 or 3.

1 is the fastest, but some drivers just straight-up won’t give it to you, and even if you get it, you might have stuttery scrolling.

Which is the best of both worlds? The one that gives acceptable input lag and no stuttering, is it 2?

Try it with 1 (your driver may give you 2 anyway :man_shrugging:) . If it’s too stuttery, change it to 2.

Whats the max_swapchain option?, wheres that located and what does it do?

It’s in settings > latency, but it’s only visible with drivers that expose it (vulkan and d3d11/12 IIRC). It controls the maximum number of images that can buffered, which–as with most buffering–is a tradeoff between latency and quality (in this case, smooth scrolling).

1 Like

I have absolutely no idea of the technical aspects behind this great feature, but would it be possible to implement something that makes it increase the frame delay value as long as the game runs without sound crackling or lagging ? For example, if frame delay was set to 0 and automatic frame delay to ON, the starting point would be 8, but as long as the game runs fine, it would go up to 9, then 10, etc. until it reaches the point were it starts lagging ?

I talked to sonninnos about exactly that and he didn’t seem too interested in it vs just setting it high to begin with and then letting it self-correct downward.

1 Like

Yeah starting high and going down is best, already with the current auto frame delay every once in a while drops some fps. I tried in some shmups (ddp, ketsui) and it doesn’t feel stable. Personally I keep it off, if I feel I need some “boost” I set it manually, plus frame-delay doesn’t have a good ms saved-resources used ratio.

2 Likes

I’m trying to compare the latency of Vulkan Wayland VS KMS on RetroArch, but I need to set a specific frequency on KMS for consistency purposes.

I have a 4K@120Hz display, and I can boot it in 4K@60Hz mode, but RetroArch changes it to 4K@120Hz when I open it in KMS. I really would like to run it at 60Hz though, for consistent tests among other 60Hz-only setups.

Can anyone help me to force 60Hz? Sorry if this was already requested on this thread.

EDIT: Also, it seems my USB keyboard doesn’t work when I open RetroArch in KMS mode. I tried with the X and UDEV input drivers.

Even though I would still love to know how to force a certain frequency on RetroArch in KMS, I have found another way to conduct the Wayland VS KMS tests on 60Hz, but what I found out seems strange.

I’m using Wayland KDE Plasma (5.24) on Manjaro with RetroArch in fullscreen mode, and assuming direct scan-out is working correctly on RetroArch, I believe the latency should be the exact same as KMS. But that’s not what I verified.

I used my phone’s 480fps slow-motion mode to capture 10 samples each of the latency between a button press on my wired keyboard and my display. I used the exact same RetroArch configuration and hardware for the test. I’m using a Radeon RX 6800 with the AMDGPU driver. Here are my averages:

  • KMS: 53ms (3.2 frames at 60fps)
  • Wayland: 77ms (4.6 frames at 60fps)

That’s a 1.4 frames of additional delay on Wayland. Where am I losing that much? Assuming direct scan-out, shouldn’t it be technically the same, or very close? Could it be perhaps RetroArch is not engaging Kwin’s direct scan-out code, or an internal RetroArch issue?

I’m sorry if this was already covered in the thread sometime before, but a search turned nothing specific to my case. Please link me up if that is the case.

Wayland has lag. It’s just not made for gaming. It’s made for watching video and browsing the web. The people who develop it are not gamers, don’t understand gaming nor really care about it much. Gaming is a second class citizen there.

If you want low latency, use X11 and disable compositing. This will basically give you the equivalent of Windows 10 with DWM disabled (like when using fullscreen, where Windows turns off DWM.) The DWM equivalent of Wayland cannot be disabled. It’s always there, adding lag.

2 Likes