简体   繁体   中英

Vulkan vkCreateWin32SurfaceKHR fails to load

Hey I'm trying to create a Windows Surface with Vulkan but the somehow vkGetInstanceProcAddr fails to load the vkCreateWin32SurfaceKHR function even though the extension is loaded properly.

Edit: here I try to get the function pointer: vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAddr(vulkanInstance.instance, "vkCreateWin32SurfaceKHR");

Did you enable the appropriate extension using eg the const VK_KHR_WIN32_SURFACE_EXTENSION_NAME at instance creation time?

Also note that you don't need to manually get the function pointer for vkCreateWin32SurfaceKHR unless you define VK_NO_PROTOTYPES as it's part of the core.

If you have enabled the extension and still don't get a valid function pointer, check if your drivers are properly installed, esp. that there is no old ICD registered that may cause problems. The LunarG Vulkan SDK contains a tool called "via" (in the bin folder) to check your Vulkan installation.

In case you're okay using the C++ API instead of the C one, an easier way to do this is via the vulkan.hpp file that ships in the SDK.

You can #define VK_USE_PLATFORM_WIN32_KHR and vk::Instance will have a vk::Result createWin32SurfaceKHR(vk::Win32SurfaceCreateInfoKHR*, vk::AllocationCallbacks*, vk::SurfaceKHR*) member function. This helps alleviate the need for grabbing function pointers yourself.

Did you #include the vulkan_win32.h header in your source file?

PFN_vkCreateWin32SurfaceKHR comes from an extension and so it is not defined in the core vulkan headers.

在此...如果您在调用vkCreateWin32SurfaceKHR时收到错误,请确保在VkWin32SurfaceCreateInfoKHR结构中定义了sType ...即使它是VkWin32SurfaceCreateInfoKHR结构,忘记stype也足以使其失败。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM