Skip to content

Commit b0316c9

Browse files
Merge pull request #40 from kingofthebongo2008/fix-for-memory-zeroed-flag
Add Runtime support check for D3D12_HEAP_FLAG_CREATE_NOT_ZEROED
2 parents d6ff05e + 1832eac commit b0316c9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/D3D12MemAlloc.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6616,6 +6616,14 @@ HRESULT AllocatorPimpl::Init(const ALLOCATOR_DESC& desc)
66166616
m_D3D12Architecture.CacheCoherentUMA = FALSE;
66176617
}
66186618

6619+
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
6620+
D3D12_FEATURE_DATA_D3D12_OPTIONS7 o = {};
6621+
hr = m_Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &o, sizeof(o));
6622+
D3D12_HEAP_FLAGS additionalFlags = (hr == S_OK) ? D3D12_HEAP_FLAG_CREATE_NOT_ZEROED : D3D12_HEAP_FLAG_NONE;
6623+
#else
6624+
constexpr D3D12_HEAP_FLAGS additionalFlags = D3D12_HEAP_FLAG_NONE;
6625+
#endif
6626+
66196627
D3D12_HEAP_PROPERTIES heapProps = {};
66206628
const UINT defaultPoolCount = GetDefaultPoolCount();
66216629
for (UINT i = 0; i < defaultPoolCount; ++i)
@@ -6625,7 +6633,7 @@ HRESULT AllocatorPimpl::Init(const ALLOCATOR_DESC& desc)
66256633

66266634
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
66276635
if (desc.Flags & ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED)
6628-
heapFlags |= D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
6636+
heapFlags |= additionalFlags;
66296637
#endif
66306638

66316639
m_BlockVectors[i] = D3D12MA_NEW(GetAllocs(), BlockVector)(

0 commit comments

Comments
 (0)