From c7a7e117b786b775f85d4bffa29deb418102d758 Mon Sep 17 00:00:00 2001 From: Aaron Bartholomew Date: Mon, 20 Aug 2018 12:28:42 -0700 Subject: [PATCH] Improve wsi.incremental_present.* for low memory This patch modifies the VK.wsi.incremental_present.* tests to alleviate issues with memory use on memory constrained platforms The issue is that the scale_down group in particular creates very large swapchains & that the presentation engine may keep one or moreof the swapchain images allocated until it is able to release them. Which means that since this test does the following: create swapchain, render some frames, destroy the swapchain, repeat the high watermark for memory consumed by swapchain images will be higher than the amount consumed by the single largest swapchain created. This patch addresses these issues in two ways: 1) Reducing the size of the swapchain images allocated for scale down tests to use the next power of two of the window size, instead of the max extents reported by Vulkan Max extents are already tested in other deqp tests & it's redundant to do evaluate it again here; this change will make the test more on functionality 2) Creates/Renders/Destroys a small dummy swapchain between each test iteration in order to flush the memory held by the presentation engine Affects: dEQP-VK.wsi.*.incremental_present.* Components: Vulkan VK-GL-CTS issue: 1179 Change-Id: Ib7e1a5d9110e7dabc0d0ced21b643389c2bf0328 (cherry picked from commit a3ba2368fda1ecf8cc3d5c3136b5674a3414f472) --- .../vulkan/wsi/vktWsiIncrementalPresentTests.cpp | 45 ++++++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp b/external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp index 1c5b2c5..f0cca4e 100644 --- a/external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp +++ b/external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp @@ -720,21 +720,25 @@ std::vector generateSwapchainConfigs (vk::VkSurfac const vk::VkBool32 clipped = VK_FALSE; vector createInfos; + const deUint32 currentWidth = properties.currentExtent.width != 0xFFFFFFFFu + ? properties.currentExtent.width + : de::min(1024u, properties.minImageExtent.width + ((properties.maxImageExtent.width - properties.minImageExtent.width) / 2)); + const deUint32 currentHeight = properties.currentExtent.height != 0xFFFFFFFFu + ? properties.currentExtent.height + : de::min(1024u, properties.minImageExtent.height + ((properties.maxImageExtent.height - properties.minImageExtent.height) / 2)); + const deUint32 imageWidth = scaling == SCALING_NONE - ? (properties.currentExtent.width != 0xFFFFFFFFu - ? properties.currentExtent.width - : de::min(1024u, properties.minImageExtent.width + ((properties.maxImageExtent.width - properties.minImageExtent.width) / 2))) + ? currentWidth : (scaling == SCALING_UP ? de::max(31u, properties.minImageExtent.width) - : properties.maxImageExtent.width); + : de::min(deSmallestGreaterOrEquallPowerOfTwoU32(currentWidth+1), properties.maxImageExtent.width)); const deUint32 imageHeight = scaling == SCALING_NONE - ? (properties.currentExtent.height != 0xFFFFFFFFu - ? properties.currentExtent.height - : de::min(1024u, properties.minImageExtent.height + ((properties.maxImageExtent.height - properties.minImageExtent.height) / 2))) + ? currentHeight : (scaling == SCALING_UP ? de::max(31u, properties.minImageExtent.height) - : properties.maxImageExtent.height); + : de::min(deSmallestGreaterOrEquallPowerOfTwoU32(currentHeight+1), properties.maxImageExtent.height)); const vk::VkExtent2D imageSize = { imageWidth, imageHeight }; + const vk::VkExtent2D dummySize = { de::max(31u, properties.minImageExtent.width), de::max(31u, properties.minImageExtent.height) }; { size_t presentModeNdx; @@ -788,6 +792,31 @@ std::vector generateSwapchainConfigs (vk::VkSurfac }; createInfos.push_back(createInfo); + + // add an extra dummy swapchain + const vk::VkSwapchainCreateInfoKHR dummyInfo = + { + vk::VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, + DE_NULL, + 0u, + surface, + properties.minImageCount, + imageFormat, + imageColorSpace, + dummySize, + imageLayers, + imageUsage, + vk::VK_SHARING_MODE_EXCLUSIVE, + 1u, + &queueFamilyIndex, + preTransform, + compositeAlpha, + presentMode, + clipped, + (vk::VkSwapchainKHR)0 + }; + + createInfos.push_back(dummyInfo); } } } -- 2.7.4