From 7e8d1f6434c7bc74df48024490e499cbd4882e5c Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 6 Dec 2021 18:51:50 +0100 Subject: [PATCH] (Windows) Improved game launching with the AMD and Intel GPU workaround setting enabled. --- es-core/src/Platform.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/es-core/src/Platform.cpp b/es-core/src/Platform.cpp index cf2df359d..66801a442 100644 --- a/es-core/src/Platform.cpp +++ b/es-core/src/Platform.cpp @@ -166,17 +166,30 @@ int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool // clang-format on if (!runInBackground) { + int width{}; + int height{}; + if (Settings::getInstance()->getBool("LaunchWorkaround")) { - // Ugly hack to make the emulator window render correctly with some graphics drivers - // (probably only those from AMD and Intel as Nvidia seems to work fine without this). - // Unfortunately this turns the screen white as the emulator is starting. - // This definitely needs a proper solution some time in the future. - SDL_HideWindow(Renderer::getSDLWindow()); - SDL_ShowWindow(Renderer::getSDLWindow()); + // Hack to make the emulator window render correctly with some graphics drivers + // when running at full screen resolution. This is probably only an issue with AMD + // and Intel drivers as Nvidia and software drivers like LLVMpipe work fine without + // this workaround. If not used on affected drivers the emulator window will simply + // be black although the emulator actually works and outputs sounds, accepts input etc. + // There is a white flash the first time an emulator is started during the program + // session and a white single-pixel line will be visible at the bottom of the screen + // when the emulator is loading but it's at least a tolerable workaround. + SDL_GetWindowSize(Renderer::getSDLWindow(), &width, &height); + SDL_SetWindowSize(Renderer::getSDLWindow(), width, height - 1); + SDL_Delay(100); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + Renderer::swapBuffers(); } WaitForSingleObject(pi.hThread, INFINITE); WaitForSingleObject(pi.hProcess, INFINITE); + + if (Settings::getInstance()->getBool("LaunchWorkaround")) + SDL_SetWindowSize(Renderer::getSDLWindow(), width, height); } // If the return value is false, then something failed.