Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7331e228 authored by Jesse Hall's avatar Jesse Hall
Browse files

libvulkan: Fix count returned for incomplete wsi queries

When vkGetPhysicalDeviceSurfaceFormatsKHR,
vkGetPhysicalDevicePresentModesKHR, and vkGetSwapchainImagesKHR
returned VK_INCOMPLETE, they would overwrite the count parameter with
the number of available items, rather than the number of returned
items.

Change-Id: I6a736770f90b95ad15bfcfbe5afb4d2886817dcb
Fixes: 31490492
Test: https://gerrit.khronos.org/#/c/158/
parent 8b2d3da4
Loading
Loading
Loading
Loading
+11 −5
Original line number Original line Diff line number Diff line
@@ -361,9 +361,11 @@ VkResult GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice /*pdev*/,
    if (formats) {
    if (formats) {
        if (*count < kNumFormats)
        if (*count < kNumFormats)
            result = VK_INCOMPLETE;
            result = VK_INCOMPLETE;
        std::copy(kFormats, kFormats + std::min(*count, kNumFormats), formats);
        *count = std::min(*count, kNumFormats);
    }
        std::copy(kFormats, kFormats + *count, formats);
    } else {
        *count = kNumFormats;
        *count = kNumFormats;
    }
    return result;
    return result;
}
}


@@ -381,9 +383,11 @@ VkResult GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice /*pdev*/,
    if (modes) {
    if (modes) {
        if (*count < kNumModes)
        if (*count < kNumModes)
            result = VK_INCOMPLETE;
            result = VK_INCOMPLETE;
        std::copy(kModes, kModes + std::min(*count, kNumModes), modes);
        *count = std::min(*count, kNumModes);
    }
        std::copy(kModes, kModes + *count, modes);
    } else {
        *count = kNumModes;
        *count = kNumModes;
    }
    return result;
    return result;
}
}


@@ -751,8 +755,10 @@ VkResult GetSwapchainImagesKHR(VkDevice,
        }
        }
        for (uint32_t i = 0; i < n; i++)
        for (uint32_t i = 0; i < n; i++)
            images[i] = swapchain.images[i].image;
            images[i] = swapchain.images[i].image;
    }
        *count = n;
    } else {
        *count = swapchain.num_images;
        *count = swapchain.num_images;
    }
    return result;
    return result;
}
}