Removed macros D3D12MA_OPTIONS16_SUPPORTED, D3D12MA_TIGHT_ALIGNMENT_SUPPORTED from the public interface

Also removed them from the Cmake script. They are now automatically determined based on D3D12_PREVIEW_SDK_VERSION, D3D12_SDK_VERSION macro.
Also made fixes in tests.
diff --git a/include/D3D12MemAlloc.h b/include/D3D12MemAlloc.h
index bb102da..23c8f70 100644
--- a/include/D3D12MemAlloc.h
+++ b/include/D3D12MemAlloc.h
@@ -1130,8 +1130,6 @@
     When true, you can use `D3D12_HEAP_TYPE_GPU_UPLOAD`.

 

     This flag is fetched from `D3D12_FEATURE_D3D12_OPTIONS16::GPUUploadHeapSupported`.

-

-    `#define D3D12MA_OPTIONS16_SUPPORTED 1` is needed for the compilation of this library. Otherwise the flag is always false.

     */

     BOOL IsGPUUploadHeapSupported() const;

     /** \brief Returns true if resource tight alignment is supported on the current system.

@@ -1139,8 +1137,6 @@
     #ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT flag was specified on allocator creation.

 

     This flag is fetched from `D3D12_FEATURE_DATA_TIGHT_ALIGNMENT::SupportTier`.

-

-    `#define D3D12MA_TIGHT_ALIGNMENT_SUPPORTED 1` is needed for the compilation of this library. Otherwise the flag is always false.

     */

     BOOL IsTightAlignmentSupported() const;

     /** \brief Returns total amount of memory of specific segment group, in bytes.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6134ea3..327ec7c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -190,19 +190,3 @@
 else()
     message(STATUS "DX12 Agility SDK not used.")
 endif()
-
-option(D3D12MA_OPTIONS16_SUPPORTED "Set if using Agility SDK 1.710.0-preview or newer that defines D3D12_FEATURE_DATA_D3D12_OPTIONS16." OFF)
-if(D3D12MA_OPTIONS16_SUPPORTED)
-    target_compile_definitions(D3D12MemoryAllocator PRIVATE D3D12MA_OPTIONS16_SUPPORTED=1)
-    if(${D3D12MA_BUILD_SAMPLE} AND ${WIN32})
-        target_compile_definitions(D3D12Sample PRIVATE D3D12MA_OPTIONS16_SUPPORTED=1)
-    endif()
-endif()
-
-option(D3D12MA_TIGHT_ALIGNMENT_SUPPORTED "Set if using Agility SDK 1.716.0-preview or newer that defines D3D12_FEATURE_DATA_TIGHT_ALIGNMENT." OFF)
-if(D3D12MA_TIGHT_ALIGNMENT_SUPPORTED)
-    target_compile_definitions(D3D12MemoryAllocator PRIVATE D3D12MA_TIGHT_ALIGNMENT_SUPPORTED=1)
-    if(${D3D12MA_BUILD_SAMPLE} AND ${WIN32})
-        target_compile_definitions(D3D12Sample PRIVATE D3D12MA_TIGHT_ALIGNMENT_SUPPORTED=1)
-    endif()
-endif()
diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp
index 976e872..0d358ea 100644
--- a/src/D3D12MemAlloc.cpp
+++ b/src/D3D12MemAlloc.cpp
@@ -107,6 +107,22 @@
    #define D3D12MA_DEFAULT_BLOCK_SIZE (64ull * 1024 * 1024)

 #endif

 

+#ifndef D3D12MA_TIGHT_ALIGNMENT_SUPPORTED

+    #if D3D12_PREVIEW_SDK_VERSION >= 716

+        #define D3D12MA_TIGHT_ALIGNMENT_SUPPORTED 1

+    #else

+        #define D3D12MA_TIGHT_ALIGNMENT_SUPPORTED 0

+    #endif

+#endif

+

+#ifndef D3D12MA_OPTIONS16_SUPPORTED

+    #if D3D12_SDK_VERSION >= 610

+        #define D3D12MA_OPTIONS16_SUPPORTED 1

+    #else

+        #define D3D12MA_OPTIONS16_SUPPORTED 0

+    #endif

+#endif

+

 #ifndef D3D12MA_DEBUG_LOG

    #define D3D12MA_DEBUG_LOG(format, ...)

    /*

@@ -6168,9 +6184,6 @@
     m_D3D12Options.ResourceHeapTier = (D3D12MA_FORCE_RESOURCE_HEAP_TIER);

 #endif

 

-// You must define this macro to like `#define D3D12MA_OPTIONS16_SUPPORTED 1` to enable GPU Upload Heaps!

-// Unfortunately there is no way to programmatically check if the included <d3d12.h> defines D3D12_FEATURE_DATA_D3D12_OPTIONS16 or not.

-// Main interfaces have respective macros like __ID3D12Device4_INTERFACE_DEFINED__, but structures like this do not.

 #if D3D12MA_OPTIONS16_SUPPORTED

     {

         D3D12_FEATURE_DATA_D3D12_OPTIONS16 options16 = {};

@@ -6180,11 +6193,8 @@
             m_GPUUploadHeapSupported = options16.GPUUploadHeapSupported;

         }

     }

-#endif

+#endif // #if D3D12MA_OPTIONS16_SUPPORTED

 

-    // You must define macro `#define D3D12MA_TIGHT_ALIGNMENT_SUPPORTED 1` to enable resource tight alignment!

-    // Unfortunately there is no way to programmatically check if the included <d3d12.h> defines D3D12_FEATURE_DATA_TIGHT_ALIGNMENT or not.

-    // Main interfaces have respective macros like __ID3D12Device4_INTERFACE_DEFINED__, but structures like this do not.

 #if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED

     {

         D3D12_FEATURE_DATA_TIGHT_ALIGNMENT tightAlignment = {};

@@ -6202,7 +6212,7 @@
             }

         }

     }

-#endif

+#endif // #if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED

 

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

     if (FAILED(hr))

@@ -7427,7 +7437,7 @@
     outPreferCommitted = false;

 

     D3D12MA_ASSERT((allocDesc.HeapType != D3D12_HEAP_TYPE_GPU_UPLOAD_COPY || IsGPUUploadHeapSupported()) &&

-        "Trying to allocate from D3D12_HEAP_TYPE_GPU_UPLOAD while GPUUploadHeapSupported == FALSE or D3D12MA_OPTIONS16_SUPPORTED macro was not defined when compiling D3D12MA library.");

+        "Trying to allocate from D3D12_HEAP_TYPE_GPU_UPLOAD while GPUUploadHeapSupported == FALSE.");

 

     bool msaaAlwaysCommitted;

     if (allocDesc.CustomPool != NULL)

diff --git a/src/Doxyfile b/src/Doxyfile
index a93bdbb..e9cc11b 100644
--- a/src/Doxyfile
+++ b/src/Doxyfile
@@ -42,7 +42,7 @@
 # title of most generated pages and in a few other places.
 # The default value is: My Project.
 
-PROJECT_NAME           = "Direct3D 12 Memory Allocator"
+PROJECT_NAME           = "D3D12 Memory Allocator"
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This
 # could be handy for archiving the generated documentation or if some version
@@ -2372,6 +2372,8 @@
                          __ID3D12Device4_INTERFACE_DEFINED__ \
                          __ID3D12Device8_INTERFACE_DEFINED__ \
                          __ID3D12Device10_INTERFACE_DEFINED__ \
+                         D3D12_PREVIEW_SDK_VERSION=716 \
+                         D3D12_SDK_VERSION=716 \
                          protected=private
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
diff --git a/src/Tests.cpp b/src/Tests.cpp
index 40388f9..f52419a 100644
--- a/src/Tests.cpp
+++ b/src/Tests.cpp
@@ -51,6 +51,8 @@
 static constexpr CONFIG_TYPE ConfigType = CONFIG_TYPE_AVERAGE;

 static const char* FREE_ORDER_NAMES[] = { "FORWARD", "BACKWARD", "RANDOM", };

 

+constexpr D3D12_RESOURCE_FLAGS D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY = (D3D12_RESOURCE_FLAGS)0x400;

+

 // Indexes match enum D3D12_HEAP_TYPE.

 static const WCHAR* const HEAP_TYPE_NAMES[] =

 {

@@ -204,6 +206,10 @@
             D3D12_RESOURCE_DESC resDesc = alloc->GetResource()->GetDesc();

             if (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)

             {

+                // Fix for D3D12 ERROR: ID3D12Device::CreatePlacedResource: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 8. When D3D12_RESOURCE_DESC::Flag bit for D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is set, Alignment must be 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT]

+                if ((resDesc.Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY) != 0)

+                    resDesc.Alignment = 0;

+

                 ComPtr<D3D12MA::Allocation> uploadAlloc;

                 CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, D3D12_RESOURCE_STATE_GENERIC_READ,

                     nullptr, &uploadAlloc, IID_NULL, nullptr));

@@ -296,6 +302,10 @@
             D3D12_RESOURCE_DESC resDesc = alloc->GetResource()->GetDesc();

             if (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)

             {

+                // Fix for D3D12 ERROR: ID3D12Device::CreatePlacedResource: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 8. When D3D12_RESOURCE_DESC::Flag bit for D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is set, Alignment must be 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT]

+                if ((resDesc.Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY) != 0)

+                    resDesc.Alignment = 0;

+

                 ComPtr<D3D12MA::Allocation> downloadAlloc;

                 CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, D3D12_RESOURCE_STATE_COPY_DEST,

                     nullptr, &downloadAlloc, IID_NULL, nullptr));

@@ -762,7 +772,13 @@
         CHECK_HR(ctx.allocator->CreateResource(&allocDesc, &resDesc, D3D12_RESOURCE_STATE_COMMON,

             nullptr, &resWithAlloc.allocation, IID_PPV_ARGS(&resWithAlloc.resource)));

         CHECK_BOOL(resWithAlloc.allocation && resWithAlloc.allocation->GetResource());

-        CHECK_BOOL(!resWithAlloc.allocation->GetHeap()); // Expected to be committed.

+        // May or may not be committed, depending on the PREFER_SMALL_BUFFERS_COMMITTED

+        // and TIGHT_ALIGNMENT settings.

+        const bool isCommitted = resWithAlloc.allocation->GetHeap() == NULL;

+        if (isCommitted)

+            wprintf(L"    Small buffer %llu B inside a custom pool was created as committed.\n", resDesc.Width);

+        else

+            wprintf(L"    Small buffer %llu B inside a custom pool was created as placed.\n", resDesc.Width);

     }

 

     // Test 3: NEVER_ALLOCATE.

@@ -2857,7 +2873,7 @@
 

 static void TestGPUUploadHeap(const TestContext& ctx)

 {

-#if D3D12MA_OPTIONS16_SUPPORTED

+#if D3D12_SDK_VERSION >= 610

     using namespace D3D12MA;

 

     wprintf(L"Test GPU Upload Heap\n");

@@ -3003,7 +3019,6 @@
 

 static void TestTightAlignment(const TestContext& ctx)

 {

-#if D3D12MA_TIGHT_ALIGNMENT_SUPPORTED

     using namespace D3D12MA;

 

     wprintf(L"Test resource tight alignment\n");

@@ -3047,7 +3062,6 @@
             resDesc.Width,

             allocs[1]->GetOffset());

     }

-#endif

 }

 

 static void TestVirtualBlocks(const TestContext& ctx)

@@ -3418,6 +3432,11 @@
             const bool isDefaultHeap = stepInfo.pMoves[i].pSrcAllocation->GetHeap()->GetDesc().Properties.Type == D3D12_HEAP_TYPE_DEFAULT;

             // Create new resource

             D3D12_RESOURCE_DESC desc = stepInfo.pMoves[i].pSrcAllocation->GetResource()->GetDesc();

+

+            // Fix for D3D12 ERROR: ID3D12Device::CreatePlacedResource: D3D12_RESOURCE_DESC::Alignment is invalid. The value is 8. When D3D12_RESOURCE_DESC::Flag bit for D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT is set, Alignment must be 0. [ STATE_CREATION ERROR #721: CREATERESOURCE_INVALIDALIGNMENT]

+            if ((desc.Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY) != 0)

+                desc.Alignment = 0;

+

             ComPtr<ID3D12Resource> dstRes;

             CHECK_HR(ctx.device->CreatePlacedResource(stepInfo.pMoves[i].pDstTmpAllocation->GetHeap(),

                 stepInfo.pMoves[i].pDstTmpAllocation->GetOffset(), &desc,