Skip to content

Should isDeviceSuitable() also check presentation support in the Window Surface chapter? #457

Description

@freeDiving

In 05_window_surface.cpp, isDeviceSuitable() checks whether the physical device has a queue family that supports graphics:

bool supportsGraphics =
    std::ranges::any_of(
        queueFamilies,
        [](auto const& qfp) {
            return !!(qfp.queueFlags &
                      vk::QueueFlagBits::eGraphics);
        });

However, createLogicalDevice() later requires a queue family that supports both graphics and presentation to the selected surface:

if ((queueFamilyProperties[qfpIndex].queueFlags &
     vk::QueueFlagBits::eGraphics) &&
    physicalDevice.getSurfaceSupportKHR(
        qfpIndex, *surface))
{
    queueIndex = qfpIndex;
    break;
}

It seems possible for a physical device to pass isDeviceSuitable() because it has a graphics-capable queue family, but then fail in createLogicalDevice() because no queue family supports both graphics and presentation to the surface.

Would it make sense for isDeviceSuitable() to also check presentation support, so that its suitability criteria match the requirements later used by createLogicalDevice()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions