VK_KHR_maintenance1: Test out of descriptor pool memory error
authorMaciej Jesionowski <maciej.jesionowski@mobica.com>
Fri, 25 Nov 2016 09:24:09 +0000 (10:24 +0100)
committerPyry Haulos <phaulos@google.com>
Wed, 14 Dec 2016 11:12:21 +0000 (07:12 -0400)
New tests:
- dEQP-VK.api.descriptor_pool.out_of_pool_memory

Issue #532

Change-Id: I80ad9301d3bc4b9d4b6afe9bdf6fe6458c4065d0

android/cts/master/vk-master.txt
external/vulkancts/framework/vulkan/vkBasicTypes.inl
external/vulkancts/framework/vulkan/vkStrUtilImpl.inl
external/vulkancts/modules/vulkan/api/vktApiDescriptorPoolTests.cpp
external/vulkancts/mustpass/1.0.2/vk-default.txt
external/vulkancts/scripts/src/vulkan.h.in

index 00792adb2c2f13f57e5f7aecc06bd56ee12311b4..0d442fca331d445ab150ceac118d5fca933da349 100644 (file)
@@ -19444,6 +19444,7 @@ dEQP-VK.api.fill_and_update_buffer.fill_buffer_second_part
 dEQP-VK.api.fill_and_update_buffer.update_buffer_second_part
 dEQP-VK.api.descriptor_pool.repeated_reset_short
 dEQP-VK.api.descriptor_pool.repeated_reset_long
+dEQP-VK.api.descriptor_pool.out_of_pool_memory
 dEQP-VK.api.null_handle.destroy_buffer
 dEQP-VK.api.null_handle.destroy_buffer_view
 dEQP-VK.api.null_handle.destroy_command_pool
index 5ffd61aba5cdac56834a18d0e76a623206fc698f..55d17af8b658c98bb934cefade7b6c54adca4913 100644 (file)
@@ -82,6 +82,7 @@ enum VkResult
        VK_ERROR_INCOMPATIBLE_DISPLAY_KHR       = -1000003001,
        VK_ERROR_VALIDATION_FAILED_EXT          = -1000011001,
        VK_ERROR_INVALID_SHADER_NV                      = -1000012000,
+       VK_ERROR_OUT_OF_POOL_MEMORY_KHR         = -1000069000,
 };
 
 enum VkStructureType
index ea03d3631cd5019e4e4161cb05fa672b1fb9f902..c77b36ddc1d963b205c95540583db5bb7297c54e 100644 (file)
@@ -91,6 +91,7 @@ const char* getResultName (VkResult value)
                case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
                case VK_ERROR_VALIDATION_FAILED_EXT:    return "VK_ERROR_VALIDATION_FAILED_EXT";
                case VK_ERROR_INVALID_SHADER_NV:                return "VK_ERROR_INVALID_SHADER_NV";
+               case VK_ERROR_OUT_OF_POOL_MEMORY_KHR:   return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR";
                default:                                                                return DE_NULL;
        }
 }
index 9e3509ca03e7bb75446e574dc0efa72f80fda77f..64d863f8a2cb0165d5a74cd9d8b99842a8101ff0 100644 (file)
@@ -37,6 +37,7 @@
 #include "deUniquePtr.hpp"
 #include "deSharedPtr.hpp"
 #include "deInt32.h"
