Added Allocator::IsUMA, IsCacheCoherentUMA

Also fixes in TestDevice4.
diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp
index 7ba6d97..a8ec007 100644
--- a/src/D3D12MemAlloc.cpp
+++ b/src/D3D12MemAlloc.cpp
@@ -2768,6 +2768,8 @@
     // Shortcut for "Allocation Callbacks", because this function is called so often.

     const ALLOCATION_CALLBACKS& GetAllocs() const { return m_AllocationCallbacks; }

     const D3D12_FEATURE_DATA_D3D12_OPTIONS& GetD3D12Options() const { return m_D3D12Options; }

+    BOOL IsUMA() const { return m_D3D12Architecture.UMA; }

+    BOOL IsCacheCoherentUMA() const { return m_D3D12Architecture.CacheCoherentUMA; }

     bool SupportsResourceHeapTier2() const { return m_D3D12Options.ResourceHeapTier >= D3D12_RESOURCE_HEAP_TIER_2; }

     bool UseMutex() const { return m_UseMutex; }

     AllocationObjectAllocator& GetAllocationObjectAllocator() { return m_AllocationObjectAllocator; }

@@ -2885,6 +2887,7 @@
     D3D12MA_ATOMIC_UINT32 m_CurrentFrameIndex;

     DXGI_ADAPTER_DESC m_AdapterDesc;

     D3D12_FEATURE_DATA_D3D12_OPTIONS m_D3D12Options;

+    D3D12_FEATURE_DATA_ARCHITECTURE m_D3D12Architecture;

     AllocationObjectAllocator m_AllocationObjectAllocator;

 

     typedef IntrusiveLinkedList<CommittedAllocationListItemTraits> CommittedAllocationList;

@@ -4485,6 +4488,7 @@
 {

     // desc.pAllocationCallbacks intentionally ignored here, preprocessed by CreateAllocator.

     ZeroMemory(&m_D3D12Options, sizeof(m_D3D12Options));

+    ZeroMemory(&m_D3D12Architecture, sizeof(m_D3D12Architecture));

 

     ZeroMemory(m_BlockVectors, sizeof(m_BlockVectors));

     ZeroMemory(m_DefaultPoolTier1MinBytes, sizeof(m_DefaultPoolTier1MinBytes));

@@ -4527,6 +4531,13 @@
     m_D3D12Options.ResourceHeapTier = (D3D12MA_FORCE_RESOURCE_HEAP_TIER);

 #endif

 

+    hr = m_Device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &m_D3D12Architecture, sizeof(m_D3D12Architecture));

+    if(FAILED(hr))

+    {

+        m_D3D12Architecture.UMA = FALSE;

+        m_D3D12Architecture.CacheCoherentUMA = FALSE;

+    }

+

     D3D12_HEAP_PROPERTIES heapProps = {};

     const UINT defaultPoolCount = CalcDefaultPoolCount();

     for(UINT i = 0; i < defaultPoolCount; ++i)

@@ -6291,6 +6302,14 @@
 {

     return m_Pimpl->GetD3D12Options();

 }

+BOOL Allocator::IsUMA() const

+{

+    return m_Pimpl->IsUMA();

+}

+BOOL Allocator::IsCacheCoherentUMA() const

+{

+    return m_Pimpl->IsCacheCoherentUMA();

+}

 

 HRESULT Allocator::CreateResource(

     const ALLOCATION_DESC* pAllocDesc,

diff --git a/src/D3D12MemAlloc.h b/src/D3D12MemAlloc.h
index 8611585..f68f4d1 100644
--- a/src/D3D12MemAlloc.h
+++ b/src/D3D12MemAlloc.h
@@ -24,7 +24,7 @@
 

 /** \mainpage D3D12 Memory Allocator

 

-<b>Version 2.0.0-development</b> (2021-02-16)

+<b>Version 2.0.0-development</b> (2021-03-11)

 

 Copyright (c) 2019-2021 Advanced Micro Devices, Inc. All rights reserved. \n

 License: MIT

@@ -1227,6 +1227,22 @@
     

     /// Returns cached options retrieved from D3D12 device.

     const D3D12_FEATURE_DATA_D3D12_OPTIONS& GetD3D12Options() const;

+    /** \brief Returns true if `D3D12_FEATURE_DATA_ARCHITECTURE1::UMA` was found to be true.

+    

+    For more information about how to use it, see articles in Microsoft Docs:

+    - https://docs.microsoft.com/en-us/windows/win32/direct3d12/default-texture-mapping

+    - https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_architecture

+    - https://docs.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getcustomheapproperties

+    */

+    BOOL IsUMA() const;

+    /** \brief Returns true if `D3D12_FEATURE_DATA_ARCHITECTURE1::CacheCoherentUMA` was found to be true.

+

+    For more information about how to use it, see articles in Microsoft Docs:

+    - https://docs.microsoft.com/en-us/windows/win32/direct3d12/default-texture-mapping

+    - https://docs.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_architecture

+    - https://docs.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getcustomheapproperties

+    */

+    BOOL IsCacheCoherentUMA() const;

 

     /** \brief Allocates memory and creates a D3D12 resource (buffer or texture). This is the main allocation function.

 

diff --git a/src/Tests.cpp b/src/Tests.cpp
index 4a15bde..f65f5b8 100644
--- a/src/Tests.cpp
+++ b/src/Tests.cpp
@@ -1422,11 +1422,22 @@
     wprintf(L"Test ID3D12Device4\n");

 

     CComPtr<ID3D12Device4> dev4;

-    CHECK_HR(ctx.device->QueryInterface(&dev4));

+    HRESULT hr = ctx.device->QueryInterface(&dev4);

+    if(FAILED(hr))

+    {

+        wprintf(L"QueryInterface for ID3D12Device4 FAILED.\n");

+        return;

+    }

 

     D3D12_PROTECTED_RESOURCE_SESSION_DESC sessionDesc = {};

     CComPtr<ID3D12ProtectedResourceSession> session;

-    CHECK_HR(dev4->CreateProtectedResourceSession(&sessionDesc, IID_PPV_ARGS(&session)));

+    // This fails on the SOFTWARE adapter.

+    hr = dev4->CreateProtectedResourceSession(&sessionDesc, IID_PPV_ARGS(&session));

+    if(FAILED(hr))

+    {

+        wprintf(L"ID3D12Device4::CreateProtectedResourceSession FAILED.\n");

+        return;

+    }

 

     // Create a buffer