From 76161df6cd536477a591987f5f4eaea0d60310c9 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 3 Jun 2022 23:41:46 +0200 Subject: [PATCH] mult frames in flight --- .../src/mm/services/vulkan_renderer.cpp | 70 +++++++++++-------- .../src/mm/services/vulkan_renderer.hpp | 6 +- 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/framework/vulkan_renderer/src/mm/services/vulkan_renderer.cpp b/framework/vulkan_renderer/src/mm/services/vulkan_renderer.cpp index e96a9f6..21c0480 100644 --- a/framework/vulkan_renderer/src/mm/services/vulkan_renderer.cpp +++ b/framework/vulkan_renderer/src/mm/services/vulkan_renderer.cpp @@ -21,8 +21,10 @@ VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE // create a dispatcher, based on additional vkDevice/vkGetDeviceProcAddr static void setup_dispacher(void) { -#if 1 - // investigate why this stopped working + // both should work + // but vk::DynamicLoader reloads the dll, so it will be open more then once + // and also might be a different one from sdl +#if 0 static vk::DynamicLoader dl; PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = dl.getProcAddress("vkGetInstanceProcAddr"); #else @@ -44,10 +46,6 @@ static bool can_use_layer(std::string_view layer_want) { return false; } -static bool can_use_validation(void) { - return can_use_layer("VK_LAYER_KHRONOS_validation"); -} - VKAPI_ATTR VkBool32 VKAPI_CALL debug_callback( VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, @@ -162,12 +160,12 @@ VulkanRenderer::VulkanRenderer(void) { VulkanRenderer::~VulkanRenderer(void) { } -bool VulkanRenderer::enable(Engine& engine, std::vector& task_array) { +bool VulkanRenderer::enable(Engine&, std::vector& task_array) { assert(!VULKAN_HPP_DEFAULT_DISPATCHER.vkEnumerateInstanceLayerProperties); setup_dispacher(); assert(VULKAN_HPP_DEFAULT_DISPATCHER.vkEnumerateInstanceLayerProperties); - // create vulkan instance + // TODO: user configurable const vk::ApplicationInfo app_info { "app_name", VK_MAKE_VERSION(1, 0, 0), // app version @@ -179,7 +177,8 @@ bool VulkanRenderer::enable(Engine& engine, std::vector layers{}; - if (can_use_validation()) { + + if (can_use_layer("VK_LAYER_KHRONOS_validation")) { layers.push_back("VK_LAYER_KHRONOS_validation"); SPDLOG_INFO("ENABLED validation layer"); } else { @@ -193,8 +192,11 @@ bool VulkanRenderer::enable(Engine& engine, std::vector _swapchain_image_views{}; std::vector _swapchain_framebuffers{}; - VkSemaphore _swapchain_sem_image_available{}; - VkSemaphore _swapchain_sem_render_finished{}; - VkFence _swapchain_fence_in_flight{}; + std::vector _swapchain_sem_image_available{}; + std::vector _swapchain_sem_render_finished{}; + std::vector _swapchain_fence_in_flight{}; public: VulkanRenderer(void);