From abf89356cdae728c6876e5207f4636fae94da0e9 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 17 Sep 2019 23:52:02 +0200 Subject: [PATCH] [d3d11] Report unified memory if all heaps are device-local Together with mapping default resources, this may or may not help performance in some applications on integrated graphics. --- src/d3d11/d3d11_device.cpp | 14 +++++++++++++- src/d3d11/d3d11_device.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 55a694fc5..fec92ec5b 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1649,7 +1649,7 @@ namespace dxvk { info->MapOnDefaultTextures = TRUE; info->TiledResourcesTier = D3D11_TILED_RESOURCES_NOT_SUPPORTED; info->StandardSwizzle = FALSE; - info->UnifiedMemoryArchitecture = FALSE; // Maybe on some APUs? + info->UnifiedMemoryArchitecture = IsUnifiedMemoryArch(); } return S_OK; case D3D11_FEATURE_D3D11_OPTIONS3: { @@ -2307,6 +2307,18 @@ namespace dxvk { } + BOOL D3D11Device::IsUnifiedMemoryArch() { + auto memory = m_dxvkAdapter->memoryProperties(); + bool result = true; + + // Report unified memory if all heaps are device-local + for (uint32_t i = 0; i < memory.memoryHeapCount && result; i++) + result &= memory.memoryHeaps[i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT; + + return result; + } + + D3D_FEATURE_LEVEL D3D11Device::GetMaxFeatureLevel(const Rc& Adapter) { static const std::array, 9> s_featureLevels = {{ { "12_1", D3D_FEATURE_LEVEL_12_1 }, diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index c8f1ec1f7..ebd83cac2 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -495,6 +495,8 @@ namespace dxvk { ID3D11Resource* pResource, UINT Subresource, const D3D11_BOX* pBox); + + BOOL IsUnifiedMemoryArch(); static D3D_FEATURE_LEVEL GetMaxFeatureLevel( const Rc& Adapter);