即使实例在 Vulkan 中创建失败,我是否应该销毁它?
Should I destroy an instance even if its creation fails in Vulkan?
即使实例在 Vulkan 中创建失败,我是否应该销毁它?
正确的是:
1:
VkResult Result = vkCreateInstance( info, NULL, instance );
if(Result != VK_SUCCESS)
{
vkDestroyInstance(Instance, NULL);
glfwTerminate();
exit(EXIT_FAILURE);
}
2:
VkResult Result = vkCreateInstance( info, NULL, instance );
if(Result != VK_SUCCESS)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
来自规范:
If a command returns a run time error, it will leave any result pointers unmodified, unless other behavior is explicitly defined in the specification.
并且由于 VkCreateInstance
需要一个 VkInstance*
,它将保持不变。
即使实例在 Vulkan 中创建失败,我是否应该销毁它?
正确的是:
1:
VkResult Result = vkCreateInstance( info, NULL, instance );
if(Result != VK_SUCCESS)
{
vkDestroyInstance(Instance, NULL);
glfwTerminate();
exit(EXIT_FAILURE);
}
2:
VkResult Result = vkCreateInstance( info, NULL, instance );
if(Result != VK_SUCCESS)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
来自规范:
If a command returns a run time error, it will leave any result pointers unmodified, unless other behavior is explicitly defined in the specification.
并且由于 VkCreateInstance
需要一个 VkInstance*
,它将保持不变。