mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/D3D12MemoryAllocator.git
synced 2024-11-21 19:50:05 +00:00
Fixed bug in BuildStatsString when Resource Heap Tier 2 is not supported
Other changes pulled from branch feature-gpu-upload-heaps (without pulling the main feature).
This commit is contained in:
commit
8730bb40bb
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
/** \mainpage D3D12 Memory Allocator
|
/** \mainpage D3D12 Memory Allocator
|
||||||
|
|
||||||
<b>Version 2.1.0-development</b> (2022-12-15)
|
<b>Version 2.1.0-development</b> (2023-07-05)
|
||||||
|
|
||||||
Copyright (c) 2019-2022 Advanced Micro Devices, Inc. All rights reserved. \n
|
Copyright (c) 2019-2023 Advanced Micro Devices, Inc. All rights reserved. \n
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
||||||
Documentation of all members: D3D12MemAlloc.h
|
Documentation of all members: D3D12MemAlloc.h
|
||||||
@ -1333,7 +1333,7 @@ public:
|
|||||||
- `pNonLocalBudget` returns the budget of the system memory available for D3D12 resources.
|
- `pNonLocalBudget` returns the budget of the system memory available for D3D12 resources.
|
||||||
- When IsUMA() `== TRUE` (integrated graphics chip):
|
- When IsUMA() `== TRUE` (integrated graphics chip):
|
||||||
- `pLocalBudget` returns the budget of the shared memory available for all D3D12 resources.
|
- `pLocalBudget` returns the budget of the shared memory available for all D3D12 resources.
|
||||||
All memory is considered "local".
|
All memory is considered "local".
|
||||||
- `pNonLocalBudget` is not applicable and returns zeros.
|
- `pNonLocalBudget` is not applicable and returns zeros.
|
||||||
|
|
||||||
This function is called "get" not "calculate" because it is very fast, suitable to be called
|
This function is called "get" not "calculate" because it is very fast, suitable to be called
|
||||||
|
@ -126,3 +126,27 @@ if(D3D12MA_BUILD_SAMPLE)
|
|||||||
message(STATUS "D3D12Sample application is not supported to Linux")
|
message(STATUS "D3D12Sample application is not supported to Linux")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(D3D12MA_AGILITY_SDK_DIRECTORY "" CACHE STRING "Path to unpacked DX12 Agility SDK. Leave empty to compile without it.")
|
||||||
|
option(D3D12MA_AGILITY_SDK_PREVIEW "Set if DX12 Agility SDK is preview version." OFF)
|
||||||
|
if(D3D12MA_AGILITY_SDK_DIRECTORY)
|
||||||
|
if(EXISTS "${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include/d3d12.h")
|
||||||
|
message(STATUS "DX12 Agility SDK used from \"${D3D12MA_AGILITY_SDK_DIRECTORY}\".")
|
||||||
|
target_compile_definitions(D3D12MemoryAllocator PRIVATE D3D12MA_USE_AGILITY_SDK=1)
|
||||||
|
target_include_directories(D3D12MemoryAllocator BEFORE PRIVATE "${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include")
|
||||||
|
if(D3D12MA_AGILITY_SDK_PREVIEW)
|
||||||
|
target_compile_definitions(D3D12MemoryAllocator PRIVATE D3D12MA_USE_AGILITY_SDK_PREVIEW=1)
|
||||||
|
endif()
|
||||||
|
if(${D3D12MA_BUILD_SAMPLE} AND ${WIN32})
|
||||||
|
target_compile_definitions(D3D12Sample PRIVATE D3D12MA_USE_AGILITY_SDK=1)
|
||||||
|
target_include_directories(D3D12Sample BEFORE PRIVATE "${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include")
|
||||||
|
if(D3D12MA_AGILITY_SDK_PREVIEW)
|
||||||
|
target_compile_definitions(D3D12Sample PRIVATE D3D12MA_USE_AGILITY_SDK_PREVIEW=1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "DX12 Agility SDK not found - cannot find file \"${D3D12MA_AGILITY_SDK_DIRECTORY}/build/native/include/d3d12.h\".")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "DX12 Agility SDK not used.")
|
||||||
|
endif()
|
||||||
|
@ -148,6 +148,12 @@ static const WCHAR* const HeapTypeNames[] =
|
|||||||
L"READBACK",
|
L"READBACK",
|
||||||
L"CUSTOM",
|
L"CUSTOM",
|
||||||
};
|
};
|
||||||
|
static const WCHAR* const StandardHeapTypeNames[] =
|
||||||
|
{
|
||||||
|
L"DEFAULT",
|
||||||
|
L"UPLOAD",
|
||||||
|
L"READBACK",
|
||||||
|
};
|
||||||
|
|
||||||
static const D3D12_HEAP_FLAGS RESOURCE_CLASS_HEAP_FLAGS =
|
static const D3D12_HEAP_FLAGS RESOURCE_CLASS_HEAP_FLAGS =
|
||||||
D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES;
|
D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES | D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES;
|
||||||
@ -452,23 +458,26 @@ static IterT BinaryFindSorted(const IterT& beg, const IterT& end, const KeyT& va
|
|||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT HeapTypeToIndex(D3D12_HEAP_TYPE type)
|
static UINT StandardHeapTypeToIndex(D3D12_HEAP_TYPE type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case D3D12_HEAP_TYPE_DEFAULT: return 0;
|
case D3D12_HEAP_TYPE_DEFAULT: return 0;
|
||||||
case D3D12_HEAP_TYPE_UPLOAD: return 1;
|
case D3D12_HEAP_TYPE_UPLOAD: return 1;
|
||||||
case D3D12_HEAP_TYPE_READBACK: return 2;
|
case D3D12_HEAP_TYPE_READBACK: return 2;
|
||||||
case D3D12_HEAP_TYPE_CUSTOM: return 3;
|
|
||||||
default: D3D12MA_ASSERT(0); return UINT_MAX;
|
default: D3D12MA_ASSERT(0); return UINT_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static D3D12_HEAP_TYPE IndexToHeapType(UINT heapTypeIndex)
|
static D3D12_HEAP_TYPE IndexToStandardHeapType(UINT heapTypeIndex)
|
||||||
{
|
{
|
||||||
D3D12MA_ASSERT(heapTypeIndex < 4);
|
switch(heapTypeIndex)
|
||||||
// D3D12_HEAP_TYPE_DEFAULT starts at 1.
|
{
|
||||||
return (D3D12_HEAP_TYPE)(heapTypeIndex + 1);
|
case 0: return D3D12_HEAP_TYPE_DEFAULT;
|
||||||
|
case 1: return D3D12_HEAP_TYPE_UPLOAD;
|
||||||
|
case 2: return D3D12_HEAP_TYPE_READBACK;
|
||||||
|
default: D3D12MA_ASSERT(0); return D3D12_HEAP_TYPE_CUSTOM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static UINT64 HeapFlagsToAlignment(D3D12_HEAP_FLAGS flags, bool denyMsaaTextures)
|
static UINT64 HeapFlagsToAlignment(D3D12_HEAP_FLAGS flags, bool denyMsaaTextures)
|
||||||
@ -6625,8 +6634,8 @@ public:
|
|||||||
void SetResidencyPriority(ID3D12Pageable* obj, D3D12_RESIDENCY_PRIORITY priority) const;
|
void SetResidencyPriority(ID3D12Pageable* obj, D3D12_RESIDENCY_PRIORITY priority) const;
|
||||||
|
|
||||||
void SetCurrentFrameIndex(UINT frameIndex);
|
void SetCurrentFrameIndex(UINT frameIndex);
|
||||||
// For more deailed stats use outCutomHeaps to access statistics divided into L0 and L1 group
|
// For more deailed stats use outCustomHeaps to access statistics divided into L0 and L1 group
|
||||||
void CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCutomHeaps[2] = NULL);
|
void CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCustomHeaps[2] = NULL);
|
||||||
|
|
||||||
void GetBudget(Budget* outLocalBudget, Budget* outNonLocalBudget);
|
void GetBudget(Budget* outLocalBudget, Budget* outNonLocalBudget);
|
||||||
void GetBudgetForHeapType(Budget& outBudget, D3D12_HEAP_TYPE heapType);
|
void GetBudgetForHeapType(Budget& outBudget, D3D12_HEAP_TYPE heapType);
|
||||||
@ -6747,7 +6756,7 @@ AllocatorPimpl::AllocatorPimpl(const ALLOCATION_CALLBACKS& allocationCallbacks,
|
|||||||
{
|
{
|
||||||
m_CommittedAllocations[i].Init(
|
m_CommittedAllocations[i].Init(
|
||||||
m_UseMutex,
|
m_UseMutex,
|
||||||
(D3D12_HEAP_TYPE)(D3D12_HEAP_TYPE_DEFAULT + i),
|
IndexToStandardHeapType(i),
|
||||||
NULL); // pool
|
NULL); // pool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7253,7 +7262,7 @@ void AllocatorPimpl::SetCurrentFrameIndex(UINT frameIndex)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCutomHeaps[2])
|
void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStatistics outCustomHeaps[2])
|
||||||
{
|
{
|
||||||
// Init stats
|
// Init stats
|
||||||
for (size_t i = 0; i < HEAP_TYPE_COUNT; i++)
|
for (size_t i = 0; i < HEAP_TYPE_COUNT; i++)
|
||||||
@ -7261,10 +7270,10 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
|
|||||||
for (size_t i = 0; i < DXGI_MEMORY_SEGMENT_GROUP_COUNT; i++)
|
for (size_t i = 0; i < DXGI_MEMORY_SEGMENT_GROUP_COUNT; i++)
|
||||||
ClearDetailedStatistics(outStats.MemorySegmentGroup[i]);
|
ClearDetailedStatistics(outStats.MemorySegmentGroup[i]);
|
||||||
ClearDetailedStatistics(outStats.Total);
|
ClearDetailedStatistics(outStats.Total);
|
||||||
if (outCutomHeaps)
|
if (outCustomHeaps)
|
||||||
{
|
{
|
||||||
ClearDetailedStatistics(outCutomHeaps[0]);
|
ClearDetailedStatistics(outCustomHeaps[0]);
|
||||||
ClearDetailedStatistics(outCutomHeaps[1]);
|
ClearDetailedStatistics(outCustomHeaps[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process default pools. 3 standard heap types only. Add them to outStats.HeapType[i].
|
// Process default pools. 3 standard heap types only. Add them to outStats.HeapType[i].
|
||||||
@ -7321,8 +7330,8 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
|
|||||||
AddDetailedStatistics(
|
AddDetailedStatistics(
|
||||||
outStats.MemorySegmentGroup[memorySegment], tmpStats);
|
outStats.MemorySegmentGroup[memorySegment], tmpStats);
|
||||||
|
|
||||||
if (outCutomHeaps)
|
if (outCustomHeaps)
|
||||||
AddDetailedStatistics(outCutomHeaps[memorySegment], tmpStats);
|
AddDetailedStatistics(outCustomHeaps[memorySegment], tmpStats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7334,7 +7343,7 @@ void AllocatorPimpl::CalculateStatistics(TotalStatistics& outStats, DetailedStat
|
|||||||
AddDetailedStatistics(
|
AddDetailedStatistics(
|
||||||
outStats.HeapType[heapTypeIndex], tmpStats);
|
outStats.HeapType[heapTypeIndex], tmpStats);
|
||||||
AddDetailedStatistics(
|
AddDetailedStatistics(
|
||||||
outStats.MemorySegmentGroup[StandardHeapTypeToMemorySegmentGroup(IndexToHeapType(heapTypeIndex))], tmpStats);
|
outStats.MemorySegmentGroup[StandardHeapTypeToMemorySegmentGroup(IndexToStandardHeapType(heapTypeIndex))], tmpStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum up memory segment groups to totals.
|
// Sum up memory segment groups to totals.
|
||||||
@ -7678,7 +7687,7 @@ void AllocatorPimpl::BuildStatsString(WCHAR** ppStatsString, BOOL detailedMap)
|
|||||||
{
|
{
|
||||||
for (uint8_t heapType = 0; heapType < STANDARD_HEAP_TYPE_COUNT; ++heapType)
|
for (uint8_t heapType = 0; heapType < STANDARD_HEAP_TYPE_COUNT; ++heapType)
|
||||||
{
|
{
|
||||||
json.WriteString(HeapTypeNames[heapType]);
|
json.WriteString(StandardHeapTypeNames[heapType]);
|
||||||
json.BeginObject();
|
json.BeginObject();
|
||||||
writeHeapInfo(m_BlockVectors[heapType], m_CommittedAllocations + heapType, false);
|
writeHeapInfo(m_BlockVectors[heapType], m_CommittedAllocations + heapType, false);
|
||||||
json.EndObject();
|
json.EndObject();
|
||||||
@ -7695,11 +7704,11 @@ void AllocatorPimpl::BuildStatsString(WCHAR** ppStatsString, BOOL detailedMap)
|
|||||||
L" - Textures",
|
L" - Textures",
|
||||||
L" - Textures RT/DS",
|
L" - Textures RT/DS",
|
||||||
};
|
};
|
||||||
json.BeginString(HeapTypeNames[heapType]);
|
json.BeginString(StandardHeapTypeNames[heapType]);
|
||||||
json.EndString(heapSubTypeName[heapSubType]);
|
json.EndString(heapSubTypeName[heapSubType]);
|
||||||
|
|
||||||
json.BeginObject();
|
json.BeginObject();
|
||||||
writeHeapInfo(m_BlockVectors[heapType + heapSubType], m_CommittedAllocations + heapType, false);
|
writeHeapInfo(m_BlockVectors[heapType * 3 + heapSubType], m_CommittedAllocations + heapType, false);
|
||||||
json.EndObject();
|
json.EndObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8014,7 +8023,7 @@ HRESULT AllocatorPimpl::CalcAllocationParams(const ALLOCATION_DESC& allocDesc, U
|
|||||||
|
|
||||||
outCommittedAllocationParams.m_HeapProperties = StandardHeapTypeToHeapProperties(allocDesc.HeapType);
|
outCommittedAllocationParams.m_HeapProperties = StandardHeapTypeToHeapProperties(allocDesc.HeapType);
|
||||||
outCommittedAllocationParams.m_HeapFlags = allocDesc.ExtraHeapFlags;
|
outCommittedAllocationParams.m_HeapFlags = allocDesc.ExtraHeapFlags;
|
||||||
outCommittedAllocationParams.m_List = &m_CommittedAllocations[HeapTypeToIndex(allocDesc.HeapType)];
|
outCommittedAllocationParams.m_List = &m_CommittedAllocations[StandardHeapTypeToIndex(allocDesc.HeapType)];
|
||||||
// outCommittedAllocationParams.m_ResidencyPriority intentionally left with default value.
|
// outCommittedAllocationParams.m_ResidencyPriority intentionally left with default value.
|
||||||
|
|
||||||
const ResourceClass resourceClass = (resDesc != NULL) ?
|
const ResourceClass resourceClass = (resDesc != NULL) ?
|
||||||
@ -8150,7 +8159,7 @@ void AllocatorPimpl::CalcDefaultPoolParams(D3D12_HEAP_TYPE& outHeapType, D3D12_H
|
|||||||
|
|
||||||
void AllocatorPimpl::RegisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
|
void AllocatorPimpl::RegisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
|
||||||
{
|
{
|
||||||
const UINT heapTypeIndex = HeapTypeToIndex(heapType);
|
const UINT heapTypeIndex = (UINT)heapType - 1;
|
||||||
|
|
||||||
MutexLockWrite lock(m_PoolsMutex[heapTypeIndex], m_UseMutex);
|
MutexLockWrite lock(m_PoolsMutex[heapTypeIndex], m_UseMutex);
|
||||||
m_Pools[heapTypeIndex].PushBack(pool->m_Pimpl);
|
m_Pools[heapTypeIndex].PushBack(pool->m_Pimpl);
|
||||||
@ -8158,7 +8167,7 @@ void AllocatorPimpl::RegisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
|
|||||||
|
|
||||||
void AllocatorPimpl::UnregisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
|
void AllocatorPimpl::UnregisterPool(Pool* pool, D3D12_HEAP_TYPE heapType)
|
||||||
{
|
{
|
||||||
const UINT heapTypeIndex = HeapTypeToIndex(heapType);
|
const UINT heapTypeIndex = (UINT)heapType - 1;
|
||||||
|
|
||||||
MutexLockWrite lock(m_PoolsMutex[heapTypeIndex], m_UseMutex);
|
MutexLockWrite lock(m_PoolsMutex[heapTypeIndex], m_UseMutex);
|
||||||
m_Pools[heapTypeIndex].Remove(pool->m_Pimpl);
|
m_Pools[heapTypeIndex].Remove(pool->m_Pimpl);
|
||||||
|
@ -35,6 +35,15 @@ namespace PS
|
|||||||
#include "Shaders\PS_Compiled.h"
|
#include "Shaders\PS_Compiled.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if D3D12MA_USE_AGILITY_SDK
|
||||||
|
#if D3D12MA_USE_AGILITY_SDK_PREVIEW
|
||||||
|
extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_PREVIEW_SDK_VERSION; }
|
||||||
|
#else
|
||||||
|
extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = D3D12_SDK_VERSION; }
|
||||||
|
#endif
|
||||||
|
extern "C" { __declspec(dllexport) extern const char* D3D12SDKPath = u8".\\D3D12\\"; }
|
||||||
|
#endif
|
||||||
|
|
||||||
enum class ExitCode : int
|
enum class ExitCode : int
|
||||||
{
|
{
|
||||||
GPUList = 2,
|
GPUList = 2,
|
||||||
|
Loading…
Reference in New Issue
Block a user