Improve wsi.incremental_present.* for low memory
authorAaron Bartholomew <abartholomew@nvidia.com>
Mon, 20 Aug 2018 19:28:42 +0000 (12:28 -0700)
committerAaron Bartholomew <abartholomew@nvidia.com>
Tue, 28 Aug 2018 17:59:43 +0000 (13:59 -0400)
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 &amp; it&apos;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)

external/vulkancts/modules/vulkan/wsi/vktWsiIncrementalPresentTests.cpp

index e8a00cb..a32e5f5 100644 (file)
@@ -971,21 +971,25 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainConfigs (vk::VkSurfac
        const vk::VkBool32                                              clipped                         = VK_FALSE;
        vector<vk::VkSwapchainCreateInfoKHR>    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;
@@ -1039,6 +1043,31 @@ std::vector<vk::VkSwapchainCreateInfoKHR> 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);
                        }
                }
        }