1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00
OpenDX/src/vulkan/vulkan_loader.cpp

61 lines
1.6 KiB
C++
Raw Normal View History

#include "vulkan_loader.h"
2017-10-10 23:32:13 +02:00
namespace dxvk::vk {
#if defined(__WINE__)
extern "C"
PFN_vkVoidFunction native_vkGetInstanceProcAddrWINE(VkInstance instance, const char *name);
static const PFN_vkGetInstanceProcAddr GetInstanceProcAddr = native_vkGetInstanceProcAddrWINE;
#else
static const PFN_vkGetInstanceProcAddr GetInstanceProcAddr = vkGetInstanceProcAddr;
#endif
2017-10-10 23:32:13 +02:00
PFN_vkVoidFunction LibraryLoader::sym(const char* name) const {
return dxvk::vk::GetInstanceProcAddr(nullptr, name);
2017-10-10 23:32:13 +02:00
}
InstanceLoader::InstanceLoader(bool owned, VkInstance instance)
: m_instance(instance), m_owned(owned) { }
2017-10-10 23:32:13 +02:00
PFN_vkVoidFunction InstanceLoader::sym(const char* name) const {
return dxvk::vk::GetInstanceProcAddr(m_instance, name);
2017-10-10 23:32:13 +02:00
}
DeviceLoader::DeviceLoader(bool owned, VkInstance instance, VkDevice device)
2017-10-10 23:32:13 +02:00
: m_getDeviceProcAddr(reinterpret_cast<PFN_vkGetDeviceProcAddr>(
dxvk::vk::GetInstanceProcAddr(instance, "vkGetDeviceProcAddr"))),
m_device(device), m_owned(owned) { }
2017-10-10 23:32:13 +02:00
PFN_vkVoidFunction DeviceLoader::sym(const char* name) const {
return m_getDeviceProcAddr(m_device, name);
}
LibraryFn::LibraryFn() { }
LibraryFn::~LibraryFn() { }
InstanceFn::InstanceFn(bool owned, VkInstance instance)
: InstanceLoader(owned, instance) { }
InstanceFn::~InstanceFn() {
if (m_owned)
this->vkDestroyInstance(m_instance, nullptr);
}
2017-10-10 23:32:13 +02:00
DeviceFn::DeviceFn(bool owned, VkInstance instance, VkDevice device)
: DeviceLoader(owned, instance, device) { }
DeviceFn::~DeviceFn() {
if (m_owned)
this->vkDestroyDevice(m_device, nullptr);
}
2017-10-10 23:32:13 +02:00
}