diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index 9b384731eb..e51ba32a91 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -1530,6 +1530,12 @@ bool VulkanContext::InitSwapchain(VkPresentModeKHR desiredPresentMode) { swap_chain_info.compositeAlpha = VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR; } +#ifdef VK_EXT_full_screen_exclusive + VkSurfaceFullScreenExclusiveInfoEXT fullScreenInfo{ VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT }; + fullScreenInfo.fullScreenExclusive = fullScreenExclusiveMode_; + swap_chain_info.pNext = &fullScreenInfo; +#endif + res = vkCreateSwapchainKHR(device_, &swap_chain_info, NULL, &swapchain_); if (res != VK_SUCCESS) { ERROR_LOG(Log::G3D, "vkCreateSwapchainKHR failed! %s", VulkanResultToString(res)); diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index 6df3e67864..e1d1d8bd8e 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -412,6 +412,10 @@ public: return presentMode_; } +#ifdef VK_EXT_full_screen_exclusive + void SetFullScreenExclusiveMode(VkFullScreenExclusiveEXT mode) { fullScreenExclusiveMode_ = mode; } +#endif + std::vector GetAvailablePresentModes() const { return availablePresentModes_; } @@ -530,6 +534,11 @@ private: PhysicalDeviceFeatures deviceFeatures_; +#ifdef VK_EXT_full_screen_exclusive + VkFullScreenExclusiveEXT fullScreenExclusiveMode_ = VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT; +#endif + + VkSurfaceCapabilitiesKHR surfCapabilities_{}; std::vector surfFormats_{}; diff --git a/Core/Config.cpp b/Core/Config.cpp index 8114467109..5f650ad535 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -749,6 +749,7 @@ static const ConfigSetting graphicsSettings[] = { #ifndef MOBILE_DEVICE ConfigSetting("FullScreen", SETTING(g_Config, bFullScreen), false, CfgFlag::DEFAULT), ConfigSetting("FullScreenMulti", SETTING(g_Config, bFullScreenMulti), false, CfgFlag::DEFAULT), + ConfigSetting("FullScreenExclusive", SETTING(g_Config, bFullScreenExclusive), false, CfgFlag::DEFAULT), #endif #if PPSSPP_PLATFORM(IOS) diff --git a/Core/Config.h b/Core/Config.h index 08648c2d5f..cb56aacaa3 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -325,6 +325,7 @@ public: int iAppSwitchMode; bool bFullScreen; bool bFullScreenMulti; + bool bFullScreenExclusive; int iInternalResolution; // 0 = Auto (native), 1 = 1x (480x272), 2 = 2x, 3 = 3x, 4 = 4x and so on. int iAnisotropyLevel; // 0 - 5, powers of 2: 0 = 1x = no aniso int iMultiSampleLevel; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index bfae4e00dd..87d3464720 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -421,6 +421,10 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) System_ApplyFullscreenState(); }); } + CheckBox* fullscreenExclusive = graphicsSettings->Add(new CheckBox(&g_Config.bFullScreenExclusive, gr->T("Exclusive fullscreen"))); + fullscreenExclusive->SetEnabledFunc([] { + return g_Config.bFullScreen; + }); #endif // Display Layout Editor: To avoid overlapping touch controls on large tablets, meet geeky demands for integer zoom/unstretched image etc. Choice *displayEditor = graphicsSettings->Add(new Choice(gr->T("Display layout & effects"))); diff --git a/Windows/GPU/WindowsVulkanContext.cpp b/Windows/GPU/WindowsVulkanContext.cpp index 243f210345..192386d5f2 100644 --- a/Windows/GPU/WindowsVulkanContext.cpp +++ b/Windows/GPU/WindowsVulkanContext.cpp @@ -126,6 +126,13 @@ bool WindowsVulkanContext::Init(HINSTANCE hInst, HWND hWnd, std::string *error_m draw_ = Draw::T3DCreateVulkanContext(vulkan_, useMultiThreading); VkPresentModeKHR presentMode = ConfigPresentModeToVulkan(draw_); + +#ifdef VK_EXT_full_screen_exclusive + vulkan_->SetFullScreenExclusiveMode(g_Config.bFullScreen && g_Config.bFullScreenExclusive + ? VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT + : VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT); +#endif + if (!vulkan_->InitSwapchain(presentMode)) { *error_message = vulkan_->InitError(); Shutdown(); @@ -169,6 +176,13 @@ void WindowsVulkanContext::Shutdown() { void WindowsVulkanContext::Resize() { draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); VkPresentModeKHR presentMode = ConfigPresentModeToVulkan(draw_); + +#ifdef VK_EXT_full_screen_exclusive + vulkan_->SetFullScreenExclusiveMode(g_Config.bFullScreen && g_Config.bFullScreenExclusive + ? VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT + : VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT); +#endif + vulkan_->InitSwapchain(presentMode); draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); }