From 229f8d37cbb1c15afba0799c7f30f2ff2a62a290 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 9 Mar 2020 02:46:22 -0700 Subject: [PATCH] win-capture/graphics-hook: Fix reacquire bug Sometimes the width/height would initially be at 0x0 when the swap chain was alt-tabbing, causing the capture to fail full-stop when trying to reacquire. --- plugins/win-capture/graphics-hook/vulkan-capture.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/win-capture/graphics-hook/vulkan-capture.c b/plugins/win-capture/graphics-hook/vulkan-capture.c index 9069a6875..0c97fc988 100644 --- a/plugins/win-capture/graphics-hook/vulkan-capture.c +++ b/plugins/win-capture/graphics-hook/vulkan-capture.c @@ -935,6 +935,11 @@ static inline HWND get_swap_window(struct vk_swap_data *swap) return NULL; } +static inline bool valid_rect(struct vk_swap_data *swap) +{ + return !!swap->image_extent.width && !!swap->image_extent.height; +} + static void vk_capture(struct vk_data *data, VkQueue queue, const VkPresentInfoKHR *info) { @@ -965,7 +970,7 @@ static void vk_capture(struct vk_data *data, VkQueue queue, vk_shtex_free(data); } if (capture_should_init()) { - if (!vk_shtex_init(data, window, swap)) { + if (valid_rect(swap) && !vk_shtex_init(data, window, swap)) { vk_shtex_free(data); data->valid = false; }