SDL/src
Sam Lantinga 1df0a1e497 Fixed bug 5140 - KMSDRM: Dynamic vsync toggle does not work
Manuel Alfayate Corchete

The KMSDRM backend was doing things wrong because of some small (but important) misconceptions on how KMS/DRM works: to implement a largely broken non-vsync refresh mechanism, the SwapWindow() function was issuing new pageflips before previous ones had completed, thus causing EBUSY returns, buffer mismanagement, etc... resulting in general breakage on vsync disabling from apps, that would not allow vsync to work again without KMSDRM video re-initialization.
To further clarify, on most DRM drivers async pageflips are NOT working nowadays, so all issued pageflips will complete on next VBLANK, NOT ASAP (calling drmModePageFlip() with the DRM_MODE_PAGE_FLIP_ASYNC flag will return error).

The old code was assuming that can just issue a synchronous (=on VBLANK) pageflip and then pass a 0 timeout to the pull() function so we do not wait for the pageflip event, thinking that this will lead to correct non-vsynced screen updates from the program: That is plain wrong.
Each pageflip has to be waite before issuing a new one, ALWAYS. And if we do not support ASYNC pageflips on the DRM driver level, then we are forced to wait for the next VBLANK. There is no way around it.

I have also added many comments on the KMSDRM code. This is needed for future reference for me or others who may need to look at this code: KMS/DRM terminology regarding what SYNC and ASYNC mean in pageflip terms, and where to do certain things and why, is not trivial. It is not desirable or possible to invest time on researching the same concepts every time there is need to dive into this code. So please leave all these comments in the patch.
2020-05-26 16:27:00 -07:00
..
atomic Add basic support for compiling on RISC OS 2020-02-13 20:50:47 +00:00
audio windows: Fix calls to CoCreateInstance() so last parameter is a LPVOID *. 2020-05-20 16:58:33 -04:00
core Getting closer. 2020-05-26 13:19:48 -07:00
cpuinfo Improved CPU detection on ARM platforms 2020-02-04 16:46:22 +00:00
dynapi locale: Implemented SDL_GetPreferredLocales(). 2020-05-04 02:27:29 -04:00
events locale: Implemented SDL_GetPreferredLocales(). 2020-05-04 02:27:29 -04:00
file Fixed compile warning 2020-02-10 13:59:05 -08:00
filesystem Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
haptic windows: Fix calls to CoCreateInstance() so last parameter is a LPVOID *. 2020-05-20 16:58:33 -04:00
hidapi hid: Add Microsoft Precision Mouse to the joystick blacklist. 2020-05-06 03:18:25 -04:00
joystick hidapi: Fix compiler warning. 2020-05-20 17:01:25 -04:00
libm Fixed compiler warning 2020-01-29 20:09:16 -08:00
loadso Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
locale locale: Removed unused variable. 2020-05-21 04:01:37 -04:00
main locale: Implemented SDL_GetPreferredLocales(). 2020-05-04 02:27:29 -04:00
power Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
render Fixed iOS build 2020-05-26 13:54:47 -07:00
sensor sensor: Fixed compiler warnings on mingw64. 2020-05-21 03:52:48 -04:00
stdlib stdlib: Fixed compiler warnings about int vs size_t. 2020-05-05 12:48:55 -04:00
test Fix some format specifier warnings 2020-03-25 01:34:15 -04:00
thread More Linux fixes. 2020-05-26 13:19:44 -07:00
timer Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
video Fixed bug 5140 - KMSDRM: Dynamic vsync toggle does not work 2020-05-26 16:27:00 -07:00
SDL.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_assert.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_assert_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_dataqueue.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_dataqueue.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_error.c SDL_error: simplified error string management. 2020-04-21 01:30:36 -04:00
SDL_error_c.h SDL_error: simplified error string management. 2020-04-21 01:30:36 -04:00
SDL_hints.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_hints_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_internal.h Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
SDL_log.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00