上下文
尝试使用Vulkan做一个最小的例子,我在终止时遇到分段错误。我发现的所有例子都非常相似,但我仍然遇到了崩溃。
尝试
#include <iostream>
#include <vulkan/vulkan.h>
int main()
{
using std::cout;
using std::endl;
// Application info
VkApplicationInfo appInfo = {};
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO ;
appInfo.apiVersion = VK_API_VERSION_1_0;
appInfo.applicationVersion = VK_MAKE_VERSION( 0 , 0 , 1 ) ;
appInfo.pApplicationName = "test_vulkan" ;
appInfo.pNext = nullptr;
appInfo.pEngineName = "test_vulkan";
// Instance info
VkInstanceCreateInfo instanceInfo = {};
instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceInfo.flags = 0;
instanceInfo.pApplicationInfo= &appInfo;
instanceInfo.pNext = nullptr;
instanceInfo.ppEnabledExtensionNames = nullptr;
instanceInfo.ppEnabledLayerNames = nullptr;
instanceInfo.enabledLayerCount =0;
instanceInfo.enabledExtensionCount = 0;
// Create instance
VkInstance instance = nullptr;
VkResult res = vkCreateInstance( &instanceInfo, nullptr, &instance); // null is the allocator for host
if (VK_SUCCESS==res) cout << "Instance created with success" << endl;
else cout << "Failed to create instance" << endl;
if (instance)
{
vkDestroyInstance( instance , nullptr ) ;
cout << "Instance destroyed" << endl;
}
instance = nullptr;
return 0;
}
问题
导致此分段错误的原因是什么?
电脑规格:
相关