mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
vk: Fixup and refactor for exclusive fullscreen stuff
This commit is contained in:
parent
76518d4c59
commit
9f97bab717
@ -574,6 +574,51 @@ namespace vk
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<VkSurfaceCapabilitiesKHR, bool> init_surface_capabilities()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (g_cfg.video.vk.force_disable_exclusive_fullscreen_mode && dev.get_surface_capabilities_2_support())
|
||||
{
|
||||
HMONITOR hmonitor = MonitorFromWindow(window_handle, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (hmonitor)
|
||||
{
|
||||
VkSurfaceCapabilities2KHR pSurfaceCapabilities = {};
|
||||
pSurfaceCapabilities.sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR;
|
||||
|
||||
VkPhysicalDeviceSurfaceInfo2KHR pSurfaceInfo = {};
|
||||
pSurfaceInfo.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR;
|
||||
pSurfaceInfo.surface = m_surface;
|
||||
|
||||
VkSurfaceCapabilitiesFullScreenExclusiveEXT full_screen_exclusive_capabilities = {};
|
||||
VkSurfaceFullScreenExclusiveWin32InfoEXT full_screen_exclusive_win32_info = {};
|
||||
full_screen_exclusive_capabilities.sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT;
|
||||
|
||||
pSurfaceCapabilities.pNext = &full_screen_exclusive_capabilities;
|
||||
|
||||
full_screen_exclusive_win32_info.sType = VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT;
|
||||
full_screen_exclusive_win32_info.hmonitor = hmonitor;
|
||||
|
||||
pSurfaceInfo.pNext = &full_screen_exclusive_win32_info;
|
||||
|
||||
auto getPhysicalDeviceSurfaceCapabilities2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR>(
|
||||
vkGetInstanceProcAddr(dev.gpu(), "vkGetPhysicalDeviceSurfaceCapabilities2KHR")
|
||||
);
|
||||
ensure(getPhysicalDeviceSurfaceCapabilities2KHR);
|
||||
CHECK_RESULT(getPhysicalDeviceSurfaceCapabilities2KHR(dev.gpu(), &pSurfaceInfo, &pSurfaceCapabilities));
|
||||
|
||||
return { pSurfaceCapabilities.surfaceCapabilities, !!full_screen_exclusive_capabilities.fullScreenExclusiveSupported };
|
||||
}
|
||||
else
|
||||
{
|
||||
rsx_log.warning("Swapchain: failed to get monitor for the window");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
VkSurfaceCapabilitiesKHR surface_descriptors = {};
|
||||
CHECK_RESULT(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(dev.gpu(), m_surface, &surface_descriptors));
|
||||
return { surface_descriptors, false };
|
||||
}
|
||||
|
||||
using WSI_swapchain_base::init;
|
||||
bool init() override
|
||||
{
|
||||
@ -586,49 +631,7 @@ namespace vk
|
||||
VkSwapchainKHR old_swapchain = m_vk_swapchain;
|
||||
vk::physical_device& gpu = const_cast<vk::physical_device&>(dev.gpu());
|
||||
|
||||
VkSurfaceCapabilities2KHR pSurfaceCapabilities = {};
|
||||
pSurfaceCapabilities.sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR;
|
||||
|
||||
VkPhysicalDeviceSurfaceInfo2KHR pSurfaceInfo = {};
|
||||
pSurfaceInfo.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR;
|
||||
pSurfaceInfo.surface = m_surface;
|
||||
|
||||
VkSurfaceCapabilitiesKHR surface_descriptors;
|
||||
bool init_surface_descriptors = true;
|
||||
#ifdef _WIN32
|
||||
bool should_disable_exclusive_full_screen = false;
|
||||
if (g_cfg.video.vk.force_disable_exclusive_fullscreen_mode && dev.get_surface_capabilities_2_support())
|
||||
{
|
||||
HMONITOR hmonitor = MonitorFromWindow(window_handle, MONITOR_DEFAULTTOPRIMARY);
|
||||
if (hmonitor)
|
||||
{
|
||||
VkSurfaceCapabilitiesFullScreenExclusiveEXT full_screen_exclusive_capabilities = {};
|
||||
VkSurfaceFullScreenExclusiveWin32InfoEXT full_screen_exclusive_win32_info = {};
|
||||
full_screen_exclusive_capabilities.sType = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT;
|
||||
|
||||
pSurfaceCapabilities.pNext = reinterpret_cast<void*>(&full_screen_exclusive_capabilities);
|
||||
|
||||
full_screen_exclusive_win32_info.sType = VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT;
|
||||
full_screen_exclusive_win32_info.hmonitor = hmonitor;
|
||||
|
||||
pSurfaceInfo.pNext = reinterpret_cast<void*>(&full_screen_exclusive_win32_info);
|
||||
|
||||
CHECK_RESULT(vkGetPhysicalDeviceSurfaceCapabilities2KHR(gpu, &pSurfaceInfo, &pSurfaceCapabilities));
|
||||
|
||||
surface_descriptors = pSurfaceCapabilities.surfaceCapabilities;
|
||||
init_surface_descriptors = false;
|
||||
should_disable_exclusive_full_screen = !!full_screen_exclusive_capabilities.fullScreenExclusiveSupported;
|
||||
}
|
||||
else
|
||||
rsx_log.warning("Swapchain: failed to get monitor for the window");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (init_surface_descriptors)
|
||||
{
|
||||
surface_descriptors = {};
|
||||
CHECK_RESULT(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu, m_surface, &surface_descriptors));
|
||||
}
|
||||
auto [surface_descriptors, should_disable_exclusive_full_screen] = init_surface_capabilities();
|
||||
|
||||
if (surface_descriptors.maxImageExtent.width < m_width ||
|
||||
surface_descriptors.maxImageExtent.height < m_height)
|
||||
@ -741,7 +744,7 @@ namespace vk
|
||||
full_screen_exclusive_info.sType = VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT;
|
||||
full_screen_exclusive_info.fullScreenExclusive = VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT;
|
||||
|
||||
swap_info.pNext = reinterpret_cast<void*>(&full_screen_exclusive_info);
|
||||
swap_info.pNext = &full_screen_exclusive_info;
|
||||
}
|
||||
|
||||
rsx_log.notice("Swapchain: requesting full screen exclusive mode %d.", static_cast<int>(full_screen_exclusive_info.fullScreenExclusive));
|
||||
|
Loading…
Reference in New Issue
Block a user