Input latency is not great
Hello, i noticed that when i enable warp mode, input latency is unnoticeable, while, even without any vsync nor compositors running (Linux), i can feel a lag between keypresses and the feedback on screen. I was reading this:
Input Latency
Currently, input is polled from the system devices once every frame (once per 20 ms when emulating a PAL Amiga). This means that some input events which could otherwise be applied to the emulation immediately may have to wait until the next emulated frame.
There are technical reasons why input is only polled once every frame (basically because both the video renderer as well as the input event loop runs in the main thread).
The plan is to move the video renderer to a new/separate thread, so input events can be waited for continuously, and applied at the earliest possible time. This work will be done while migrating FS-UAE from SDL 1.2 to SDL 2.0, as the new version of SDL is better suited to running the video renderer in a separate thread.
So i wonder if it has already be implemented and i may be doing something wrong on my side. Thank you!
Input is polled more often than once per frame, yes, so that information is outdated.
I'm not sure the problem you describe here is a general input latency issue; it could just be that the software/game you're running isn't responding that quickly to input? If so, using warp mode will make input latency appear to be better because it takes less "real time" for you to notice. But since you've also sped up the Amiga, the input latency might not actually be better in terms of emulated frames until the input had any effect... ?
Although what you say surely makes sense to me, I still don't remember my experience on the real Amiga to be so "laggish". Even the simple move of the mouse pointer in a blank amiga screen seems to move with a delay. I filmed me hitting the mouse button on the amiga screen at 60fps. There are 5 frames delay when running a shader and 4 frames delay when not. Amiga is running at 50hz and monitor refresh rate is set to 50hz too, vsync is disabled.
4 frames @60fps means a delay of 66ms without a shader. Do you think this is a good test and/or the expected results?
https://user-images.githubusercontent.com/1230726/143556370-0753329b-0c32-4b1d-98ce-466d1ab42178.mp4
https://user-images.githubusercontent.com/1230726/143556381-b7060d53-430d-4962-82ee-7048b189416f.mp4
I just found this other one: http://eab.abime.net/showthread.php?t=88777
Tried it and filmed it at 60hz, with fs emulating 50hz and screen refresh rate to 50hz, more or less the same results: between 2,5 frames and 3 frames delay without a shader (41ms to 50ms) and between 3.5 frames and 4 frames with a shader: (58ms to 66ms) To be fair i filmed the real linux host running openbox window manager; this time de delay is whitin a single frame (<16ms) Taking openbox+X11 as a floor, this means uae introduced a lag somewhere between 1.5 to 2 frames at 60fps -> 24 to 32 ms:
https://user-images.githubusercontent.com/1230726/143558249-b507f4be-061a-4295-a742-f834b79207cb.mp4
https://user-images.githubusercontent.com/1230726/143558256-d6b36dae-87c1-4055-8702-efe8eae7fd13.mp4
https://user-images.githubusercontent.com/1230726/143561298-631d8ad0-2836-424f-b997-33d1ec84992f.mp4