Skip to content

Commit c31b438

Browse files
Re-Arrange Code flow after swapchainimage count change
- The code that relies on the SwapchainImageCount such as the command buffer are re-arranged to ensure that they run after we establish the correct number of Swapchain Images
1 parent 4e16169 commit c31b438

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

ZEngine/ZEngine/Hardwares/VulkanDevice.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,6 @@ namespace ZEngine::Hardwares
409409
VmaAllocatorCreateInfo vma_allocator_create_info = {.physicalDevice = PhysicalDevice, .device = LogicalDevice, .instance = Instance, .vulkanApiVersion = VK_API_VERSION_1_3};
410410
ZENGINE_VALIDATE_ASSERT(vmaCreateAllocator(&vma_allocator_create_info, &VmaAllocatorValue) == VK_SUCCESS, "Failed to create VMA Allocator")
411411

412-
m_buffer_manager.Initialize(this);
413-
EnqueuedCommandbuffers.init(Arena, m_buffer_manager.TotalCommandBufferCount, m_buffer_manager.TotalCommandBufferCount);
414-
415412
/*
416413
* Creating Swapchain
417414
*/
@@ -428,6 +425,10 @@ namespace ZEngine::Hardwares
428425
PreviousFrameIndex = 0;
429426
CurrentFrameIndex = 0;
430427

428+
CreateSwapchain();
429+
430+
EnqueuedCommandbuffers.init(Arena, m_buffer_manager.TotalCommandBufferCount, m_buffer_manager.TotalCommandBufferCount);
431+
431432
SwapchainRenderCompleteSemaphores.init(Arena, SwapchainImageCount, SwapchainImageCount);
432433
SwapchainAcquiredSemaphores.init(Arena, SwapchainImageCount, SwapchainImageCount);
433434
SwapchainSignalFences.init(Arena, SwapchainImageCount, SwapchainImageCount);
@@ -438,7 +439,6 @@ namespace ZEngine::Hardwares
438439
SwapchainRenderCompleteSemaphores[i] = ZPushStructCtorArgs(Arena, Primitives::Semaphore, this);
439440
SwapchainSignalFences[i] = ZPushStructCtorArgs(Arena, Primitives::Fence, this, true);
440441
}
441-
CreateSwapchain();
442442

443443
/*
444444
* Creating Global Descriptor Pool for : Textures
@@ -1242,6 +1242,8 @@ namespace ZEngine::Hardwares
12421242
SwapchainFramebuffers.init(Arena, SwapchainImageCount, SwapchainImageCount);
12431243
}
12441244

1245+
m_buffer_manager.Initialize(this, SwapchainImageCount);
1246+
12451247
scratch = ZGetScratch(Arena);
12461248

12471249
Array<VkImage> SwapchainImages = {};

0 commit comments

Comments
 (0)