Input lag

From Emulation General Wiki
Revision as of 15:24, 1 December 2023 by Ahayri (talk | contribs) (Display lag)
Jump to navigation Jump to search

Input lag is the delay between pressing a button and seeing the game react.[1] The potential causes for "input lag" are described below (steps which have negligible contributions to the input lag have been omitted). Each step in the process increases "input lag", however, the net result may be unnoticeable if the overall "input lag" is low enough.

Causes

Display lag

This is the lag caused by the modern displays/televisions/monitors (due to the nature of the digital technology). Digital image processing (such as upscaling, motion smoothing and edge smoothing etc.) takes time and therefore adds some degree of input lag as well. Once the frame has been processed, the final step is the pixel response time for the pixel to display the correct color for the new frame.

Analog CRT TVs and VGA CRT monitors have nearly zero input lag, but display lag limited by phosphor decay time due to the nature of the technology. Although HD CRTs that do digital image processing such as High-Definition, 100Hz/doubling the scanrate or 480p inputs which use scaling and cause noticable input lag. OLEDs have almost no display lag due to their fast response time and the nature of the technology. They are also capable of displaying true black levels, which means that they do not require a backlight to produce an image and this allows OLEDs to turn individual pixels on and off much faster than LCDs, which require a backlight to produce an image.

If you're in the market for a monitor or TV and display lag including input lag is a concern; check these websites because some of the modern displays only have negligible amount of input lag and display lag and even some of them are near identical performance compared to Analog CRTs.

Compositor

If you're using Windows Vista/7 and playing in windowed mode, having DWM enabled will add a noticeable amount of input lag because it forces vertical synchronization at the OS-level. The same thing applies to other OSes if their compositor uses V-Sync. Windows Aero and DWM can be disabled in both Vista and 7, thus disabling compositing and lowering input lag when playing in windowed mode, but this can no longer be done from Windows 8 onward due to WDDM 1.2+. That said, exclusive fullscreen should automatically disable compositing on all Windows OSes, making it the preferred way to emulate in most cases.

GPU driver

There is video latency caused by the GL drivers in Windows/Linux. Both the GLX X11 and Windows GL/D3D drivers are full of hacks, code paths, and buffer schemes that cater to benchmarking applications and games. This is counterproductive when the aim is low-latency audio and video synchronization for emulators. You don't want all this stuff going on in the background. This can be avoided by using KMS and DRM/EGL, specifically on Linux. By using these modes, the user is in control of front and back buffers and don't have to rely on APIs, so that they can find where and when a frame was dropped and how to act accordingly with that in mind. It is advisable to get the latest driver to improve performance, as notable graphics chip manufacturers (e.g. Nvidia) do not find KMS a priority.[2] Intel and most AMD graphics chips, however, should be fine regardless, but it is still advisable to update drivers.

Input

actuation force demonstration

When it comes to delay of input devices most important thing usually is input controllers (ASICS/MCU/ECs), sensors and switches including switch designs. Wired/wireless usually doesn't matter (unless its Bluetooth with power saving mode); the thing that really matter is "consistency about polling rate"; polling rate fluctuations cause stutters and unstable input device feedback to users. When it comes to wireless technology "consistency" may be affected by lots of environmental factors.

See these websites for various controllers and keyboard/mouse devices for input lag performance benchmarks.

Battle(non)sense: Keyboard Input Lag 125, 250, 500, 1000Hz USB vs. PS/2
  • Make sure to use reasonable CPI/DPI and Polling rate values for USB devices because optimizing input and matrix resolution may affect input delay little bit.
Battle(non)sense: Low DPI vs. High DPI and Polling Rate Analysis

BIOS settings, bad drivers, OS misconfiguration and placebo effect

Some people claims that default BIOS settings, Windows settings, registry settings, bloated services etc. causes little bit input delay and if you tweak these settings it will improve your system responsiveness. These kind of tweaks on internet considerably popular due to placebo effect but actually some of them really improves input delay a tiny bit. If you're obsessed with hacking your operating system and improving your system responsiveness even for a little bit you can check out FR33THY's latency analysis and also optimization pack which includes useful scripts. Most importantly make sure to use always proper and official drivers for your computer otherwise it may affect your system responsivess negatively (e.g. High DPC Latency, spikes etc.)

See ways to reduce input lag section for reducing input delay.

Ways to reduce input lag