+#include "deSTLUtil.hpp"
 
 namespace vkt
 {
@@ -142,6 +143,118 @@ tcu::TestStatus resetDescriptorPoolTest (Context& context, deUint32 numIteration
        return tcu::TestStatus::pass("Pass");
 }
 
+tcu::TestStatus outOfPoolMemoryTest (Context& context)
+{
+       const DeviceInterface&  vkd                                                     = context.getDeviceInterface();
+       const VkDevice                  device                                          = context.getDevice();
+       const bool                              expectOutOfPoolMemoryError      = de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), "VK_KHR_maintenance1");
+       deUint32                                numErrorsReturned                       = 0;
+
+       const struct FailureCase
+       {
+               deUint32        poolDescriptorCount;            //!< total number of descriptors (of a given type) in the descriptor pool
+               deUint32        poolMaxSets;                            //!< max number of descriptor sets that can be allocated from the pool
+               deUint32        bindingCount;                           //!< number of bindings per descriptor set layout
+               deUint32        bindingDescriptorCount;         //!< number of descriptors in a binding (array size) (in all bindings)
+               deUint32        descriptorSetCount;                     //!< number of descriptor sets to allocate
+               string          description;                            //!< the log message for this failure condition
+       } failureCases[] =
+       {
+               //      pool                    pool            binding         binding         alloc set
+               //      descr. count    max sets        count           array size      count
+               {       4u,                             2u,                     1u,                     1u,                     3u,             "Out of descriptor sets",                                                                                       },
+               {       3u,                             4u,                     1u,                     1u,                     4u,             "Out of descriptors (due to the number of sets)",                                       },
+               {       2u,                             1u,                     3u,                     1u,                     1u,             "Out of descriptors (due to the number of bindings)",                           },
+               {       3u,                             2u,                     1u,                     2u,                     2u,             "Out of descriptors (due to descriptor array size)",                            },
+               {       5u,                             1u,                     2u,                     3u,                     1u,             "Out of descriptors (due to descriptor array size in all bindings)",},
+       };
+
+       context.getTestContext().getLog()
+               << tcu::TestLog::Message
+               << "Creating a descriptor pool with insufficient resources. Descriptor set allocation is likely to fail."
+               << tcu::TestLog::EndMessage;
+
+       for (deUint32 failureCaseNdx = 0u; failureCaseNdx < DE_LENGTH_OF_ARRAY(failureCases); ++failureCaseNdx)
+       {
+               const FailureCase& params = failureCases[failureCaseNdx];
+               context.getTestContext().getLog() << tcu::TestLog::Message << "Checking: " << params.description << tcu::TestLog::EndMessage;
+
+               for (VkDescriptorType   descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
+                                                               descriptorType < VK_DESCRIPTOR_TYPE_LAST;
+                                                               descriptorType = static_cast<VkDescriptorType>(descriptorType + 1))
+               {
+                       context.getTestContext().getLog() << tcu::TestLog::Message << "- " << getDescriptorTypeName(descriptorType) << tcu::TestLog::EndMessage;
+
+                       const VkDescriptorPoolSize                                      descriptorPoolSize =
+                       {
+                               descriptorType,                                                                                         // type
+                               params.poolDescriptorCount,                                                                     // descriptorCount
+                       };
+
+                       const VkDescriptorPoolCreateInfo                        descriptorPoolCreateInfo =
+                       {
+                               VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,                          // VkStructureType                sType;
+                               DE_NULL,                                                                                                        // const void*                    pNext;
+                               (VkDescriptorPoolCreateFlags)0,                                                         // VkDescriptorPoolCreateFlags    flags;
+                               params.poolMaxSets,                                                                                     // uint32_t                       maxSets;
+                               1u,                                                                                                                     // uint32_t                       poolSizeCount;
+                               &descriptorPoolSize,                                                                            // const VkDescriptorPoolSize*    pPoolSizes;
+                       };
+
+                       const Unique<VkDescriptorPool>                          descriptorPool(createDescriptorPool(vkd, device, &descriptorPoolCreateInfo));
+
+                       const VkDescriptorSetLayoutBinding                      descriptorSetLayoutBinding =
+                       {
+                               0u,                                                                                                                     // uint32_t              binding;
+                               descriptorType,                                                                                         // VkDescriptorType      descriptorType;
+                               params.bindingDescriptorCount,                                                          // uint32_t              descriptorCount;
+                               VK_SHADER_STAGE_ALL,                                                                            // VkShaderStageFlags    stageFlags;
+                               DE_NULL,                                                                                                        // const VkSampler*      pImmutableSamplers;
+                       };
+
+                       const vector<VkDescriptorSetLayoutBinding>      descriptorSetLayoutBindings (params.bindingCount, descriptorSetLayoutBinding);
+                       const VkDescriptorSetLayoutCreateInfo           descriptorSetLayoutInfo =
+                       {
+                               VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,            // VkStructureType                        sType;
+                               DE_NULL,                                                                                                        // const void*                            pNext;
+                               (VkDescriptorSetLayoutCreateFlags)0,                                            // VkDescriptorSetLayoutCreateFlags       flags;
+                               static_cast<deUint32>(descriptorSetLayoutBindings.size()),      // uint32_t                               bindingCount;
+                               &descriptorSetLayoutBindings[0],                                                        // const VkDescriptorSetLayoutBinding*    pBindings;
+                       };
+
+                       const Unique<VkDescriptorSetLayout>                     descriptorSetLayout     (createDescriptorSetLayout(vkd, device, &descriptorSetLayoutInfo));
+                       const vector<VkDescriptorSetLayout>                     rawSetLayouts           (params.descriptorSetCount, *descriptorSetLayout);
+                       vector<VkDescriptorSet>                                         rawDescriptorSets       (params.descriptorSetCount, DE_NULL);
+
+                       const VkDescriptorSetAllocateInfo                       descriptorSetAllocateInfo =
+                       {
+                               VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,                         // VkStructureType                 sType;
+                               DE_NULL,                                                                                                        // const void*                     pNext;
+                               *descriptorPool,                                                                                        // VkDescriptorPool                descriptorPool;
+                               static_cast<deUint32>(rawSetLayouts.size()),                            // uint32_t                        descriptorSetCount;
+                               &rawSetLayouts[0],                                                                                      // const VkDescriptorSetLayout*    pSetLayouts;
+                       };
+
+                       const VkResult result = vkd.allocateDescriptorSets(device, &descriptorSetAllocateInfo, &rawDescriptorSets[0]);
+
+                       if (result != VK_SUCCESS)
+                       {
+                               ++numErrorsReturned;
+
+                               if (expectOutOfPoolMemoryError && result != VK_ERROR_OUT_OF_POOL_MEMORY_KHR)
+                                       return tcu::TestStatus::fail("Expected VK_ERROR_OUT_OF_POOL_MEMORY_KHR but got " + string(getResultName(result)) + " instead");
+                       }
+                       else
+                               context.getTestContext().getLog() << tcu::TestLog::Message << "  Allocation was successful anyway" << tcu::TestLog::EndMessage;
+               }
+       }
+
+       if (numErrorsReturned == 0u)
+               return tcu::TestStatus::pass("Not validated");
+       else
+               return tcu::TestStatus::pass("Pass");
+}
+
 } // anonymous
 
 tcu::TestCaseGroup* createDescriptorPoolTests (tcu::TestContext& testCtx)
