Fix partial heap usage in protected_memory android swapchain tests
authorChris Hambacher <c.hambacher@samsung.com>
Thu, 21 Jul 2022 18:28:01 +0000 (13:28 -0500)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 4 Aug 2022 15:54:21 +0000 (15:54 +0000)
On devices with small amounts of protected memory, limitting usage to
25% of the total protected memory causes tests to be skipped. Tweak
to allow for full usage of the protected heap.

Affects:
dEQP-VK.protected_memory.interaction.wsi.android.swapchain.create.min_image_count
dEQP-VK.protected_memory.interaction.wsi.android.swapchain.create.image_format
dEQP-VK.protected_memory.interaction.wsi.android.swapchain.create.image_extent

Components: Vulkan

VK-GL-CTS Issue: 3296

Change-Id: I43c1cfc8d0e44d401952317158829f1a2da241a1

external/vulkancts/modules/vulkan/protected_memory/vktProtectedMemWsiSwapchainTests.cpp

index 50a416c9470808b7d5689283a66c002c62dc4793..d41b101cfa9f651a4106f3a73706f1f7a6029245 100644 (file)
@@ -317,7 +317,6 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                        // Determine the maximum memory heap space available for protected images
                        vk::VkPhysicalDeviceMemoryProperties    memoryProperties        = vk::getPhysicalDeviceMemoryProperties(context.getInstanceDriver(), context.getPhysicalDevice());
                        vk::VkDeviceSize                                                protectedHeapSize       = 0;
-                       vk::VkDeviceSize                                                maxMemoryUsage          = 0;
                        deUint32                                                                protectedHeapMask       = 0;
 
                        for (deUint32 memType = 0; memType < memoryProperties.memoryTypeCount; memType++)
@@ -330,15 +329,14 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                                        (protectedHeapMask & (1u << heapIndex)) == 0)
                                {
                                        protectedHeapSize = de::max(protectedHeapSize, memoryProperties.memoryHeaps[heapIndex].size);
-                                       maxMemoryUsage    = protectedHeapSize / 4 ; /* Use at maximum 25% of heap */
                                        protectedHeapMask |= 1u << heapIndex;
                                }
                        }
 
                        // If the implementation doesn't have a max image count, min+16 means we won't clamp.
-                       // Limit it to how many protected images we estimate can be allocated - 25% of heap size
+                       // Limit it to how many protected images we estimate can be allocated
                        const deUint32  maxImageCount           = de::min((capabilities.maxImageCount > 0) ? capabilities.maxImageCount : capabilities.minImageCount + 16u,
-                                                                                                                 deUint32(maxMemoryUsage / memoryRequirements.size));
+                                                                                                                 deUint32(protectedHeapSize / memoryRequirements.size));
                        if (maxImageCount < capabilities.minImageCount)
                                TCU_THROW(NotSupportedError, "Memory heap doesn't have enough memory!.");
 
@@ -358,7 +356,6 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                        vk::VkDevice                                                    device                          = context.getDevice();
                        vk::VkPhysicalDeviceMemoryProperties    memoryProperties        = vk::getPhysicalDeviceMemoryProperties(context.getInstanceDriver(), context.getPhysicalDevice());
                        vk::VkDeviceSize                                                protectedHeapSize       = 0;
-                       vk::VkDeviceSize                                                maxMemoryUsage          = 0;
 
                        for (deUint32 memType = 0; memType < memoryProperties.memoryTypeCount; memType++)
                        {
@@ -368,7 +365,6 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
 #endif
                                {
                                        protectedHeapSize = de::max(protectedHeapSize, memoryProperties.memoryHeaps[heapIndex].size);
-                                       maxMemoryUsage    = protectedHeapSize / 4 ; /* Use at maximum 25% of heap */
                                }
                        }
 
@@ -407,7 +403,7 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                                        }
 
                                        // Check for the image size requirement based on double/triple buffering
-                                       if (memoryRequirements.size  * capabilities.minImageCount < maxMemoryUsage)
+                                       if (memoryRequirements.size  * capabilities.minImageCount < protectedHeapSize)
                                        {
                                                cases.push_back(baseParameters);
                                                cases.back().imageFormat                = curFmt->format;
@@ -433,7 +429,6 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                        vk::VkDevice                                                    device                          = context.getDevice();
                        vk::VkPhysicalDeviceMemoryProperties    memoryProperties        = vk::getPhysicalDeviceMemoryProperties(context.getInstanceDriver(), context.getPhysicalDevice());
                        vk::VkDeviceSize                                                protectedHeapSize       = 0;
-                       vk::VkDeviceSize                                                maxMemoryUsage          = 0;
 
                        for (deUint32 memType = 0; memType < memoryProperties.memoryTypeCount; memType++)
                        {
@@ -443,7 +438,6 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
 #endif
                                {
                                        protectedHeapSize = de::max(protectedHeapSize, memoryProperties.memoryHeaps[heapIndex].size);
-                                       maxMemoryUsage    = protectedHeapSize / 4 ; /* Use at maximum 25% of heap */
                                }
                        }
 
@@ -483,7 +477,7 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                                        }
 
                                        // Check for the image size requirement based on double/triple buffering
-                                       if (memoryRequirements.size  * capabilities.minImageCount < maxMemoryUsage)
+                                       if (memoryRequirements.size  * capabilities.minImageCount < protectedHeapSize)
                                        {
                                                cases.push_back(baseParameters);
                                                cases.back().imageExtent.width  = de::clamp(s_testSizes[ndx].width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width);
@@ -525,7 +519,7 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                                }
 
                                // Check for the image size requirement based on double/triple buffering
-                               if (memoryRequirements.size  * capabilities.minImageCount < maxMemoryUsage)
+                               if (memoryRequirements.size  * capabilities.minImageCount < protectedHeapSize)
                                {
                                        cases.push_back(baseParameters);
                                        cases.back().imageExtent = capabilities.currentExtent;
@@ -573,7 +567,7 @@ std::vector<vk::VkSwapchainCreateInfoKHR> generateSwapchainParameterCases (vk::w
                                        }
 
                                        // Check for the image size requirement based on double/triple buffering
-                                       if (memoryRequirements.size  * capabilities.minImageCount < maxMemoryUsage)
+                                       if (memoryRequirements.size  * capabilities.minImageCount < protectedHeapSize)
                                        {
                                                cases.push_back(baseParameters);
                                                cases.back().imageExtent =s_testExtentSizes[ndx];