(Windows) Improved game launching with the AMD and Intel GPU workaround setting enabled.

This commit is contained in:
Leon Styhre 2021-12-06 18:51:50 +01:00
parent 9cb88e822f
commit 7e8d1f6434

View file

@ -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.