diff --git a/ZEngine/ZEngine/Hardwares/VulkanDevice.cpp b/ZEngine/ZEngine/Hardwares/VulkanDevice.cpp index c6b68003..98a96965 100644 --- a/ZEngine/ZEngine/Hardwares/VulkanDevice.cpp +++ b/ZEngine/ZEngine/Hardwares/VulkanDevice.cpp @@ -409,9 +409,6 @@ namespace ZEngine::Hardwares VmaAllocatorCreateInfo vma_allocator_create_info = {.physicalDevice = PhysicalDevice, .device = LogicalDevice, .instance = Instance, .vulkanApiVersion = VK_API_VERSION_1_3}; ZENGINE_VALIDATE_ASSERT(vmaCreateAllocator(&vma_allocator_create_info, &VmaAllocatorValue) == VK_SUCCESS, "Failed to create VMA Allocator") - m_buffer_manager.Initialize(this); - EnqueuedCommandbuffers.init(Arena, m_buffer_manager.TotalCommandBufferCount, m_buffer_manager.TotalCommandBufferCount); - /* * Creating Swapchain */ @@ -428,6 +425,8 @@ namespace ZEngine::Hardwares PreviousFrameIndex = 0; CurrentFrameIndex = 0; + CreateSwapchain(); + SwapchainRenderCompleteSemaphores.init(Arena, SwapchainImageCount, SwapchainImageCount); SwapchainAcquiredSemaphores.init(Arena, SwapchainImageCount, SwapchainImageCount); SwapchainSignalFences.init(Arena, SwapchainImageCount, SwapchainImageCount); @@ -438,7 +437,6 @@ namespace ZEngine::Hardwares SwapchainRenderCompleteSemaphores[i] = ZPushStructCtorArgs(Arena, Primitives::Semaphore, this); SwapchainSignalFences[i] = ZPushStructCtorArgs(Arena, Primitives::Fence, this, true); } - CreateSwapchain(); /* * Creating Global Descriptor Pool for : Textures @@ -1242,6 +1240,9 @@ namespace ZEngine::Hardwares SwapchainFramebuffers.init(Arena, SwapchainImageCount, SwapchainImageCount); } + m_buffer_manager.Initialize(this); + EnqueuedCommandbuffers.init(Arena, m_buffer_manager.TotalCommandBufferCount, m_buffer_manager.TotalCommandBufferCount); + scratch = ZGetScratch(Arena); Array SwapchainImages = {}; @@ -2004,10 +2005,10 @@ namespace ZEngine::Hardwares } } - void CommandBufferManager::Initialize(VulkanDevice* device, uint8_t swapchain_image_count, int thread_count) + void CommandBufferManager::Initialize(VulkanDevice* device, int thread_count) { Device = device; - m_total_pool_count = swapchain_image_count * thread_count; + m_total_pool_count = device->SwapchainImageCount * thread_count; TotalCommandBufferCount = m_total_pool_count * MaxBufferPerPool; m_instant_fence = ZPushStructCtorArgs(Device->Arena, Primitives::Fence, device); m_instant_semaphore = ZPushStructCtorArgs(Device->Arena, Primitives::Semaphore, device);