KMS - Emulationstation cannot change display mode when initializing after a game
When quitting a game, ES cannot change KMS display mode.
It happens here : https://gitlab.com/recalbox/recalbox-emulationstation/-/blob/master/es-core/src/Renderer.cpp#L123
mSdlWindow = SDL_CreateWindow("EmulationStation",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
mDisplayWidth,
mDisplayHeight,
SDL_WINDOW_OPENGL | (mWindowed ? 0 : SDL_WINDOW_FULLSCREEN));
Setting SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
show this when initializing a new window after quitting a game :
[2021/10/13 09:47:40.840] (INFO ) : [Renderer] Creating surface...
[2021/10/13 09:47:40.840] (INFO ) : [Renderer] Trying Resolution: 640,480
DEBUG: Failed loading eglGetPlatformDisplayEXT: /usr/lib/libGLESv1_CM.so.1: undefined symbol: _eglGetPlatformDisplayEXT
DEBUG: Failed loading _eglGetPlatformDisplayEXT: /usr/lib/libGLESv1_CM.so.1: undefined symbol: __eglGetPlatformDisplayEXT
DEBUG: Mode doesn't have an associated index
DEBUG: Mode doesn't have an associated index
comes from https://github.com/libsdl-org/SDL/blob/345c161feb52f39c4ebfc1cda0cf80c05ce699fc/src/video/kmsdrm/SDL_kmsdrmvideo.c#L1145
Where the mode should be switched.
I tested other calls after the window creation to see if it could make it happen :
SDL_SetWindowFullscreen(mSdlWindow, SDL_WINDOW_FULLSCREN); => Nope
SDL_SetWindowSize(mSdlWindow, mDisplayWidth, mDisplayHeight); => Nope
So i tried to save the mode used on first render, to reapply it :
if(mode.h == 0){
# First render
SDL_GetWindowDisplayMode(mSdlWindow,&mode);
{ LOG(LogInfo) << "[Renderer] Saving mode : "<<mode.w <<"x" << mode.h << "@" << mode.refresh_rate; }
{ LOG(LogInfo) << "[Renderer] Mode index : "<< ((driverdata *)mode.driverdata)->mode_index; }
}
{ LOG(LogInfo) << "[Renderer] Applying mode : "<<mode.w <<"x" << mode.h << "@" << mode.refresh_rate << " index: "<<((driverdata *)mode.driverdata)->mode_index; }
SDL_SetWindowDisplayMode(mSdlWindow, &mode);
=> Nope, it doesn't change the mode.
The SDL_SetWindowDisplayMode
seems not so complicated : https://github.com/libsdl-org/SDL/blob/345c161feb52f39c4ebfc1cda0cf80c05ce699fc/src/video/SDL_video.c#L1145
Uninitializing SDL Video and start it again make the issue diseapear. But it fucks up the controllers.