Display choice
Use Custom resolution/CRTSwitchRes solutions for displaying it on a CRT display in the correct resolutions. You could use built-in Custom resolution/CRTSwitchRes solutions like RetroArch's CRTSwitchRes or GroovyMAME using with CRT emudriver which is much more practical compared to using EDID editor tools such as Custom Resolution Utility (CRU) or using Linux in KMS mode[3][4]. See #Enhancements sections in each page for "built-in custom resolution/CRTSwitchRes" support for emulators.
If you have a "gaming" monitor you can also turn on "overdrive" option if available for overclocking pixels (applies overvoltage to pixels) making them react faster (better pixel response time) which results in less ghosting. That said, increasing pixel overdrive may cause inverse ghosting as the increased voltage can cause the pixels to overshoot the colors. See these websites and reviews to learn information about your display devices capabilities and performance.
Also you could use latest MAME with "-lowlatency" flag for your variable refresh rate supported monitor.

  • Wired controller/input device (just for minimizing possible negative factors, just like using wired connection for router and client device)
  • Use exclusive fullscreen for Windows 8 and onwards if available because with borderless windowed and windowed fullscreen, due to WDDM 1.2 the desktop composition cannot be disabled anymore, so your only hope to avoid the compositing lag penalty is to play in exclusive fullscreen mode.
  • Use input lag-mitigating techniques if application supports it.
    • A relatively new lag-mitigating technique known as Run-Ahead has recently been implemented in several emulators and frontends, which leverages spare performance overhead to run one or more instances of the emulator ahead of the regular instance, then uses save state rollback to lay that instance over what you see, effectively cutting a whole frame or more of input lag. Most games, even on real hardware on a CRT, have at least one hard-coded frame between executing an action on the controller and said action being reflected on screen, so setting Run-Ahead to 1 frame cuts out that superfluous frame and thus is usually considered safe, but setting it to 2 or more can result in dropped frames and perceived video stutter (though some games can benefit from 2 or more frames, particularly a lot of 5th-gen games). This is also quite processor-heavy, as every extra Run-Ahead frame requires a whole extra instance of the emulator, easily doubling or tripling CPU load, and some emulators are currently not able to use Run-Ahead at all. That said, combined with all the other lag reduction techniques on a sufficiently powerful system, Run-Ahead in theory can actually result in less input lag than even real hardware.
    • Another option for lag-mitigating technique known as Preemptive Frames. See this video for information.
 It cannot be understated how much system requirements increase the more lag reduction measures are employed. A computer or device that would normally be able to run an emulator or core at full speed with ease can suddenly find itself chugging with said measures implemented, especially once Run-Ahead and Frame Delay come into play, which may necessitate foregoing some of them. Some ways to alleviate the load and unlock more lag mitigation potential include making sure performance options are enabled, turning on speed hacks or dynarecs if applicable (to the extent that they don't hamper the game significantly, that is), or switching to faster, less accurate emulator/cores altogether, as the less CPU intensive an emulator is, the more performance overhead is left over for lag reduction. An example would be switching from bsnes to SNES9X, which trades cycle accuracy and compatibility with a handful of games for far greater performance and thus more room to reduce input lag. Also, as implied before, if you have to choose between Run-Ahead and Frame Delay, you should almost always choose Run-Ahead. Of course, if your system is powerful enough to run the most accurate emulators along with all the input lag reduction techniques all at once, go ahead and do so.

References

External Links

inputlag.science - repository of knowledge about input lag in gaming
Run-Ahead Wiki
Mouse devices sensor list
DestinyXZ9's investigations about input lag in various emulators
RTINGS: Input Lag of Monitors
RTINGS: Input Lag of TVs
RTINGS: Pixel Response Time of Monitors
RTINGS: Pixel Response Time of TVs
TFTCentral: Reviews and Input Lag analysis of Monitors
ApertureGrille: Reviews and Input Lag analysis of Monitors
Controller latency on MiSTer
Rocket Science: Controller Input Lag comparison video
RTINGS: Mouse Click Latencies
RTINGS: Mouse CPI and Speed-Related Accuracy Variation/SRAV results
RTINGS: Mouse sensor latencies
RTINGS: Keyboard Latencies
mousespecs: Mouse Click Latencies
Derek Wilson/AnandTech: Exploring Input Lag Inside and Out
BlurBusters: Preview of NVIDIA G-SYNC, Part #2 Input Lag
RetroRGB: BSNES Runahead Mode Lag Tested
Rocket Jump Ninja - YouTube channel dedicated to mouse reviews
Battle(non)sense - YouTube channel dedicated to analysing netcode performance of games and testing input lag, system responsiveness etc.
FR33THY - YouTube channel dedicated to computer hardware and peripherals for testing input lag and system responsiveness etc.
PPSSPP: Input lag too high, ideas for improvement
Brunnis: An input lag investigation