We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3902

Summary: [PATCH] Add a specific KMSDRM hint for low latency video
Product: SDL Reporter: Manuel Alfayate Corchete <redwindwanderer>
Component: videoAssignee: Brandon Schaefer <brandontschaefer>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: brandontschaefer
Version: 2.0.6   
Hardware: All   
OS: Linux   
Attachments: Small patch for low latency mode hint on the KMSDRM video driver
Version 2 patch for low latency mode hint on the KMSDRM video driver

Description Manuel Alfayate Corchete 2017-10-21 12:12:40 UTC
Created attachment 3023 [details]
Small patch for low latency mode hint on the KMSDRM video driver

Hi,

This patch adds low input lag hint to the KMSDRM driver.

In some scenarios, low-latency video is desirable, so instead of letting drmModePageFlip to do it's triple-buffering and thus letting the game to loop once more, we immediately wait for vsync after issuing a pageflip.
This results on a whole frame less of input lag (~16ms on a ~60Hz display).

This behaviour is optional, of course, because the program will become more sensible to system jittering (and have less CPU time to "render ahead"), so the user must pass SDL_KMSDRM_DOUBLE_BUFFER=1 before the program name or set it as an env variable.

The idea was taken from how RetroArch does it, and why.

Thanks

Manuel Alfayate
Comment 1 Manuel Alfayate Corchete 2017-10-23 13:20:01 UTC
Created attachment 3033 [details]
Version 2 patch for low latency mode hint on the KMSDRM video driver

Updated version of the patch. Please merge this version: it saves a function call on every pageflip.
I consider it the final version of this patch, so it's ready to be merged ASAP.
Comment 2 Brandon Schaefer 2017-10-26 23:49:10 UTC
https://hg.libsdl.org/SDL/rev/fbfdee28682d

Thanks!