c++ - Vulkan 创建实例 VK_OUT_OF_HOST_MEMORY

标签 c++ winapi visual-studio-2015 vulkan

我正在尝试创建一个 VkInstance 来开始使用 Vulkan,但我已经遇到了一个未记录的错误。这是我到目前为止的所有代码:

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);

这之后的结果是VK_OUT_OF_HOST_MEMORY。关于这个的所有文档都说 vkCreateInstance 可能会返回这个。 super 有帮助-_-。我在这里缺少什么?

最佳答案

确保您的安装正确。对于开发,您应该有一个支持 Vulkan 的图形驱动程序和来自 LunarG 的 Vulkan SDK。

首先验证您的安装并运行演示程序:vulkaninfocube。如果两者都不起作用,则可能是您的卡/驱动程序无法使用 Vulkan。

最后,您的应用程序应该链接到 vulkan-1 库。 vkCreateInstance 由来自 SDK(Vulkan 运行时)的加载程序提供服务,因此除了没有可用的兼容驱动程序外,通常没有理由导致它失败。

关于c++ - Vulkan 创建实例 VK_OUT_OF_HOST_MEMORY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40856564/

相关文章:

c# - 抑制文件中的抑制错误给出错误 : The Selected Message Could not be suppressed

c# - 在 Visual Studio 中复制行的快捷方式?

Preon 的 Java 或 C++ 等价物?

c++ - 终端不断缓冲按下的键

c - 以编程方式在 Windows 中启用大页面

linux - Chefspec 在 Linux 上删除 Win32::Service

c++ - WINAPI 枚举WindowsProc : Non-Standard Syntax; use & to create a point to a member

c# - 如何将一些 using 语句设置为不冗余,即使它们是冗余的?

java - C/C++/Java设计问题: Keeping Track of Many Variables by Saving To File and Parsing Afterwards

c++ - 为什么我们需要访问者模式中的accept()以及为什么我们不能直接调用visitor.visit()?