Skip to content

Commit c06cd9a

Browse files
authored
Merge pull request #85 from sawickiap/master
New updates to D3D12 Memory Allocator
2 parents 2ac8a9b + 07f1e1e commit c06cd9a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/D3D12MemAlloc.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ static const D3D12_HEAP_FLAGS RESOURCE_CLASS_HEAP_FLAGS =
215215
static const D3D12_RESIDENCY_PRIORITY D3D12_RESIDENCY_PRIORITY_NONE = D3D12_RESIDENCY_PRIORITY(0);
216216

217217
static const D3D12_HEAP_TYPE D3D12_HEAP_TYPE_GPU_UPLOAD_COPY = (D3D12_HEAP_TYPE)5;
218+
static const D3D12_RESOURCE_FLAGS D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY = (D3D12_RESOURCE_FLAGS)0x400;
218219

219220
#ifndef _D3D12MA_ENUM_DECLARATIONS
220221

@@ -816,11 +817,9 @@ static bool ValidateAllocateMemoryParameters(
816817
return pAllocDesc &&
817818
pAllocInfo &&
818819
ppAllocation &&
819-
(pAllocInfo->Alignment == 0 ||
820-
pAllocInfo->Alignment == D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT ||
821-
pAllocInfo->Alignment == D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT) &&
822-
pAllocInfo->SizeInBytes != 0 &&
823-
pAllocInfo->SizeInBytes % (64ull * 1024) == 0;
820+
IsPow2(pAllocInfo->Alignment) &&
821+
pAllocInfo->SizeInBytes > 0 &&
822+
pAllocInfo->SizeInBytes % 4 == 0;
824823
}
825824

826825
#endif // _D3D12MA_FUNCTIONS
@@ -7849,6 +7848,7 @@ HRESULT AllocatorPimpl::GetResourceAllocationInfo(
78497848

78507849
#if D3D12MA_USE_SMALL_RESOURCE_PLACEMENT_ALIGNMENT
78517850
if (inOutResourceDesc.Alignment == 0 &&
7851+
(inOutResourceDesc.Flags & D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT_COPY) == 0 &&
78527852
(inOutResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE1D ||
78537853
inOutResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D ||
78547854
inOutResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D) &&
@@ -9878,7 +9878,7 @@ HRESULT Allocator::AllocateMemory(
98789878
return E_INVALIDARG;
98799879
}
98809880
D3D12MA_DEBUG_GLOBAL_MUTEX_LOCK
9881-
return m_Pimpl->AllocateMemory(pAllocDesc, pAllocInfo, ppAllocation);
9881+
return m_Pimpl->AllocateMemory(pAllocDesc, pAllocInfo, ppAllocation);
98829882
}
98839883

98849884
HRESULT Allocator::CreateAliasingResource(

src/D3D12Sample.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,8 @@ static void PrintAdapterInformation(IDXGIAdapter1* adapter)
605605
assert(0);
606606
}
607607

608-
wprintf(L"D3D12_FEATURE_DATA_D3D12_OPTIONS16:\n");
609-
wprintf(L" GPUUploadHeapSupported = %u\n", g_Allocator->IsGPUUploadHeapSupported() ? 1 : 0);
608+
wprintf(L"GPUUploadHeapSupported = %u\n", g_Allocator->IsGPUUploadHeapSupported() ? 1 : 0);
609+
wprintf(L"TightAlignmentSupported = %u\n", g_Allocator->IsTightAlignmentSupported() ? 1 : 0);
610610

611611
ComPtr<IDXGIAdapter3> adapter3;
612612
if(SUCCEEDED(adapter->QueryInterface(IID_PPV_ARGS(&adapter3))))

0 commit comments

Comments
 (0)