简体   繁体   English

Vulkan:vkGetPhysicalDeviceSurfaceFormatsKHR没有可用的格式吗?

[英]Vulkan: vkGetPhysicalDeviceSurfaceFormatsKHR No Formats available?

I'm In the process of doing ogldev's vulkan tutorials and I've run into this problem with specifically the vkGetPhysicalDeviceSurfaceFormatsKHR function. 我正在做ogldev的vulkan教程,并且特别是使用vkGetPhysicalDeviceSurfaceFormatsKHR函数遇到了此问题。 The documentation says that if the pSurfaceFormats argument is NULL, it will tell how many surface formats are actually available in the pSurfaceFormatCount pointer. 该文档说,如果pSurfaceFormats参数为NULL,它将告诉pSurfaceFormatCount指针实际有多少种表面格式可用。

Here's where my problem comes in.. It doesn't touch the integer pointer at all. 这就是我的问题所在。.它根本不涉及整数指针。

    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);

(the assert(NumFormats > 0) fails) I am running Linux with nvidia drivers, and I am pretty sure that the vulkan API can see my gpu properly, since my output is this: assert(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)

Problem solved. 问题解决了。 I looked at this answer and figured out that I had forgot to initialize my xcb window before I tried to check what surface formats and capabilities were available. 我看着这个答案 ,发现在尝试检查可用的表面格式和功能之前,我忘记了初始化xcb窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM