From fe4a621c7bd2302c7f1aaa8cdb55a446b3975a01 Mon Sep 17 00:00:00 2001 From: Lars Harrison Date: Sat, 3 Feb 2024 02:18:23 +0000 Subject: [PATCH] Fix coherent memory allocation to use device When allocating coherent memory (generally, suballocations) and looking up existing VkDeviceMemory entries, the device is critical to finding valid allocation blocks, otherwise allocations from other devices might be chosen, which invalidate things. This happens only in situations where a single process has multiple VkDevices, so it was rare enough not to be caught until now. Reviewed-by: Aaron Ruby Acked-by: Yonggang Luo Acked-by: Adam Jackson Part-of: --- src/gfxstream/guest/vulkan_enc/ResourceTracker.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gfxstream/guest/vulkan_enc/ResourceTracker.cpp b/src/gfxstream/guest/vulkan_enc/ResourceTracker.cpp index 97eac6ecf80..be6fb36f943 100644 --- a/src/gfxstream/guest/vulkan_enc/ResourceTracker.cpp +++ b/src/gfxstream/guest/vulkan_enc/ResourceTracker.cpp @@ -3155,6 +3155,8 @@ VkResult ResourceTracker::getCoherentMemory(const VkMemoryAllocateInfo* pAllocat { AutoLock lock(mLock); for (const auto& [memory, info] : info_VkDeviceMemory) { + if (info.device != device) continue; + if (info.memoryTypeIndex != pAllocateInfo->memoryTypeIndex) continue; if (info.dedicated || dedicated) continue;