mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
(Windows) Added game launch workaround for an AMD and Intel GPU issue.
This commit is contained in:
parent
bad7aaf4be
commit
0b47a90b3e
|
@ -989,7 +989,12 @@ void FileData::launchGame(Window* window)
|
|||
// swapBuffers() is called here to turn the screen black to eliminate some potential
|
||||
// flickering and to avoid showing the game launch message briefly when returning
|
||||
// from the game.
|
||||
#if defined(_WIN64)
|
||||
if (!(Settings::getInstance()->getBool("LaunchWorkaround") ||
|
||||
ViewController::get()->runInBackground(mSystem)))
|
||||
#else
|
||||
if (!ViewController::get()->runInBackground(mSystem))
|
||||
#endif
|
||||
Renderer::swapBuffers();
|
||||
|
||||
Scripting::fireEvent("game-start", romPath, getSourceFileData()->metadata.get("name"));
|
||||
|
|
|
@ -1046,6 +1046,27 @@ void GuiMenu::openOtherOptions()
|
|||
}
|
||||
});
|
||||
|
||||
#if defined(_WIN64)
|
||||
// Workaround for launching games on AMD and Intel graphics drivers.
|
||||
auto launch_workaround = std::make_shared<SwitchComponent>(mWindow);
|
||||
launch_workaround->setState(Settings::getInstance()->getBool("LaunchWorkaround"));
|
||||
s->addWithLabel("AMD AND INTEL GPU GAME LAUNCH WORKAROUND", launch_workaround);
|
||||
s->addSaveFunc([launch_workaround, s] {
|
||||
if (launch_workaround->getState() != Settings::getInstance()->getBool("LaunchWorkaround")) {
|
||||
Settings::getInstance()->setBool("LaunchWorkaround", launch_workaround->getState());
|
||||
s->setNeedsSaving();
|
||||
}
|
||||
});
|
||||
|
||||
// If the RunInBackground setting is enabled, then disable this option.
|
||||
if (Settings::getInstance()->getBool("RunInBackground")) {
|
||||
launch_workaround->setEnabled(false);
|
||||
launch_workaround->setOpacity(DISABLED_OPACITY);
|
||||
launch_workaround->getParent()->getChild(launch_workaround->
|
||||
getChildIndex() - 1)->setOpacity(DISABLED_OPACITY);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Whether to upscale the video frame rate to 60 FPS.
|
||||
auto video_upscale_frame_rate = std::make_shared<SwitchComponent>(mWindow);
|
||||
video_upscale_frame_rate->setState(Settings::getInstance()->getBool("VideoUpscaleFrameRate"));
|
||||
|
@ -1180,6 +1201,25 @@ void GuiMenu::openOtherOptions()
|
|||
});
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
// Switch callback.
|
||||
auto launchWorkAroundToggleFunc = [launch_workaround]() {
|
||||
if (launch_workaround->getEnabled()) {
|
||||
launch_workaround->setEnabled(false);
|
||||
launch_workaround->setOpacity(DISABLED_OPACITY);
|
||||
launch_workaround->getParent()->getChild(launch_workaround->
|
||||
getChildIndex() - 1)->setOpacity(DISABLED_OPACITY);
|
||||
}
|
||||
else {
|
||||
launch_workaround->setEnabled(true);
|
||||
launch_workaround->setOpacity(255);
|
||||
launch_workaround->getParent()->getChild(launch_workaround->
|
||||
getChildIndex() - 1)->setOpacity(255);
|
||||
}
|
||||
};
|
||||
run_in_background->setCallback(launchWorkAroundToggleFunc);
|
||||
#endif
|
||||
|
||||
mWindow->pushGui(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,15 +151,16 @@ int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground)
|
|||
&si, // Pointer to the STARTUPINFOW structure.
|
||||
&pi); // Pointer to the PROCESS_INFORMATION structure.
|
||||
|
||||
// Unfortunately suspending ES-DE and resuming when the game/emulator process has exited
|
||||
// doesn't work reliably on Windows, so we may need to keep ES-DE running in the background
|
||||
// while the game is launched. I'm not sure if there is a workaround for this, but on most
|
||||
// Windows installations it seems to work fine so we'll let the user choose via a menu option.
|
||||
// Possibly the issue is specific to Windows 8.
|
||||
// Running in the background is also required for Steam games as ES-DE would otherwise
|
||||
// wait forever for Steam to exit unless it was already running when the game was launched.
|
||||
if (!runInBackground) {
|
||||
// Wait for the child process to exit.
|
||||
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());
|
||||
}
|
||||
|
||||
WaitForSingleObject(pi.hThread, INFINITE);
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
}
|
||||
|
|
|
@ -246,6 +246,9 @@ void Settings::setDefaults()
|
|||
mBoolMap["HideTaskbar"] = { false, false };
|
||||
#endif
|
||||
mBoolMap["RunInBackground"] = { false, false };
|
||||
#if defined(_WIN64)
|
||||
mBoolMap["LaunchWorkaround"] = { true, true };
|
||||
#endif
|
||||
mStringMap["MediaDirectory"] = { "", "" };
|
||||
mBoolMap["VideoUpscaleFrameRate"] = { false, false };
|
||||
mBoolMap["LaunchCommandOverride"] = { true, true };
|
||||
|
|
Loading…
Reference in a new issue