#include "vulkan_loader.h" #include "../util/util_win32_compat.h" namespace dxvk::vk { LibraryLoader::LibraryLoader() : m_library(LoadLibraryA("vulkan-1")) , m_getInstanceProcAddr(reinterpret_cast( GetProcAddress(m_library, "vkGetInstanceProcAddr"))) { } LibraryLoader::~LibraryLoader() { FreeLibrary(m_library); } PFN_vkVoidFunction LibraryLoader::sym(VkInstance instance, const char* name) const { return m_getInstanceProcAddr(instance, name); } PFN_vkVoidFunction LibraryLoader::sym(const char* name) const { return sym(nullptr, name); } InstanceLoader::InstanceLoader(const Rc& library, bool owned, VkInstance instance) : m_library(library), m_instance(instance), m_owned(owned) { } PFN_vkVoidFunction InstanceLoader::sym(const char* name) const { return m_library->sym(m_instance, name); } DeviceLoader::DeviceLoader(const Rc& library, bool owned, VkDevice device) : m_library(library) , m_getDeviceProcAddr(reinterpret_cast( m_library->sym("vkGetDeviceProcAddr"))), m_device(device), m_owned(owned) { } PFN_vkVoidFunction DeviceLoader::sym(const char* name) const { return m_getDeviceProcAddr(m_device, name); } LibraryFn::LibraryFn() { } LibraryFn::~LibraryFn() { } InstanceFn::InstanceFn(const Rc& library, bool owned, VkInstance instance) : InstanceLoader(library, owned, instance) { } InstanceFn::~InstanceFn() { if (m_owned) this->vkDestroyInstance(m_instance, nullptr); } DeviceFn::DeviceFn(const Rc& library, bool owned, VkDevice device) : DeviceLoader(library, owned, device) { } DeviceFn::~DeviceFn() { if (m_owned) this->vkDestroyDevice(m_device, nullptr); } }