From 06d62cf86a5b0c0cd6b52e25b5e6711c25739620 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 31 May 2022 20:18:27 +0200 Subject: [PATCH] Simplify vulkan set_resize function callbacks --- gfx/drivers_context/w_vk_ctx.c | 33 ++++++++++++---------------- gfx/drivers_context/wayland_vk_ctx.c | 18 +++++++-------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/gfx/drivers_context/w_vk_ctx.c b/gfx/drivers_context/w_vk_ctx.c index ecf5efa36b..f5ed81cada 100644 --- a/gfx/drivers_context/w_vk_ctx.c +++ b/gfx/drivers_context/w_vk_ctx.c @@ -139,18 +139,18 @@ static void gfx_ctx_w_vk_swap_buffers(void *data) static bool gfx_ctx_w_vk_set_resize(void *data, unsigned width, unsigned height) { - if (!vulkan_create_swapchain(&win32_vk, width, height, win32_vk_interval)) + if (vulkan_create_swapchain(&win32_vk, width, height, win32_vk_interval)) { - RARCH_ERR("[Vulkan]: Failed to update swapchain.\n"); - return false; + if (win32_vk.created_new_swapchain) + vulkan_acquire_next_image(&win32_vk); + win32_vk.context.invalid_swapchain = true; + win32_vk.need_new_swapchain = false; + + return true; } - if (win32_vk.created_new_swapchain) - vulkan_acquire_next_image(&win32_vk); - win32_vk.context.invalid_swapchain = true; - win32_vk.need_new_swapchain = false; - - return true; + RARCH_ERR("[Vulkan]: Failed to update swapchain.\n"); + return false; } static void gfx_ctx_w_vk_update_title(void *data) @@ -175,8 +175,6 @@ static void gfx_ctx_w_vk_get_video_size(void *data, { HWND window = win32_get_window(); - (void)data; - if (!window) { RECT mon_rect; @@ -270,20 +268,17 @@ static bool gfx_ctx_w_vk_set_video_mode(void *data, { win32_vk.fullscreen = fullscreen; - if (!win32_set_video_mode(NULL, width, height, fullscreen)) + if (win32_set_video_mode(NULL, width, height, fullscreen)) { - RARCH_ERR("[Vulkan]: win32_set_video_mode failed.\n"); - goto error; - } - else /* Create a new swapchain in order to prevent fullscreen * emulated mailbox crash caused by refresh rate change */ vulkan_create_swapchain(&win32_vk, width, height, win32_vk_interval); - gfx_ctx_w_vk_swap_interval(data, win32_vk_interval); - return true; + gfx_ctx_w_vk_swap_interval(data, win32_vk_interval); + return true; + } -error: + RARCH_ERR("[Vulkan]: win32_set_video_mode failed.\n"); gfx_ctx_w_vk_destroy(data); return false; } diff --git a/gfx/drivers_context/wayland_vk_ctx.c b/gfx/drivers_context/wayland_vk_ctx.c index f19e4de04a..1b25d6d900 100644 --- a/gfx/drivers_context/wayland_vk_ctx.c +++ b/gfx/drivers_context/wayland_vk_ctx.c @@ -98,18 +98,16 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) wl->vk.context.invalid_swapchain = true; if (wl->vk.created_new_swapchain) vulkan_acquire_next_image(&wl->vk); - } - else - { - RARCH_ERR("[Wayland/Vulkan]: Failed to update swapchain.\n"); - return false; + + wl->vk.need_new_swapchain = false; + + wl_surface_set_buffer_scale(wl->surface, wl->buffer_scale); + + return true; } - wl->vk.need_new_swapchain = false; - - wl_surface_set_buffer_scale(wl->surface, wl->buffer_scale); - - return true; + RARCH_ERR("[Wayland/Vulkan]: Failed to update swapchain.\n"); + return false; } static void gfx_ctx_wl_update_title(void *data)