I'm a complete beginner with Vulkan. I've encountered a problem:
I correctly configured my CMake according to a tutorial (https://docs.vulkan.org/tutorial/latest/02_Development_environment.html) and completed a Vulkan test program with validation layers enabled, using the exact code from the tutorial (https://docs.vulkan.org/tutorial/latest/_attachments/02_validation_layers.cpp). However, the program quickly freezes and crashes after it starts running.
When I disable the validation layers, the program works normally.
Visual Studio shows that the problem is in this code:
//vulkan_raii.hpp
Result result = static_cast<Result>( getDispatcher()->vkCreateInstance( reinterpret_cast<const VkInstanceCreateInfo *>( &createInfo ),
reinterpret_cast<const VkAllocationCallbacks *>( allocator.get() ),
reinterpret_cast<VkInstance *>( &instance ) ) );
The error is:
Exception thrown at 0x00007FFD2B113741 (VkLayer_khronos_validation.dll) in untitled6.exe: 0xC0000005: Access violation writing location 0x0000000004D826F8.
I'm sure the problem is on line 121 of main.cpp.
I rewrote the program using vkCreateInstance, and the problem persists in the "create vk instance part." Disabling the Validation Layer makes it work too.
I've been stuck on this problem for two days. Does anyone know why this is happening? Thanks.