Vulkan实例创建失败



我有一个vulkan程序在我的笔记本电脑上运行,但在我的桌面上失败了。错误为:

HeatMethod: ../libraries/vulkansdk-linux/1.2.154.0/source/Vulkan-Headers/include/vulkan/vulkan.hpp:13143: typename vk::ResultValueType<vk::UniqueHandle<Type, Dispatch> >::type vk::createResultValue(vk::Result, T&, const char*, const typename vk::UniqueHandleTraits<Type, Dispatch>::deleter&) [with T = vk::Instance; D = vk::DispatchLoaderStatic; typename vk::ResultValueType<vk::UniqueHandle<Type, Dispatch> >::type = vk::ResultValue<vk::UniqueHandle<vk::Instance, vk::DispatchLoaderStatic> >; typename vk::UniqueHandleTraits<Type, Dispatch>::deleter = vk::ObjectDestroy<vk::NoParent, vk::DispatchLoaderStatic>]: Assertion `result == Result::eSuccess' failed.

我使用注释来跟踪问题,发现它发生在实例创建时:

// Global scope
const std::vector<const char*> VALIDATION_LAYERS = {
"VK_LAYER_KHRONOS_validation",
};
// Setup general information about the current application
vk::ApplicationInfo program_info(
"Vulkan Engine",
VK_MAKE_VERSION(1, 0, 0),
"No Engine",
VK_MAKE_VERSION(1, 0, 0),
VK_API_VERSION_1_2);
if(!CheckAvailableLayers())
RecordLogError("Validation layers requested, but not available!");
vector<const char*> required_extensions;
if(!RequestExtensions(required_extensions))
RecordLogError("Missing a required extension");
// Create Vulkan instance to communicate with the loader
vk::InstanceCreateInfo createInfo(
{},
&program_info,
static_cast<uint32_t>(VALIDATION_LAYERS.size()),
VALIDATION_LAYERS.data(),
static_cast<uint32_t>(required_extensions.size()),
required_extensions.data());
auto [result, instance] = vk::createInstanceUnique(createInfo);

这个错误本身就是hpp头中的一个失败的asseriton,所以它有点神秘。我不确定问题出在哪里。

问题是试图在构建脚本上设置验证层:

os.environ['VK_INSTANCE_LAYERS'] = 'VK_LAYER_LUNARG_standard_validation'

删除该行解决了问题。

相关内容

  • 没有找到相关文章

最新更新