View Single Post
Old 23 July 2016, 20:09   #1
mark_k
Registered User
 
Join Date: Aug 2004
Location:
Posts: 2,481
Late emulation to reduce input lag?

This post has a rambling suggestion about how to (maybe) minimise input lag in emulation. [After writing most of this I discovered that RetroArch/libretro apparently implements something like this; they call it "frame delay".]

By input lag I mean the delay between pressing a controller button and the result being shown on the PC monitor. Maybe low-latency vsync mode does exactly this already???

I'll assume emulation runs vsynced, so the emulated Amiga frame rate matches that of the PC display. I'll also assume that emulation of each Amiga frame takes only a small proportion of a PC frame. For example WinUAE might take 10% of PC frame time to emulate one Amiga frame.

How does the timing work then? Is it like this?

[PC vblank]
[PC output image is of previously-rendered Amiga frame n]
WinUAE wakes up, detects user input, renders Amiga frame n+1 and hands it off to the graphics driver
WinUAE sleeps until the next PC vblank (i.e. for ~90% of frame time).
[PC vblank]
[PC output image is Amiga frame n+1]
etc.

In that case there is a delay of ~90% frame time between when WinUAE finishes rendering the Amiga image, and when it gets shown on the PC display.

An alternative would delay emulating each frame, so there is a smaller delay between sampling input devices/emulating/handing off image to graphics driver and when the image is displayed on the PC monitor.

[PC vblank]
[PC output image is of previously-rendered Amiga frame n]
WinUAE sleeps for 80% of frame time.
WinUAE wakes up, detects user input, renders Amiga frame n+1 and hands it off to the graphics driver
WinUAE sleeps until (next vblank time + 80%)
[PC vblank]
[PC output image is Amiga frame n+1]
etc.

Waking up at the 80% point of each PC frame allows for some leeway; some Amiga frames take longer to emulate than others, other programs running on the PC might make emulating that frame take longer etc. With that scheme, the delay between checking for user input and when the emulated Amiga frame gets displayed would be <= 20% of a frame.

Different speed PCs, emulation settings and graphics drivers would need the amount of sleep to be adjustable.
mark_k is offline  
AdSense AdSense  
 
Page generated in 0.05054 seconds with 9 queries