Skip to content

Commit

Permalink
vulkan: test for invalid/hidden swapchain
Browse files Browse the repository at this point in the history
In practice, this is done by communicating a current extent of 0.

Probably helps with #65
  • Loading branch information
haasn committed Dec 23, 2019
1 parent 8230603 commit f2178b8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vulkan/swapchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ static bool update_swapchain_info(struct priv *p, VkSwapchainCreateInfoKHR *info
VkSurfaceCapabilitiesKHR caps;
VK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vk->physd, p->surf, &caps));

// Check for hidden/invisible window
if (!caps.currentExtent.width || !caps.currentExtent.height) {
PL_DEBUG(vk, "maxImageExtent reported as 0x0, hidden window? skipping");
return false;
}

// Sorted by preference
static const struct { VkCompositeAlphaFlagsKHR vk_mode;
enum pl_alpha_mode pl_mode;
Expand Down Expand Up @@ -486,7 +492,7 @@ static bool vk_sw_recreate(const struct pl_swapchain *sw, int w, int h)
sinfo.oldSwapchain = p->swapchain;

if (!update_swapchain_info(p, &sinfo, w, h))
goto error;
return false;

PL_INFO(sw, "(Re)creating swapchain of size %dx%d",
sinfo.imageExtent.width,
Expand Down

0 comments on commit f2178b8

Please sign in to comment.