Vulkan create instance VK_OUT_OF_HOST_MEMORY

2019-09-16 02:37发布

I'm trying to create a VkInstance to get started with Vulkan and I've already run into an undocumented error. This is all the code that I have so far:

VkApplicationInfo applicationInfo = {};
applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
applicationInfo.pNext = NULL;
applicationInfo.pApplicationName = "<game>";
applicationInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
applicationInfo.pEngineName = "<engine>";
applicationInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
applicationInfo.apiVersion = VK_API_VERSION_1_0;

// setup the instance info
VkInstanceCreateInfo instanceInfo = {};
instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceInfo.pNext = NULL;
instanceInfo.flags = 0;
instanceInfo.pApplicationInfo = &applicationInfo;
instanceInfo.enabledLayerCount = 0;
instanceInfo.ppEnabledExtensionNames = NULL;
instanceInfo.enabledExtensionCount = 0;
instanceInfo.ppEnabledLayerNames = NULL;

// create the vk instance which is used to do stuff in vulkan
VkInstance instance;
VkResult result = vkCreateInstance(&instanceInfo, NULL, &instance);

the result after this is VK_OUT_OF_HOST_MEMORY. All the documentation says about this is that vkCreateInstance might return this. Super helpful -_-. What am I missing here?

2条回答
看我几分像从前
2楼-- · 2019-09-16 02:48

Make sure that your installation is correct. For development you should have a graphics driver supporting Vulkan and the Vulkan SDK from LunarG.

Start by verifying your installation and run demo programs: vulkaninfo and cube. If either doesn't work, chances are your card/driver isn't capable of using Vulkan.

Finally, your app should be linked against vulkan-1 library. vkCreateInstance is serviced by the loader from the SDK (Vulkan runtime), so normally there should be no reason for it to fail, other than no compatible drivers available.

查看更多
走好不送
3楼-- · 2019-09-16 02:52

This turned out to be a bug in the Vulkan SDK, which was reproduced and patched in issue #629 https://vulkan.lunarg.com/issue/view/584553649ab0fa4b673614cb.

查看更多
登录 后发表回答