VK_KHR_maintenance1: Test vkAllocate* failure behavior
authorMaciej Jesionowski <maciej.jesionowski@mobica.com>
Thu, 24 Nov 2016 13:40:33 +0000 (14:40 +0100)
committerPyry Haulos <phaulos@google.com>
Thu, 15 Dec 2016 14:44:03 +0000 (10:44 -0400)
This tests updated behavior of vkAllocateCommandBuffers and
vkAllocateDescriptorSets. When allocating objects in bulk,
if some allocations fail then all objects must be freed and
handles must be set to VK_NULL_HANDLE.

Modified tests:
- dEQP-VK.api.object_management.alloc_callback_fail_multiple.descriptor_set
- dEQP-VK.api.object_management.alloc_callback_fail_multiple.command_buffer_primary
- dEQP-VK.api.object_management.alloc_callback_fail_multiple.command_buffer_secondary

Issue #532

Change-Id: If03e7cdbec4d13bd0671bab9d6a1edd9107636b5

external/vulkancts/modules/vulkan/api/vktApiObjectManagementTests.cpp

index 48e04ac..f91c297 100644 (file)
@@ -302,6 +302,11 @@ T alignToPowerOfTwo (T value, T align)
        return (value + align - T(1)) & ~(align - T(1));
 }
 
+inline bool hasDeviceExtension (Context& context, const string& name)
+{
+       return de::contains(context.getDeviceExtensions().begin(), context.getDeviceExtensions().end(), name);
+}
+
 VkDeviceSize getPageTableSize (const PlatformMemoryLimits& limits, VkDeviceSize allocationSize)
 {
        VkDeviceSize    totalSize       = 0;
@@ -317,8 +322,6 @@ VkDeviceSize getPageTableSize (const PlatformMemoryLimits& limits, VkDeviceSize
        return totalSize;
 }
 
-
-
 size_t getCurrentSystemMemoryUsage (const AllocationCallbackRecorder& allocRecoder)
 {
        const size_t                                            systemAllocationOverhead        = sizeof(void*)*2;
@@ -2519,12 +2522,14 @@ tcu::TestStatus allocCallbackFailTest (Context& context, typename Object::Parame
 }
 
 // Determine whether an API call sets the invalid handles to NULL (true) or leaves them undefined or not modified (false)
-template<typename T> inline bool isNullHandleOnAllocationFailure                        (void) { return false; }
-template<>                      inline bool isNullHandleOnAllocationFailure<VkPipeline> (void) { return true;  }
+template<typename T> inline bool isNullHandleOnAllocationFailure                                 (Context&)             { return false; }
+template<>                      inline bool isNullHandleOnAllocationFailure<VkCommandBuffer> (Context& context) { return hasDeviceExtension(context, "VK_KHR_maintenance1"); }
+template<>                      inline bool isNullHandleOnAllocationFailure<VkDescriptorSet> (Context& context) { return hasDeviceExtension(context, "VK_KHR_maintenance1"); }
+template<>                      inline bool isNullHandleOnAllocationFailure<VkPipeline>          (Context&)             { return true;  }
 
-template<typename T> inline bool isPooledObject                                                                 (void) { return false; };
-template<>                      inline bool isPooledObject<VkCommandBuffer>                     (void) { return true;  };
-template<>                      inline bool isPooledObject<VkDescriptorSet>                     (void) { return true;  };
+template<typename T> inline bool isPooledObject                                         (void) { return false; };
+template<>                      inline bool isPooledObject<VkCommandBuffer> (void) { return true;  };
+template<>                      inline bool isPooledObject<VkDescriptorSet> (void) { return true;  };
 
 template<typename Object>
 tcu::TestStatus allocCallbackFailMultipleObjectsTest (Context& context, typename Object::Parameters params)
@@ -2532,7 +2537,7 @@ tcu::TestStatus allocCallbackFailMultipleObjectsTest (Context& context, typename
        typedef SharedPtr<Move<typename Object::Type> > ObjectTypeSp;
 
        static const deUint32   numObjects                      = 4;
-       const bool                              expectNullHandles       = isNullHandleOnAllocationFailure<typename Object::Type>();
+       const bool                              expectNullHandles       = isNullHandleOnAllocationFailure<typename Object::Type>(context);
        deUint32                                numPassingAllocs        = 0;
 
        {