Search code examples
c++vulkan

question about VkPhysicalDeviceVulkan12Features


I ran into an issue when adding features to a physical device using bootstrap https://github.com/charles-lunarg/vk-bootstrap. Doing so gives me assertion failed Assertion failed: m_init, file \vkbootstrap\VkBootstrap.h, line 132

I understand that this could indicate a bug within the vk-bootstrap source, but I wanted to rule out that it's my own fault. Here is the code snippet which im using to add (empty)VkPhysicalDeviceVulkan12Features into physical device and I wanted to know if I'm intializing it correctly

    VkPhysicalDeviceVulkan12Features feat;
    feat.pNext = nullptr;
    feat.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;

    vkb::PhysicalDeviceSelector selector{ vkb_inst };
    vkb::PhysicalDevice physicalDevice = selector
        .set_minimum_version(1, 2)
        .set_surface(_surface)
        .set_required_features_12(feat)
        .select()
        .value();

Solution

  • You are not checking Results for errors.

    Probably should be something like:

    vkb::PhysicalDeviceSelector selector{ vkb_inst };
    auto maybe_device = selector.select();
    if( !maybe_device ) panic( maybe_device.error() );
    
    vkb::PhysicalDevice device = maybe_device.value();