简体   繁体   中英

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. The documentation says that if the pSurfaceFormats argument is NULL, it will tell how many surface formats are actually available in the pSurfaceFormatCount pointer.

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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