add missing initialization of dynamic dispatcher

This commit is contained in:
tomilov 2020-01-30 14:46:20 +05:00
parent 7efe3d096b
commit bbbbf6b751
2 changed files with 9 additions and 2 deletions

View File

@ -32,7 +32,7 @@ add_executable(NoExceptions
)
if (UNIX)
target_link_libraries(NoExceptions "-ldl")
target_link_libraries(NoExceptions ${CMAKE_DL_LIBS})
endif()
set_target_properties(NoExceptions PROPERTIES FOLDER "Tests")

View File

@ -22,15 +22,21 @@
#include "vulkan/vulkan.hpp"
#include <iostream>
static char const* AppName = "DeviceFunctions";
static char const* AppName = "NoExceptions";
static char const* EngineName = "Vulkan.hpp";
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE;
int main(int /*argc*/, char ** /*argv*/)
{
vk::DynamicLoader dl;
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
vk::ApplicationInfo appInfo(AppName, 1, EngineName, 1, VK_API_VERSION_1_1);
vk::UniqueInstance instance = vk::createInstanceUnique(vk::InstanceCreateInfo({}, &appInfo)).value;
VULKAN_HPP_DEFAULT_DISPATCHER.init(*instance);
std::vector<vk::PhysicalDevice> physicalDevices = instance->enumeratePhysicalDevices().value;
assert(!physicalDevices.empty());
@ -48,6 +54,7 @@ int main(int /*argc*/, char ** /*argv*/)
float queuePriority = 0.0f;
vk::DeviceQueueCreateInfo deviceQueueCreateInfo(vk::DeviceQueueCreateFlags(), static_cast<uint32_t>(graphicsQueueFamilyIndex), 1, &queuePriority);
vk::UniqueDevice device = physicalDevices[0].createDeviceUnique(vk::DeviceCreateInfo(vk::DeviceCreateFlags(), 1, &deviceQueueCreateInfo)).value;
VULKAN_HPP_DEFAULT_DISPATCHER.init(*device);
// create a UniqueCommandPool to allocate a CommandBuffer from
vk::UniqueCommandPool commandPool = device->createCommandPoolUnique(vk::CommandPoolCreateInfo(vk::CommandPoolCreateFlags(), deviceQueueCreateInfo.queueFamilyIndex)).value;