(Windows) Changed the fullscreen mode to SDL_WINDOW_BORDERLESS.

Also removed the 'AMD and Intel GPU game launch workaround' menu option.
This commit is contained in:
Leon Styhre 2021-12-09 18:53:22 +01:00
parent 9b312881a2
commit 045e56ae3f
5 changed files with 25 additions and 80 deletions

View file

@ -1082,12 +1082,7 @@ void FileData::launchGame(Window* window)
// swapBuffers() is called here to turn the screen black to eliminate some potential // 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 // flickering and to avoid showing the game launch message briefly when returning
// from the game. // from the game.
#if defined(_WIN64)
if (!(Settings::getInstance()->getBool("LaunchWorkaround") || runInBackground))
#else
if (!runInBackground) if (!runInBackground)
#endif
Renderer::swapBuffers(); Renderer::swapBuffers();
Scripting::fireEvent("game-start", romPath, getSourceFileData()->metadata.get("name"), Scripting::fireEvent("game-start", romPath, getSourceFileData()->metadata.get("name"),

View file

@ -986,28 +986,6 @@ 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 gray out 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
#if defined(VIDEO_HW_DECODING) #if defined(VIDEO_HW_DECODING)
// Whether to enable hardware decoding for the FFmpeg video player. // Whether to enable hardware decoding for the FFmpeg video player.
auto video_hardware_decoding = std::make_shared<SwitchComponent>(mWindow); auto video_hardware_decoding = std::make_shared<SwitchComponent>(mWindow);
@ -1173,27 +1151,6 @@ void GuiMenu::openOtherOptions()
}); });
#endif #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
s->setSize(mSize); s->setSize(mSize);
mWindow->pushGui(s); mWindow->pushGui(s);
} }

View file

@ -169,27 +169,22 @@ int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool
int width{}; int width{};
int height{}; int height{};
if (Settings::getInstance()->getBool("LaunchWorkaround")) { // Hack to make the emulator window render correctly when launching games while running in
// Hack to make the emulator window render correctly with some graphics drivers // full screen mode. If not done, the emulator window will simply be black although the
// when running at full screen resolution. This is probably only an issue with AMD // game actually works and outputs sounds, accepts input etc. There is sometimes a white
// and Intel drivers as Nvidia and software drivers like LLVMpipe work fine without // flash the first time an emulator is started during the program session and a white
// this workaround. If not used on affected drivers the emulator window will simply // single-pixel line will be visible at the bottom of the screen while the game is loading.
// be black although the emulator actually works and outputs sounds, accepts input etc. // But it's at least a tolerable workaround.
// There is a white flash the first time an emulator is started during the program SDL_GetWindowSize(Renderer::getSDLWindow(), &width, &height);
// session and a white single-pixel line will be visible at the bottom of the screen SDL_SetWindowSize(Renderer::getSDLWindow(), width, height - 1);
// when the emulator is loading but it's at least a tolerable workaround. SDL_Delay(100);
SDL_GetWindowSize(Renderer::getSDLWindow(), &width, &height); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SDL_SetWindowSize(Renderer::getSDLWindow(), width, height - 1); Renderer::swapBuffers();
SDL_Delay(100);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Renderer::swapBuffers();
}
WaitForSingleObject(pi.hThread, INFINITE); WaitForSingleObject(pi.hThread, INFINITE);
WaitForSingleObject(pi.hProcess, INFINITE); WaitForSingleObject(pi.hProcess, INFINITE);
if (Settings::getInstance()->getBool("LaunchWorkaround")) SDL_SetWindowSize(Renderer::getSDLWindow(), width, height);
SDL_SetWindowSize(Renderer::getSDLWindow(), width, height);
} }
// If the return value is false, then something failed. // If the return value is false, then something failed.

View file

@ -233,9 +233,6 @@ void Settings::setDefaults()
mBoolMap["VSyncWorkaround"] = {true, true}; mBoolMap["VSyncWorkaround"] = {true, true};
#endif #endif
mBoolMap["RunInBackground"] = {false, false}; mBoolMap["RunInBackground"] = {false, false};
#if defined(_WIN64)
mBoolMap["LaunchWorkaround"] = {true, true};
#endif
#if defined(VIDEO_HW_DECODING) #if defined(VIDEO_HW_DECODING)
mBoolMap["VideoHardwareDecoding"] = {false, false}; mBoolMap["VideoHardwareDecoding"] = {false, false};
#endif #endif

View file

@ -159,36 +159,37 @@ namespace Renderer
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
#endif #endif
#if defined(__APPLE__) || defined(__unix__)
bool userResolution = false; bool userResolution = false;
// Check if the user has changed the resolution from the command line. // Check if the user has changed the resolution from the command line.
if (windowWidth != displayMode.w || windowHeight != displayMode.h) if (windowWidth != displayMode.w || windowHeight != displayMode.h)
userResolution = true; userResolution = true;
// Not sure if this could be a useful setting for some users.
// SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
#endif
unsigned int windowFlags; unsigned int windowFlags;
setupWindow(); setupWindow();
#if defined(_WIN64) #if defined(_WIN64)
// For Windows, always set the mode to windowed as full screen mode seems to behave quite // For Windows we use SDL_WINDOW_BORDERLESS as "real" full screen doesn't work properly.
// erratic. There may be a proper fix for this, but for now windowed mode seems to behave // The borderless mode seems to behave well and it's almost completely seamless, especially
// well and it's almost completely seamless, especially with a hidden taskbar. // with a hidden taskbar.
windowFlags = getWindowFlags(); if (!userResolution)
windowFlags = SDL_WINDOW_BORDERLESS | getWindowFlags();
else
// If the resolution has been manually set from the command line, then keep the border.
windowFlags = getWindowFlags();
#elif defined(__APPLE__) #elif defined(__APPLE__)
// Not sure if this could be a useful setting.
// SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
// The SDL_WINDOW_BORDERLESS mode seems to be the only mode that somehow works on macOS // The SDL_WINDOW_BORDERLESS mode seems to be the only mode that somehow works on macOS
// as a real fullscreen mode will do lots of weird stuff like preventing window switching // as a real fullscreen mode will do lots of weird stuff like preventing window switching
// or refusing to let emulators run at all. SDL_WINDOW_FULLSCREEN_DESKTOP almost works, but // or refusing to let emulators run at all. SDL_WINDOW_FULLSCREEN_DESKTOP almost works, but
// it "shuffles" windows when starting the emulator and won't return properly when the game // it "shuffles" windows when starting the emulator and won't return properly when the game
// has exited. With SDL_WINDOW_BORDERLESS some emulators (like RetroArch) have to be // has exited. With SDL_WINDOW_BORDERLESS some emulators (like RetroArch) have to be
// configured to run in fullscreen mode or switching to its window will not work when a // configured to run in fullscreen mode or switching to its window will not work, but
// game is launched. So there is room for improvement although it's acceptable for now. // apart from that this mode works fine.
if (!userResolution) if (!userResolution)
windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI | getWindowFlags(); windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI | getWindowFlags();
else else
// If the user has changed the resolution from the command line, then add a
// border to the window.
windowFlags = SDL_WINDOW_ALLOW_HIGHDPI | getWindowFlags(); windowFlags = SDL_WINDOW_ALLOW_HIGHDPI | getWindowFlags();
#else #else
if (!userResolution) if (!userResolution)