From 173a33886c72304aea923382ec114679dcad6ba4 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 9 Sep 2017 14:04:26 +1000 Subject: Vulkan: Move render pass management to ObjectCache --- Source/Core/VideoBackends/Vulkan/main.cpp | 51 +++++++++++++++---------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/main.cpp') diff --git a/Source/Core/VideoBackends/Vulkan/main.cpp b/Source/Core/VideoBackends/Vulkan/main.cpp index 90621d23ec..63b7921442 100644 --- a/Source/Core/VideoBackends/Vulkan/main.cpp +++ b/Source/Core/VideoBackends/Vulkan/main.cpp @@ -186,6 +186,25 @@ bool VideoBackend::Initialize(void* window_handle) // With the backend information populated, we can now initialize videocommon. InitializeShared(); + // Create command buffers. We do this separately because the other classes depend on it. + g_command_buffer_mgr = std::make_unique(g_Config.bBackendMultithreading); + if (!g_command_buffer_mgr->Initialize()) + { + PanicAlert("Failed to create Vulkan command buffers"); + Shutdown(); + return false; + } + + // Remaining classes are also dependent on object/shader cache. + g_object_cache = std::make_unique(); + g_shader_cache = std::make_unique(); + if (!g_object_cache->Initialize() || !g_shader_cache->Initialize()) + { + PanicAlert("Failed to initialize Vulkan object cache."); + Shutdown(); + return false; + } + // Create swap chain. This has to be done early so that the target size is correct for auto-scale. std::unique_ptr swap_chain; if (surface != VK_NULL_HANDLE) @@ -199,39 +218,19 @@ bool VideoBackend::Initialize(void* window_handle) } } - // Create command buffers. We do this separately because the other classes depend on it. - g_command_buffer_mgr = std::make_unique(g_Config.bBackendMultithreading); - if (!g_command_buffer_mgr->Initialize()) - { - PanicAlert("Failed to create Vulkan command buffers"); - Shutdown(); - return false; - } - // Create main wrapper instances. - g_object_cache = std::make_unique(); - g_shader_cache = std::make_unique(); g_framebuffer_manager = std::make_unique(); g_renderer = std::make_unique(std::move(swap_chain)); + g_vertex_manager = std::make_unique(); + g_texture_cache = std::make_unique(); + g_perf_query = std::make_unique(); // Invoke init methods on main wrapper classes. // These have to be done before the others because the destructors // for the remaining classes may call methods on these. - if (!g_object_cache->Initialize() || !g_shader_cache->Initialize() || - !StateTracker::CreateInstance() || !FramebufferManager::GetInstance()->Initialize() || - !Renderer::GetInstance()->Initialize()) - { - PanicAlert("Failed to initialize Vulkan classes."); - Shutdown(); - return false; - } - - // Create remaining wrapper instances. - g_vertex_manager = std::make_unique(); - g_texture_cache = std::make_unique(); - g_perf_query = std::make_unique(); - if (!VertexManager::GetInstance()->Initialize() || !TextureCache::GetInstance()->Initialize() || - !PerfQuery::GetInstance()->Initialize()) + if (!StateTracker::CreateInstance() || !FramebufferManager::GetInstance()->Initialize() || + !Renderer::GetInstance()->Initialize() || !VertexManager::GetInstance()->Initialize() || + !TextureCache::GetInstance()->Initialize() || !PerfQuery::GetInstance()->Initialize()) { PanicAlert("Failed to initialize Vulkan classes."); Shutdown(); -- cgit v1.2.3