我正在执行ogldev's vulkan tutorials并且我特意使用vkGetPhysicalDeviceSurfaceFormatsKHR函数遇到了这个问题。文档说如果pSurfaceFormats参数为NULL,它将告诉pSurfaceFormatCount指针实际有多少表面格式。
这是我的问题所在。它根本不触及整数指针。
uint NumFormats = 0;
res = vkGetPhysicalDeviceSurfaceFormatsKHR(PhysDev, Surface, &NumFormats, NULL);
if(res != VK_SUCCESS) {
LIFE_ERROR("vkGetPhysicalDeviceSurfaceFormatsKHR error: %d\n", res);
assert(0);
}
assert(NumFormats > 0);
(断言(NumFormats> 0)失败)我使用nvidia驱动程序运行Linux,我很确定vulkan API可以正常查看我的gpu,因为我的输出是这样的:
Found 6 extensions
Instance extension 0 - VK_KHR_surface
Instance extension 1 - VK_KHR_xcb_surface
Instance extension 2 - VK_KHR_xlib_surface
Instance extension 3 - VK_KHR_wayland_surface
Instance extension 4 - VK_EXT_debug_report
Instance extension 5 - VK_NV_external_memory_capabilities
Surface created
Num physical devices 1
Device name: GTX 980 Ti
API version: 1.0.24
Num of family queues: 2
....(assert failes)