layers: Only set up tracking for new descriptors if allocation succeeded.
authorChris Forbes <chrisforbes@google.com>
Fri, 22 Jan 2016 02:44:40 +0000 (15:44 +1300)
committerJon Ashburn <jon@lunarg.com>
Fri, 22 Jan 2016 23:47:37 +0000 (16:47 -0700)
It's possible for this call to fail -- the pool is exhausted, or the request was simply bogus. In these cases, the returned descriptor set handles are meaningless. Don't shove them in our hashtables.

Signed-off-by: Chris Forbes <chrisforbes@google.com>
layers/object_tracker.h

index 4622c18..0c3d42b 100644 (file)
@@ -932,11 +932,13 @@ explicit_AllocateDescriptorSets(
     VkResult result = get_dispatch_table(object_tracker_device_table_map, device)->AllocateDescriptorSets(
         device, pAllocateInfo, pDescriptorSets);
 
-    loader_platform_thread_lock_mutex(&objLock);
-    for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) {
-        alloc_descriptor_set(device, pAllocateInfo->descriptorPool, pDescriptorSets[i], VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT);
+    if (VK_SUCCESS == result) {
+        loader_platform_thread_lock_mutex(&objLock);
+        for (uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++) {
+            alloc_descriptor_set(device, pAllocateInfo->descriptorPool, pDescriptorSets[i], VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT);
+        }
+        loader_platform_thread_unlock_mutex(&objLock);
     }
-    loader_platform_thread_unlock_mutex(&objLock);
 
     return result;
 }