@@ -159,6 +272,10 @@ tcu::TestCaseGroup* createDescriptorPoolTests (tcu::TestContext& testCtx)
                                        "repeated_reset_long",
                                        "Test many cycles of vkAllocateDescriptorSets and vkResetDescriptorPool",
                                        resetDescriptorPoolTest, numIterationsHigh);
+       addFunctionCase(descriptorPoolTests.get(),
+                                       "out_of_pool_memory",
+                                       "Test that when we run out of descriptors a correct error code is returned",
+                                       outOfPoolMemoryTest);
 
        return descriptorPoolTests.release();
 }
index 8c8fbbd7df5a0ba9f21ce99b2e75838dd684b641..5fec511ce280e2dfd1fb2a4fb1295939a4b9f461 100644 (file)
@@ -14185,6 +14185,7 @@ dEQP-VK.api.fill_and_update_buffer.fill_buffer_second_part
 dEQP-VK.api.fill_and_update_buffer.update_buffer_second_part
 dEQP-VK.api.descriptor_pool.repeated_reset_short
 dEQP-VK.api.descriptor_pool.repeated_reset_long
+dEQP-VK.api.descriptor_pool.out_of_pool_memory
 dEQP-VK.api.null_handle.destroy_buffer
 dEQP-VK.api.null_handle.destroy_buffer_view
 dEQP-VK.api.null_handle.destroy_command_pool
index 03f0cf4c74654caa6e19386a2658ed19f82576f8..091464e6578459978213f8bb328d04083d6a09be 100644 (file)
@@ -145,6 +145,7 @@ typedef enum VkResult {
     VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
     VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
     VK_ERROR_INVALID_SHADER_NV = -1000012000,
+    VK_ERROR_OUT_OF_POOL_MEMORY_KHR = -1000069000,
     VK_RESULT_BEGIN_RANGE = VK_ERROR_FRAGMENTED_POOL,
     VK_RESULT_END_RANGE = VK_INCOMPLETE,
     VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FRAGMENTED_POOL + 1),