Difference between revisions of "Input lag"

From Emulation General Wiki
Jump to navigation Jump to search
(BIOS, Bad driver, OS misconfiguration and placebo effect)
m (External Links)
Line 102: Line 102:
 
[https://www.retrorgb.com/bsnes-runahead-mode-lag-tested.html RetroRGB: BSNES Runahead Mode Lag Tested]<br/>
 
[https://www.retrorgb.com/bsnes-runahead-mode-lag-tested.html RetroRGB: BSNES Runahead Mode Lag Tested]<br/>
 
[https://www.youtube.com/@BattleNonSense/videos Battle(non)sense (Usually analysis netcode performance and input lag etc.)]<br/>
 
[https://www.youtube.com/@BattleNonSense/videos Battle(non)sense (Usually analysis netcode performance and input lag etc.)]<br/>
[https://www.youtube.com/@FR33THY/videos FR33THY (Usually reviews computer hardware and peripherals, testing for input lag etc.)]<br/>
+
[https://www.youtube.com/@FR33THY/videos FR33THY] - YouTube channel dedicated to computer hardware and peripherals for testing input lag and system responsiveness etc.<br/>
[https://docs.google.com/spreadsheets/d/19rFOoJtx8OTF7GumSxwhB_3oCQ5bmY4bSpth7ef69Iw/edit#gid=0 FR33THY latency analysis]<br/>
 
 
[https://github.com/hrydgard/ppsspp/issues/17685 PPSSPP: Input lag too high - ideas for improvement]
 
[https://github.com/hrydgard/ppsspp/issues/17685 PPSSPP: Input lag too high - ideas for improvement]
  
 
[[Category:FAQs]]
 
[[Category:FAQs]]

Revision as of 11:25, 6 November 2023

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 display lag (although its limited by phosphor decay time) and input lag, due to the nature of the technology, the exception being later model HD CRTs that do digital image processing such as High-Definition, 100Hz/doubling the scanrate or 480p inputs which use scaling and cause input lag. OLEDs also have considerable amount of input lag compared to analog CRTs but there is 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.

Having said that most modern "gaming" LCD and OLED monitors have "low enough" display and input lag, and many newer TVs also have negligible input lag so long as Game Mode is turned on. These websites makes it a point to test the displays it reviews for display and input lag, so if you're in the market for a monitor or TV and display lag including input lag is a concern, check there first.

Compositor/Windows Aero

If you're using Windows Vista/7 and are playing in windowed mode, having Aero 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 compositing is enabled with VSync. Aero 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.

To disable Windows Aero under Windows Vista/7, select the Basic or Classic theme under Control Center > Personalization, or disable desktop composition under .exe properties > Compatibility. Some emulators and frontends allow you to disable desktop composition without having to switch themes.

GPU driver latency

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.

Hard GPU sync options in some emulator frontends can reduce or remove latency from buffering at the possible expense of performance.

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.

Low-level APIs such as Vulkan give the user control over buffering and may lower latency without resource-heavy solutions like hard GPU sync. However, there is evidence that OpenGL has lower latency than Vulkan in some instances.[3]

Controller/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

  • Wired controller/input device (just for minimizing possible negative factors, just like using wired connection for router and client device)
  • Linux OS in KMS mode[4][5] OR Windows OS with CRT Emudriver but you need compatible GPU for this.
    • Use exclusive fullscreen for Windows 8+ if available. Reason for this is borderless windowed, or windowed fullscreen in Windows 8 and later, due to WDDM 1.2+ the desktop composition cannot be disabled manually, so your only hope to avoid the compositing lag penalty is to play in exclusive fullscreen mode.
  • Use CRT TV OR VGA CRT with analog input/output. If your GPU only support digital output then use high-end DAC/Digital-to-Analog converters. HDMI ones generally pretty bad. See this thread for more information about high-end DACs.
    • Also you could use RetroArch's CRTSwitchRes option with your CRT display. Works the best with CRT Emudriver, no pre setup required for Linux other than X11 of course. Another option is using GroovyMAME instead of MAME..
    • If you don't have a CRT, you can mitigate input lag on LCDs by setting the display to game mode if available (this will turns off some post-processing effects) and also set resolution to native panel resolution (for preventing possible low quality hardware display scaler or GPU scaling delay)
    • If you have a "Gaming" monitor you can also turn on "Overdrive" if available for overclocking/applies overvoltage to pixels making them react faster (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.
 For G-SYNC gamers who don’t want to tear, keeping VSYNC ON while using NVIDIA Reflex or NVIDIA Ultra Low Latency Mode, will automatically cap the framerate below the refresh rate, preventing VSYNC backpressure, eliminating tearing, and keeping latency low if you become GPU bound below the refresh rate of your display. Do note, however, that this method will result in slightly higher latency than just letting your FPS run uncapped with NVIDIA Reflex enabled.
 As a side note, VSYNC ON in the NVIDIA Control Panel will only work for Fullscreen applications. In addition, MS Hybrid-based laptops do not support VSYNC ON. If you are gaming in windowed mode or on one of these laptops, and want to utilize G-SYNC + VSYNC + Reflex mode, use in-game VSYNC.[6]
  • Some graphics drivers enforce excessive frame buffering, which may be eliminated with GPU commands. RetroArch's Synchronization Fences/Hard Sync for OpenGL does this. If using Vulkan, be sure to set the max swapchain images parameter to 2, though weaker GPUs, especially Intel iGPUs, can struggle with this, particularly if using shaders or increasing rendering resolution.
  • 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.
  • Some emulator frontends like RetroArch or GroovyMAME have the option named "Frame Delay" to delay the processing of emulation for a few milliseconds until right before the given frame period is over, which causes inputs to be polled quickly before your display refreshes instead at the beginning of the 16.7ms (for 60 fps) frame period. The amount of time you can use Frame Delay without dropping frames is dependent on the performance of the emulator on your machine. Predictive waiting may also be forced with any DirectX based program through GeDoSaTo. Also you can use Automatic Frame Delay instead of manually giving a value for Frame Delay.

Realistically, Frame Delay is the last thing to configure, after all other sync and buffer settings and Run-Ahead frames have been configured for your system's performance, as it gives the least lag reduction bang for your CPU load buck. It is possible on systems with performance much higher than is required to run at full speed.

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.

  • There are some emulators have the option named "threaded presentation" OR "backend multithreading" for Vulkan video renderer backend and some people claim that this technique adds a frame of input lag. (e.g. Flycast_libretro, LRPS2). This option has actually existed for some time in various emulators that implemented Vulkan renderer backend. What it actually does is when the CPU wants to make something draw it has to issue a "draw call" which takes up CPU time, on old APIs this was nearly all done on one thread, the reason for that is different threads can't access other threads data (quickly) if it's being updated and because of how it used to be done, you needed to synchronise threads a lot and that meant that using lots of threads ended up not always being too helpful, in Vulkan because the person using the API is more explicit about how they want their memory and what have you allocated and used it's easier to submit "draw calls" on multiple threads so it (usually) performs better because it's designed to avoid the issues of older APIs.[7]

References

External Links

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 (might find this interesting as well)
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
Rocket Jump Ninja (Usually reviews mouse devices)
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
Battle(non)sense (Usually analysis netcode performance and input lag 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