OSDN Git Service

libvulkan: Fix dEQP-VK.api.object_management.alloc_callback_fail.device
authorJesse Hall <jessehall@google.com>
Fri, 22 Jan 2016 05:54:49 +0000 (21:54 -0800)
committerJesse Hall <jessehall@google.com>
Mon, 25 Jan 2016 21:49:31 +0000 (13:49 -0800)
In vkCreateDevice, we were using the app-provided allocator if available,
otherwise the instance allocator. (The code also fell back to the
default allocator if the instance didn't have an allocator, but it
always does, so the fallback was dead code.) That's all as it should
be.

However, we don't store the app-provided allocator, and everywhere
else just uses the instance allocator. In particular, vkDestroyDevice
ignores the app-provided allocator, and just uses the instance
allocator to free the Device structure. That causes the test to fail,
since we use the app-provided device allocator to allocate, but the
instance allocator to free.

Getting this right will require some possibly large restructuring and
careful review of the code. In the short term, this change just
ignores the app-provided allocator in vkCreateDevice and uses the
instance allocator instead, so that at least we use the same allocator
for alloc and free. Bug 26732122 filed to do this properly.

Change-Id: I4ed4c12dfa255bb58a33dca1a89946255276c791
(cherry picked from commit 58579313664f5d72706f8e3df50b4e7217f7326b)

vulkan/libvulkan/loader.cpp

index 4b7bd57..bc1c3b8 100644 (file)
@@ -835,12 +835,11 @@ VkResult CreateDevice_Bottom(VkPhysicalDevice gpu,
     Instance& instance = GetDispatchParent(gpu);
     VkResult result;
 
-    if (!allocator) {
-        if (instance.alloc)
-            allocator = instance.alloc;
-        else
-            allocator = &kDefaultAllocCallbacks;
-    }
+    // FIXME(jessehall): We don't have good conventions or infrastructure yet to
+    // do better than just using the instance allocator and scope for
+    // everything. See b/26732122.
+    if (true /*!allocator*/)
+        allocator = instance.alloc;
 
     void* mem = allocator->pfnAllocation(allocator->pUserData, sizeof(Device),
                                          alignof(Device),