VulkanDevice: Allow 0x0 window size

Fixes minimizing in render-to-separate-window mode.
This commit is contained in:
Stenzek 2025-03-12 23:52:37 +10:00
parent 4fc49ee0ca
commit ba3295930c
No known key found for this signature in database
3 changed files with 5 additions and 5 deletions

View File

@ -666,7 +666,7 @@ float GPU::ComputeDisplayAspectRatio() const
if (g_settings.display_aspect_ratio == DisplayAspectRatio::MatchWindow)
{
const WindowInfo& wi = GPUThread::GetRenderWindowInfo();
if (!wi.IsSurfaceless())
if (!wi.IsSurfaceless() && wi.surface_width > 0 && wi.surface_height > 0)
ar = static_cast<float>(wi.surface_width) / static_cast<float>(wi.surface_height);
}
else if (g_settings.display_aspect_ratio == DisplayAspectRatio::Custom)

View File

@ -1270,8 +1270,9 @@ void GPUThread::DisplayWindowResizedOnThread()
if (!swap_chain)
return;
const float f_width = static_cast<float>(swap_chain->GetWidth());
const float f_height = static_cast<float>(swap_chain->GetHeight());
// our imgui stuff can't cope with 0x0/hidden windows
const float f_width = static_cast<float>(std::max(swap_chain->GetWidth(), 1u));
const float f_height = static_cast<float>(std::max(swap_chain->GetHeight(), 1u));
ImGuiManager::WindowResized(f_width, f_height);
InputManager::SetDisplayWindowSize(f_width, f_height);

View File

@ -540,8 +540,7 @@ bool VulkanSwapChain::CreateSwapChain(VulkanDevice& dev, Error* error)
if (old_swap_chain != VK_NULL_HANDLE)
vkDestroySwapchainKHR(vkdev, old_swap_chain, nullptr);
if (window_size.width == 0 || window_size.width > std::numeric_limits<u16>::max() || window_size.height == 0 ||
window_size.height > std::numeric_limits<u16>::max())
if (window_size.width > std::numeric_limits<u16>::max() || window_size.height > std::numeric_limits<u16>::max())
{
Error::SetStringFmt(error, "Invalid swap chain dimensions: {}x{}", window_size.width, window_size.height);
return false;