Skip to content

Commit 117ff9e

Browse files
Some refactoring after merging #40
1 parent b0316c9 commit 117ff9e

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/D3D12MemAlloc.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6582,6 +6582,8 @@ AllocatorPimpl::AllocatorPimpl(const ALLOCATION_CALLBACKS& allocationCallbacks,
65826582

65836583
HRESULT AllocatorPimpl::Init(const ALLOCATOR_DESC& desc)
65846584
{
6585+
bool notZeroedSupported = false;
6586+
65856587
#if D3D12MA_DXGI_1_4
65866588
desc.pAdapter->QueryInterface(D3D12MA_IID_PPV_ARGS(&m_Adapter3));
65876589
#endif
@@ -6592,6 +6594,12 @@ HRESULT AllocatorPimpl::Init(const ALLOCATOR_DESC& desc)
65926594

65936595
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
65946596
m_Device->QueryInterface(D3D12MA_IID_PPV_ARGS(&m_Device8));
6597+
6598+
D3D12_FEATURE_DATA_D3D12_OPTIONS7 options7 = {};
6599+
if(SUCCEEDED(m_Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &options7, sizeof(options7))))
6600+
{
6601+
notZeroedSupported = true;
6602+
}
65956603
#endif
65966604

65976605
HRESULT hr = m_Adapter->GetDesc(&m_AdapterDesc);
@@ -6616,14 +6624,6 @@ HRESULT AllocatorPimpl::Init(const ALLOCATOR_DESC& desc)
66166624
m_D3D12Architecture.CacheCoherentUMA = FALSE;
66176625
}
66186626

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-
66276627
D3D12_HEAP_PROPERTIES heapProps = {};
66286628
const UINT defaultPoolCount = GetDefaultPoolCount();
66296629
for (UINT i = 0; i < defaultPoolCount; ++i)
@@ -6632,8 +6632,10 @@ HRESULT AllocatorPimpl::Init(const ALLOCATOR_DESC& desc)
66326632
CalcDefaultPoolParams(heapProps.Type, heapFlags, i);
66336633

66346634
#ifdef __ID3D12Device8_INTERFACE_DEFINED__
6635-
if (desc.Flags & ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED)
6636-
heapFlags |= additionalFlags;
6635+
if ((desc.Flags & ALLOCATOR_FLAG_DEFAULT_POOLS_NOT_ZEROED) != 0 && notZeroedSupported)
6636+
{
6637+
heapFlags |= D3D12_HEAP_FLAG_CREATE_NOT_ZEROED;
6638+
}
66376639
#endif
66386640

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

0 commit comments

Comments
 (0)