Vulkan Access violation executing location

I started using Vulkan from vcpkg, when I try to call vkCreateInstance I get the following error with no clue:
Exception thrown at 0x00007FF8B778A248 (PhotobookRuntimeComponent.dll) in PhotobookNet.exe: 0xC0000005: Access violation executing location 0x00007FF8B778A248.

I thought that I could use the validation layers, however when I call vkEnumerateInstanceLayerProperties I get the same error.

Any idea how to handle this?
I use Vulkan 1.3.296.0 from vcpkg 2024.04.26
The library is used inside a WInUI3 project that calls C++ code. I don’t intend to draw into a window so I don’t use glfw etc.
Here is how I use it cpp-photobook/PB/src/OGLEngine.cpp at 29433e8285e5d3e26c2eca86ad46be2401570335 · cosmin42/cpp-photobook · GitHub

I tried enabling all VS exception types, I checked for missing dlls using gflags, I tried different memory alignments and nothing. Any idea what it could be? I just can’t figure it out. Thank you!

1 Like

You have to manually tie vulkan-sdk-components from vcpkg manifest mode using dynamic dispatch

#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
This must appear before:
#include <vulkan/vulkan.hpp>

Inside your createInstance() function
// Initialize the dispatcher for global functions before calling any Vulkan function
VULKAN_HPP_DEFAULT_DISPATCHER.init();

// example createInstance() in here somewhere

Reinitialize the dispatcher with instance-level function pointers immediately after
VULKAN_HPP_DEFAULT_DISPATCHER.init(instance.get());

// because you’re not using installed SDK, setup the environment paths globally for windows
VK_LAYER_PATH “C:\Users\yourname\source\repos\yourproject\vcpkg_installed\x64-windows\x64-windows\debug\bin”

//over here you can read more about the validation layers //can’t post links here (silly it’s vulkan link)
//lunarg
/doc/view/latest/windows/layer_configuration

This is as far as I have gotten with it so far, hope this helps someone!
I can make it work without any of the debug and layer code however in release

update: ok, got it partially working I use
vk::ResultValuevk::UniqueInstance result = vk::createInstanceUnique(createInfo, nullptr, VULKAN_HPP_DEFAULT_DISPATCHER);

and then VULKAN_HPP_DEFAULT_DISPATCHER.init(instance.get());
again inside my device code.

Update again… I have switched to SDK install it appears the debug is seperate and the hardware needs a special external tool to help, I would recommend choosing this path for debug operations.