我用vulkan食谱学习vulkan,现在我发现自己陷入了僵局:
如果我尝试在我发送给VK_KHR_SURFACE_EXTENSION_NAME
的{{1}}结构中的扩展名列表中传递扩展名,VK_KHR_WIN32_SURFACE_EXTENSION_NAME
和VkDeviceCreateInfo
,则该函数会失败而任何错误(它都不会返回vkCreateDevice
)
我已经查过了,而且我知道我的显卡支持我试图通过的所有扩展程序。我尝试从验证层读取输出,但它们似乎没有找到失败的原因(我启用了VK_SUCCESS
和标准验证层)。
我创建逻辑设备的功能如下所示 -
VK_LAYER_LUNARG_api_dump
bool create_logical_device(VkPhysicalDevice &physDev, VkDevice &device,
std::vector<char const *> &desExts,
std::vector<queueInfo> &qInfos,
VkPhysicalDeviceFeatures &physDevFtrs)
{
std::vector<VkDeviceQueueCreateInfo> qCreateInfo;
std::vector<VkExtensionProperties> physDevExtProps;
if (!get_avl_phys_dev_exts(physDev, physDevExtProps))
return false;
for (auto &ext : desExts)
{
if (!is_ext_available(physDevExtProps, ext))
return false;
}
for (auto &i : qInfos)
{
qCreateInfo.push_back(
{VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
nullptr,
0,
i.FamilyIndex,
(uint32_t)i.Priorities.size(),
i.Priorities.size() > 0 ? i.Priorities.data() : nullptr
});
}
VkDeviceCreateInfo devCreateInfo =
{
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
nullptr,
0,
(uint32_t)qCreateInfo.size(),
qCreateInfo.size() > 0 ? qCreateInfo.data() : nullptr,
0,
nullptr,
(uint32_t)desExts.size(),
desExts.size() > 0 ? desExts.data() : nullptr,
&physDevFtrs
};
#ifdef ENABLE_VALIDATION
devCreateInfo.enabledLayerCount = (uint32_t)valLayers.size();
devCreateInfo.ppEnabledLayerNames = valLayers.data();
#endif
if (vkCreateDevice(physDev, &devCreateInfo, nullptr, &device) != VK_SUCCESS)
{
std::cout << "Could not create logical device!" << std::endl;
return false;
}
std::cout << "Succesfully created logical device" << std::endl;
return true;
}
是全局范围内的常量向量。
这种失败发生在Windows和Linux上,所以它只能是我身边的东西。通过调试器运行代码并没有向我揭示任何内容。我能做错什么?
答案 0 :(得分:0)
Are You sure You are providing valid extension names? VK_KHR_SURFACE_EXTENSION_NAME is an instance extension, so it shouldn't be provided during device creation.
And thanks for using/reading/learning from the Vulkan Cookbook ;-).