Skip to content

Variable name mismatch in a code snippet on the "Drawing a Triangle/Setup/Validation layers" page #413

Description

@patrik7557

In the third paragraph, titled "Using extensions", the second code snippet uses wrong variable names. As the logic is the same as for the layer support check, it appears to be copied and pasted from there, but the variable names mismatch (layer <-> extension).

Wrong code snippet in documentation on the page:

// Get the required extensions.
auto requiredExtensions = getRequiredInstanceExtensions();

// Check if the required extensions are supported by the Vulkan implementation.
auto extensionProperties = context.enumerateInstanceExtensionProperties();
auto unsupportedLayerIt = std::ranges::find_if(requiredLayers,
                                               [&layerProperties](auto const &requiredLayer) {
                                                   return std::ranges::none_of(layerProperties,
                                                                              [requiredLayer](auto const &layerProperty) { return strcmp(layerProperty.layerName, requiredLayer) == 0; });
                         });
if (unsupportedPropertyIt != requiredExtensions.end())
{
    throw std::runtime_error("Required extension not supported: " + std::string(*unsupportedPropertyIt));
}

Correct code snippet in the codebase:

// Get the required extensions.
auto requiredExtensions = getRequiredInstanceExtensions();

// Check if the required extensions are supported by the Vulkan implementation.
auto extensionProperties = context.enumerateInstanceExtensionProperties();
auto unsupportedPropertyIt =
    std::ranges::find_if(requiredExtensions,
                         [&extensionProperties](auto const &requiredExtension) {
	                         return std::ranges::none_of(extensionProperties,
	                                                     [requiredExtension](auto const &extensionProperty) { return strcmp(extensionProperty.extensionName, requiredExtension) == 0; });
                         });
if (unsupportedPropertyIt != requiredExtensions.end())
{
	throw std::runtime_error("Required extension not supported: " + std::string(*unsupportedPropertyIt));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions