From 48777c8fcfa5b0cd1474461e9c25540bdeffe75b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 13 Aug 2020 18:47:52 +0200 Subject: [PATCH] [dxvk] Remove optional memory property flags one by one We don't always want to remove HOST_CACHED if no DEVICE_LOCAL type exists, so iterate over the bits one by one. --- src/dxvk/dxvk_memory.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dxvk/dxvk_memory.cpp b/src/dxvk/dxvk_memory.cpp index 11f2dfa13..15d199cd5 100644 --- a/src/dxvk/dxvk_memory.cpp +++ b/src/dxvk/dxvk_memory.cpp @@ -200,9 +200,14 @@ namespace dxvk { // If that still didn't work, probe slower memory types as well VkMemoryPropertyFlags optFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + VkMemoryPropertyFlags remFlags = 0; - if (!result && (flags & optFlags)) - result = this->tryAlloc(req, dedAllocPtr, flags & ~optFlags, priority); + while (!result && (flags & optFlags)) { + remFlags |= optFlags & -optFlags; + optFlags &= ~remFlags; + + result = this->tryAlloc(req, dedAllocPtr, flags & ~remFlags, priority); + } if (!result) { DxvkAdapterMemoryInfo memHeapInfo = m_device->adapter()->getMemoryHeapInfo();