From 033104f335273f80b4dc186f0e364ff466b3ba80 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Thu, 19 Sep 2024 00:01:30 +0200 Subject: [PATCH] [d3d9] Cleanup buffer memory flag selection --- src/d3d9/d3d9_common_buffer.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/d3d9/d3d9_common_buffer.cpp b/src/d3d9/d3d9_common_buffer.cpp index 370301dbe..7b5f60d50 100644 --- a/src/d3d9/d3d9_common_buffer.cpp +++ b/src/d3d9/d3d9_common_buffer.cpp @@ -111,12 +111,20 @@ namespace dxvk { info.stages |= VK_PIPELINE_STAGE_HOST_BIT; info.access |= VK_ACCESS_HOST_WRITE_BIT; - if (!(m_desc.Usage & D3DUSAGE_WRITEONLY)) - info.access |= VK_ACCESS_HOST_READ_BIT; - memoryFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT - | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT - | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + + if ((m_desc.Usage & (D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC)) == 0 + || DoPerDrawUpload() + || m_parent->CanOnlySWVP() + || m_parent->GetOptions()->cachedDynamicBuffers) { + // Never use uncached memory on devices that support SWVP because we might end up reading from it. + + info.access |= VK_ACCESS_HOST_READ_BIT; + memoryFlags |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + } else { + memoryFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + } } else { info.stages |= VK_PIPELINE_STAGE_TRANSFER_BIT; @@ -126,13 +134,6 @@ namespace dxvk { memoryFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; } - if ((memoryFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && (m_parent->GetOptions()->cachedDynamicBuffers || m_parent->CanOnlySWVP())) { - // Never use uncached memory on devices that support SWVP because we might end up reading from it. - memoryFlags &= ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - memoryFlags |= VK_MEMORY_PROPERTY_HOST_COHERENT_BIT - | VK_MEMORY_PROPERTY_HOST_CACHED_BIT; - } - return m_parent->GetDXVKDevice()->createBuffer(info, memoryFlags); }