From 10823cd459608a9968b5cc7540123d4b5a3438f5 Mon Sep 17 00:00:00 2001 From: Attila Uygun Date: Tue, 8 Aug 2023 00:02:20 +0200 Subject: [PATCH] Fix memory issue in VulkanContext::SwapBuffers --- src/engine/renderer/vulkan/vulkan_context.cc | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/engine/renderer/vulkan/vulkan_context.cc b/src/engine/renderer/vulkan/vulkan_context.cc index f617863..02f96ef 100644 --- a/src/engine/renderer/vulkan/vulkan_context.cc +++ b/src/engine/renderer/vulkan/vulkan_context.cc @@ -1536,24 +1536,13 @@ bool VulkanContext::SwapBuffers() { /*pWaitSemaphores*/ (separate_present_queue_) ? &image_ownership_semaphores_[frame_index_] : &draw_complete_semaphores_[frame_index_], - /*swapchainCount*/ 0, - /*pSwapchain*/ nullptr, - /*pImageIndices*/ nullptr, + /*swapchainCount*/ 1, + /*pSwapchains*/ &window_.swapchain, + /*pImageIndices*/ &window_.current_buffer, /*pResults*/ nullptr, }; - - VkSwapchainKHR* swapchains = (VkSwapchainKHR*)alloca(sizeof(VkSwapchainKHR*)); - uint32_t* pImageIndices = (uint32_t*)alloca(sizeof(uint32_t*)); - - present.pSwapchains = swapchains; - present.pImageIndices = pImageIndices; - DCHECK(window_.swapchain != VK_NULL_HANDLE); - swapchains[present.swapchainCount] = window_.swapchain; - pImageIndices[present.swapchainCount] = window_.current_buffer; - present.swapchainCount++; - err = QueuePresentKHR(present_queue_, &present); frame_index_ += 1;