(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
// flickering and to avoid showing the game launch message briefly when returning
// from the game.
#if defined(_WIN64)
if (!(Settings::getInstance()->getBool("LaunchWorkaround") || runInBackground))
#else
if (!runInBackground)
#endif
Renderer::swapBuffers();
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)
// Whether to enable hardware decoding for the FFmpeg video player.
auto video_hardware_decoding = std::make_shared<SwitchComponent>(mWindow);
@ -1173,27 +1151,6 @@ 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
s->setSize(mSize);
mWindow->pushGui(s);
}

View file

@ -169,26 +169,21 @@ int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool
int width{};
int height{};
if (Settings::getInstance()->getBool("LaunchWorkaround")) {
// 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.
// Hack to make the emulator window render correctly when launching games while running in
// full screen mode. If not done, the emulator window will simply be black although the
// game actually works and outputs sounds, accepts input etc. There is sometimes 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 while the game 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);
}

View file

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

View file

@ -159,36 +159,37 @@ namespace Renderer
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
#endif
#if defined(__APPLE__) || defined(__unix__)
bool userResolution = false;
// Check if the user has changed the resolution from the command line.
if (windowWidth != displayMode.w || windowHeight != displayMode.h)
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;
setupWindow();
#if defined(_WIN64)
// For Windows, always set the mode to windowed as full screen mode seems to behave quite
// erratic. There may be a proper fix for this, but for now windowed mode seems to behave
// well and it's almost completely seamless, especially with a hidden taskbar.
// For Windows we use SDL_WINDOW_BORDERLESS as "real" full screen doesn't work properly.
// The borderless mode seems to behave well and it's almost completely seamless, especially
// with a hidden taskbar.
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__)
// 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
// 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
// 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
// configured to run in fullscreen mode or switching to its window will not work when a
// game is launched. So there is room for improvement although it's acceptable for now.
// configured to run in fullscreen mode or switching to its window will not work, but
// apart from that this mode works fine.
if (!userResolution)
windowFlags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_ALLOW_HIGHDPI | getWindowFlags();
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();
#else
if (!userResolution)