Disabled preference for creating small buffers as committed when tight alignment is used
diff --git a/include/D3D12MemAlloc.h b/include/D3D12MemAlloc.h index 737e6ae..bb102da 100644 --- a/include/D3D12MemAlloc.h +++ b/include/D3D12MemAlloc.h
@@ -1051,6 +1051,11 @@ which may take longer than creating placed resources in existing heaps. Passing this flag will disable this committed preference globally for the allocator. It can also be disabled for a single allocation by using #ALLOCATION_FLAG_STRATEGY_MIN_TIME. + + If the tight resource alignment feature is used by the library (which happens automatically whenever supported, + unless you use flag #ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT), then small buffers are not preferred as committed. + Long story short, you don't need to specify any of these flags. + The library chooses the most optimal method automatically. */ ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED = 0x10, /** TODO document... */
diff --git a/src/D3D12MemAlloc.cpp b/src/D3D12MemAlloc.cpp index 7eb79f0..d67ac34 100644 --- a/src/D3D12MemAlloc.cpp +++ b/src/D3D12MemAlloc.cpp
@@ -5999,7 +5999,7 @@ const bool m_UseMutex; const bool m_AlwaysCommitted; const bool m_MsaaAlwaysCommitted; - const bool m_PreferSmallBuffersCommitted; + bool m_PreferSmallBuffersCommitted; const bool m_UseTightAlignment; bool m_DefaultPoolsNotZeroed = false; ID3D12Device* m_Device; // AddRef @@ -6192,6 +6192,14 @@ if (SUCCEEDED(hr)) { m_TightAlignmentSupported = tightAlignment.SupportTier >= D3D12_TIGHT_ALIGNMENT_TIER_1; + + // If tight alignment is supported (checked by the code above) and wasn't disabled by the developer + // (with ALLOCATOR_FLAG_DONT_USE_TIGHT_ALIGNMENT), disable the preference for creating small buffers as committed, + // as if ALLOCATOR_FLAG_DONT_PREFER_SMALL_BUFFERS_COMMITTED was specified. + if (IsTightAlignmentEnabled()) + { + m_PreferSmallBuffersCommitted = false; + } } } #endif