Fixed window resizing

This commit is contained in:
Piotr Krygier committed 2025-06-20 13:44:33 +02:00
1 parent f197280e88
commit 3c72c9b387
6 files changed
+61 -17

No files matched your search

+13 -4
View File
@@ -29,6 +29,7 @@
#include "locale_vulkan.h"
#include "utilities/rse_errors_common.h"
#include "utilities/logger.h"
#include "vulkan/vulkan_core.h"
#include "vulkan_errors.h"
#include "window.h"
@@ -553,8 +554,8 @@ static rse_err_t create_sync_objects()
if (VK_SUCCESS != vkCreateSemaphore(g_vulkan_state.device, &semaphore_info, NULL, &g_image_available_semaphores[i]) ||
VK_SUCCESS != vkCreateSemaphore(g_vulkan_state.device, &semaphore_info, NULL, &g_render_finished_semaphores[i]) ||
VK_SUCCESS != vkCreateFence(g_vulkan_state.device, &fenceInfo, NULL, &g_in_flight_fences[i])) {
LOGF(vulkan_messages[VULKAN_SYNCOBJCTS_CREATION_FAILED]);
return VULKAN_ERROR_SYNCOBJCTS_CREATION_FAILED;
LOGF(vulkan_messages[VULKAN_SYNCOBJCTS_CREATION_FAILED]);
return VULKAN_ERROR_SYNCOBJCTS_CREATION_FAILED;
}
}
@@ -613,7 +614,7 @@ rse_err_t draw_frame()
result = vkAcquireNextImageKHR(g_vulkan_state.device, g_vulkan_state.swapchain, UINT64_MAX, g_image_available_semaphores[g_vulkan_state.current_frame],
VK_NULL_HANDLE, &image_index);
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) {
if (result == VK_ERROR_OUT_OF_DATE_KHR) {
recreate_swapchain();
return RSE_ERROR_NO_ERROR;
} else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
@@ -660,7 +661,15 @@ rse_err_t draw_frame()
present_info.pImageIndices = &image_index;
vkQueuePresentKHR(g_present_queue, &present_info);
result = vkQueuePresentKHR(g_present_queue, &present_info);
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || is_framebuffer_resized()) {
reset_framebuffer_resized();
recreate_swapchain();
} else if (result != VK_SUCCESS) {
LOGF(vulkan_messages[VULAKN_DRAW_FAILED]);
return VULKAN_ERROR_DRAW_FAILED;
}
g_vulkan_state.current_frame = (g_vulkan_state.current_frame + 1) % SWAP_BUFFER_COUNT;