Vulkan 实例创建失败
Vulkan instance creation fails
我有一个 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 header 中的失败断言,所以它有点神秘。我不确定是什么问题。
问题是试图在构建脚本上设置验证层:
os.environ['VK_INSTANCE_LAYERS'] = 'VK_LAYER_LUNARG_standard_validation'
删除该行解决了问题。
我有一个 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 header 中的失败断言,所以它有点神秘。我不确定是什么问题。
问题是试图在构建脚本上设置验证层:
os.environ['VK_INSTANCE_LAYERS'] = 'VK_LAYER_LUNARG_standard_validation'
删除该行解决了问题。