#include "deimos/vulkan/vulkan.h" #include #include #include #include static deimos::OsApi* os_api; static deimos::LogApi* log_api; namespace deimos { class VulkanLoaderImpl : public VulkanLoaderApi { Allocator* m_allocator; gsl::owner m_vulkan_dll{}; public: explicit VulkanLoaderImpl(Allocator* allocator) : m_allocator{allocator} {} VulkanApi* LoadEntry() override { if (m_vulkan_dll == nullptr) { m_vulkan_dll = os_api->dll->Open("vulkan-1.dll"); if (m_vulkan_dll != nullptr) { log_api->LogInfo("Vulkan DLL loaded"); } else { deimos_Panic("Couldn't load Vulkan DLL"); return nullptr; } } VulkanApi* api = m_allocator->New(); #define FN(NAME) api->NAME = (PFN_vk##NAME)os_api->dll->GetSymbol(m_vulkan_dll, "vk" #NAME); #include "deimos/vulkan/vulkan_entry_functions.inc" #undef FN return api; } }; void RegisterVulkanLoaderApi(ApiRegistry* registry) { os_api = registry->Get(); log_api = registry->Get(); auto* allocator_api = registry->Get(); auto* allocator = allocator_api->CreateChild(allocator_api->system, "Vulkan"); auto* impl = allocator->New(allocator); registry->Set(impl); log_api->LogInfo("Vulkan loader API registered"); } } // namespace deimos