Repository: libsdl-org/SDL
File: src/gpu/vulkan/SDL_gpu_vulkan.c (C)

Code before:
        const char *,
        deviceCreateInfo.enabledExtensionCount);
    CreateDeviceExtensionArray(&renderer->supports, deviceExtensions);
    deviceCreateInfo.ppEnabledExtensionNames = deviceExtensions;

    VkPhysicalDeviceFeatures2 featureList;
    int minor = VK_VERSION_MINOR(features->desiredApiVersion);

    VkPhysicalDevice16BitStorageFeatures storage;
    VkPhysicalDeviceMultiviewFeatures multiview;
    VkPhysicalDeviceProtectedMemoryFeatures protectedMem;
    VkPhysicalDeviceSamplerYcbcrConversionFeatures ycbcr;
    VkPhysicalDeviceShaderDrawParametersFeatures drawParams;
    VkPhysicalDeviceVariablePointersFeatures varPointers;

    if (features->usesCustomVulkanOptions && minor > 0) {
        featureList.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
        featureList.features = features->desiredVulkan10DeviceFeatures;
        if (minor > 1) {
            featureList.pNext = &features->desiredVulkan11DeviceFeatures;
            features->desiredVulkan11DeviceFeatures.pNext = &features->desiredVulkan12DeviceFeatures;
            features->desiredVulkan12DeviceFeatures.pNext = minor > 2 ? &features->desiredVulkan13DeviceFeatures : NULL;
            features->desiredVulkan13DeviceFeatures.pNext = NULL;
        } else {
            // Break VkPhysicalDeviceVulkan11Features into pre 1.2 structures for Vulkan 1.1 Support
            SDL_memset(&storage, 0, sizeof(VkPhysicalDevice16BitStorageFeatures));
            storage.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES;
            storage.storageBuffer16BitAccess = features->desiredVulkan11DeviceFeatures.storageBuffer16BitAccess;
            storage.storageInputOutput16 = features->desiredVulkan11DeviceFeatures.storageInputOutput16;
            storage.storagePushConstant16 = features->desiredVulkan11DeviceFeatures.storagePushConstant16;
            storage.uniformAndStorageBuffer16BitAccess = features->desiredVulkan11DeviceFeatures.uniformAndStorageBuffer16BitAccess;

            SDL_memset(&multiview, 0, sizeof(VkPhysicalDeviceMultiviewFeatures));
            multiview.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES;
            multiview.multiview = features->desiredVulkan11DeviceFeatures.multiview;
            multiview.multiviewGeometryShader = features->desiredVulkan11DeviceFeatures.multiviewGeometryShader;
            multiview.multiviewTessellationShader = features->desiredVulkan11DeviceFeatures.multiviewTessellationShader;

            SDL_memset(&protectedMem, 0, sizeof(VkPhysicalDeviceProtectedMemoryFeatures));
            protectedMem.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES;
            protectedMem.protectedMemory = features->desiredVulkan11DeviceFeatures.protectedMemory;

            SDL_memset(&ycbcr, 0, sizeof(VkPhysicalDeviceSamplerYcbcrConversionFeatures));
            ycbcr.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
            ycbcr.samplerYcbcrConversion = features->desiredVulkan11DeviceFeatures.samplerYcbcrConversion;

            SDL_memset(&drawParams, 0, sizeof(VkPhysicalDeviceShaderDrawParametersFeatures));
            drawParams.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES;
            drawParams.shaderDrawParameters = features->desiredVulkan11DeviceFeatures.shaderDrawParameters;

            SDL_memset(&varPointers, 0, sizeof(VkPhysicalDeviceVariablePointersFeatures));

Review comment (suggestion):
We have a macro for this:
```c
SDL_zero(storage);
```

Code after:
        const char *,
        deviceCreateInfo.enabledExtensionCount);
    CreateDeviceExtensionArray(&renderer->supports, deviceExtensions);
    deviceCreateInfo.ppEnabledExtensionNames = deviceExtensions;

    VkPhysicalDeviceFeatures2 featureList;
    int minor = VK_VERSION_MINOR(features->desiredApiVersion);

    struct {
        VkPhysicalDevice16BitStorageFeatures storage;
        VkPhysicalDeviceMultiviewFeatures multiview;
        VkPhysicalDeviceProtectedMemoryFeatures protectedMem;
        VkPhysicalDeviceSamplerYcbcrConversionFeatures ycbcr;
        VkPhysicalDeviceShaderDrawParametersFeatures drawParams;
        VkPhysicalDeviceVariablePointersFeatures varPointers;
    } legacyFeatures;

    if (features->usesCustomVulkanOptions && minor > 0) {
        featureList.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
        featureList.features = features->desiredVulkan10DeviceFeatures;
        if (minor > 1) {
            featureList.pNext = &features->desiredVulkan11DeviceFeatures;
            features->desiredVulkan11DeviceFeatures.pNext = &features->desiredVulkan12DeviceFeatures;
            features->desiredVulkan12DeviceFeatures.pNext = minor > 2 ? &features->desiredVulkan13DeviceFeatures : NULL;
            features->desiredVulkan13DeviceFeatures.pNext = NULL;
        } else {
            // Break VkPhysicalDeviceVulkan11Features into pre 1.2 structures for Vulkan 1.1 Support
            SDL_zero(legacyFeatures);

            legacyFeatures.storage.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES;
            legacyFeatures.storage.storageBuffer16BitAccess = features->desiredVulkan11DeviceFeatures.storageBuffer16BitAccess;
            legacyFeatures.storage.storageInputOutput16 = features->desiredVulkan11DeviceFeatures.storageInputOutput16;
            legacyFeatures.storage.storagePushConstant16 = features->desiredVulkan11DeviceFeatures.storagePushConstant16;
            legacyFeatures.storage.uniformAndStorageBuffer16BitAccess = features->desiredVulkan11DeviceFeatures.uniformAndStorageBuffer16BitAccess;

            legacyFeatures.multiview.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES;
            legacyFeatures.multiview.multiview = features->desiredVulkan11DeviceFeatures.multiview;
            legacyFeatures.multiview.multiviewGeometryShader = features->desiredVulkan11DeviceFeatures.multiviewGeometryShader;
            legacyFeatures.multiview.multiviewTessellationShader = features->desiredVulkan11DeviceFeatures.multiviewTessellationShader;

            legacyFeatures.protectedMem.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES;
            legacyFeatures.protectedMem.protectedMemory = features->desiredVulkan11DeviceFeatures.protectedMemory;

            legacyFeatures.ycbcr.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
            legacyFeatures.ycbcr.samplerYcbcrConversion = features->desiredVulkan11DeviceFeatures.samplerYcbcrConversion;

            legacyFeatures.drawParams.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES;
            legacyFeatures.drawParams.shaderDrawParameters = features->desiredVulkan11DeviceFeatures.shaderDrawParameters;

            legacyFeatures.varPointers.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES;
            legacyFeatures.varPointers.variablePointers = features->desiredVulkan11DeviceFeatures.variablePointers;