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 <aruby@blackberry.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
Lars Harrison
2024-02-03 02:18:23 +00:00
committed by Marge Bot
parent ef4d6d8fb4
commit fe4a621c7b
@@ -3155,6 +3155,8 @@ VkResult ResourceTracker::getCoherentMemory(const VkMemoryAllocateInfo* pAllocat
{
AutoLock<RecursiveLock> 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;