1
votes

I am trying to run this Nvidia example: https://github.com/nvpro-samples/gl_render_vk_direct_display The problem is that on call:

std::vector<vk::PhysicalDevice> devices = m_instance->enumeratePhysicalDevices();

The application crashes with error

Access violation executing location 0x00007FF953BA88E0

If I check process variables in VS debugger under this location is stored vkEnumeratePhysicalDevices method adresss. The strange thing is if I call Vulkan C API's vkEnumeratePhysicalDevices method directly instead of C++ api call m_instance->enumeratePhysicalDevices() I do not get any access violation message. I little bit suspect that problem could be in the new Vulkan Dynamic loader, but I am just guessing. The loader is executed this way when vk::Instance is created:

  vk::DynamicLoader         dl;
  PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr =
      dl.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
  VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);

  // check for required instance extensions
  std::vector<vk::ExtensionProperties> availableInstanceExtensions = vk::enumerateInstanceExtensionProperties();
  for(const auto& required : requiredInstanceExtensions)
  {
    bool found = false;
    for(const auto& available : availableInstanceExtensions)
    {
      if(std::string(required) == available.extensionName)
      {
        found = true;
        break;
      }
    }
    if(!found)
    {
      throw std::exception(("Required instance extension not found: " + std::string(required)).c_str());
    }
  }
  vk::InstanceCreateInfo createInfo{
      vk::InstanceCreateFlags(),        nullptr, 0, nullptr, uint32_t(requiredInstanceExtensions.size()),
      requiredInstanceExtensions.data()};
  m_instance = vk::createInstanceUnique(createInfo);

  VULKAN_HPP_DEFAULT_DISPATCHER.init(m_instance.get());

Am I doing something wrong upon loading with dynamic dispatcher?

VULKAN_HPP_DEFAULT_DISPATCHER.init(device);

Do I need to do same init with device? Like I saw here https://github.com/KhronosGroup/Vulkan-Hpp/blob/master/tests/DispatchLoaderDynamic/DispatchLoaderDynamic.cpp. It is completely obscure for me because for example in "Vulkan minimal example" the guy is loading via dispatcher just instance proc adresses (https://github.com/dokipen3d/vulkanHppMinimalExample/blob/master/main.cpp).

1

1 Answers

0
votes

I do not know why, but suddenly the C++ api calls started to work. I did not changed anything regarding VulkanSDK. The only thing I did was reinstalling the GPU drivers, but I am sure that same driver was installed even before. So reinstaling the driver solved the problem, but still it is little bit a mystery for me.