#include <AllocatorVk.h>
|
| Allocation_T (uint32_t currentFrameIndex, bool userDataString) |
|
| ~Allocation_T () |
|
void | InitBlockAllocation (Pool hPool, DeviceMemoryBlock *block, VkDeviceSize offset, VkDeviceSize alignment, VkDeviceSize size, SuballocationType suballocationType, bool mapped, bool canBecomeLost) |
|
void | InitLost () |
|
void | ChangeBlockAllocation (Allocator hAllocator, DeviceMemoryBlock *block, VkDeviceSize offset) |
|
void | InitDedicatedAllocation (uint32_t memoryTypeIndex, VkDeviceMemory hMemory, SuballocationType suballocationType, void *pMappedData, VkDeviceSize size) |
|
ALLOCATION_TYPE | GetType () const |
|
VkDeviceSize | GetAlignment () const |
|
VkDeviceSize | GetSize () const |
|
bool | IsUserDataString () const |
|
void * | GetUserData () const |
|
void | SetUserData (Allocator hAllocator, void *pUserData) |
|
SuballocationType | GetSuballocationType () const |
|
uint8_t | GetMapCount () const |
|
uint8_t | GetFlags () const |
|
DeviceMemoryBlock * | GetBlock () const |
|
VkDeviceSize | GetOffset () const |
|
VkDeviceMemory | GetMemory () const |
|
uint32_t | GetMemoryTypeIndex () const |
|
bool | IsPersistentMap () const |
|
void * | GetMappedData () const |
|
bool | CanBecomeLost () const |
|
Pool | GetPool () const |
|
uint32_t | GetLastUseFrameIndex () const |
|
bool | CompareExchangeLastUseFrameIndex (uint32_t &expected, uint32_t desired) |
|
bool | MakeLost (uint32_t currentFrameIndex, uint32_t frameInUseCount) |
|
void | DedicatedAllocCalcStatsInfo (StatInfo &outInfo) |
|
void | BlockAllocMap () |
|
void | BlockAllocUnmap () |
|
VkResult | DedicatedAllocMap (Allocator hAllocator, void **ppData) |
|
void | DedicatedAllocUnmap (Allocator hAllocator) |
|
char * | __rep__ (bool remove=false) |
|
Definition at line 1108 of file AllocatorVk.h.
◆ ALLOCATION_TYPE
Enumerator |
---|
ALLOCATION_TYPE_NONE | |
ALLOCATION_TYPE_BLOCK | |
ALLOCATION_TYPE_DEDICATED | |
ALLOCATION_TYPE_BLOCK_DEDICATED | |
Definition at line 1124 of file AllocatorVk.h.
1125 {
1130 };
@ ALLOCATION_TYPE_DEDICATED
@ ALLOCATION_TYPE_BLOCK_DEDICATED
◆ Allocation_T()
vkmm::Allocation_T::Allocation_T |
( |
uint32_t |
currentFrameIndex, |
|
|
bool |
userDataString |
|
) |
| |
|
inline |
Definition at line 1134 of file AllocatorVk.h.
1134 :
1136 m_Alignment(1),
1137 m_Size(0),
1139 m_LastUseFrameIndex(currentFrameIndex),
1142 m_MapCount(0),
1143 m_Flags(userDataString ? (uint8_t)FLAG_USER_DATA_STRING : 0)
1144 {
1145#if VMA_STATS_STRING_ENABLED
1146 m_CreationFrameIndex = currentFrameIndex;
1147 m_BufferImageUsage = 0;
1148#endif
1149 }
@ SUBALLOCATION_TYPE_UNKNOWN
◆ ~Allocation_T()
vkmm::Allocation_T::~Allocation_T |
( |
| ) |
|
|
inline |
Definition at line 1167 of file AllocatorVk.h.
1168 {
1169 assert((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) == 0 && "Allocation was not unmapped before destruction.");
1170
1171
1173 }
◆ __rep__()
char * vkmm::Allocation_T::__rep__ |
( |
bool |
remove = false | ) |
|
|
inline |
Definition at line 1290 of file AllocatorVk.h.
1290 {
1291
1292 static char msg[512];
1293 memset(msg, 1, sizeof(msg));
1294
1295 if (remove) {
1296 sprintf_s(msg, "DELETE %s :: addr[%p] \n memoryType %u align:%zu size:%zu \n",
1300 m_Alignment,
1301 m_Size);
1302 }
1303 else {
1304 sprintf_s(msg, "NEW %s :: addr[%p] \n memoryType %u align:%zu size:%zu \n",
1308 m_Alignment,
1309 m_Size);
1310 }
1311 return msg;
1312
1313 }
DedicatedAllocation m_DedicatedAllocation
◆ BlockAllocMap()
void vkmm::Allocation_T::BlockAllocMap |
( |
| ) |
|
◆ BlockAllocUnmap()
void vkmm::Allocation_T::BlockAllocUnmap |
( |
| ) |
|
◆ CanBecomeLost()
bool vkmm::Allocation_T::CanBecomeLost |
( |
| ) |
const |
Definition at line 760 of file AllocatorVk.cpp.
761 {
762 switch (m_Type)
763 {
767 return false;
768 default:
769 assert(0);
770 return false;
771 }
772
773 }
BlockAllocation m_BlockAllocation
◆ ChangeBlockAllocation()
void vkmm::Allocation_T::ChangeBlockAllocation |
( |
Allocator |
hAllocator, |
|
|
DeviceMemoryBlock * |
block, |
|
|
VkDeviceSize |
offset |
|
) |
| |
◆ CompareExchangeLastUseFrameIndex()
bool vkmm::Allocation_T::CompareExchangeLastUseFrameIndex |
( |
uint32_t & |
expected, |
|
|
uint32_t |
desired |
|
) |
| |
|
inline |
Definition at line 1266 of file AllocatorVk.h.
1267 {
1268 return m_LastUseFrameIndex.compare_exchange_weak(expected, desired);
1269 }
◆ DedicatedAllocCalcStatsInfo()
void vkmm::Allocation_T::DedicatedAllocCalcStatsInfo |
( |
StatInfo & |
outInfo | ) |
|
|
inline |
Definition at line 1272 of file AllocatorVk.h.
1273 {
1275 outInfo.blockCount = 1;
1276 outInfo.allocationCount = 1;
1277 outInfo.unusedRangeCount = 0;
1278 outInfo.usedBytes = m_Size;
1279 outInfo.unusedBytes = 0;
1280 outInfo.allocationSizeMin = outInfo.allocationSizeMax = m_Size;
1281 outInfo.unusedRangeSizeMin = UINT64_MAX;
1282 outInfo.unusedRangeSizeMax = 0;
1283 }
◆ DedicatedAllocMap()
VkResult vkmm::Allocation_T::DedicatedAllocMap |
( |
Allocator |
hAllocator, |
|
|
void ** |
ppData |
|
) |
| |
Definition at line 1707 of file AllocatorVk.cpp.
1708 {
1710
1711 if (m_MapCount != 0)
1712 {
1713 if ((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) < 0x7F)
1714 {
1717
1718 m_MapCount = 1;
1719 return VK_SUCCESS;
1720 }
1721 else
1722 {
1723 assert(0 && "Dedicated allocation mapped too many times simultaneously.");
1724 return VK_ERROR_MEMORY_MAP_FAILED;
1725 }
1726 }
1727 else
1728 {
1729 VkResult result = vkMapMemory(
1730 hAllocator->m_hDevice,
1732 0,
1733 VK_WHOLE_SIZE,
1734 0,
1735 ppData);
1736 if (result == VK_SUCCESS)
1737 {
1739 m_MapCount = 1;
1740 }
1741 return result;
1742 }
1743 }
ALLOCATION_TYPE GetType() const
◆ DedicatedAllocUnmap()
void vkmm::Allocation_T::DedicatedAllocUnmap |
( |
Allocator |
hAllocator | ) |
|
Definition at line 1744 of file AllocatorVk.cpp.
1745 {
1747
1748 if ((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) != 0)
1749 {
1750 --m_MapCount;
1751 if (m_MapCount == 0)
1752 {
1754 vkUnmapMemory(
1755 hAllocator->m_hDevice,
1757 }
1758 }
1759 else
1760 {
1761 log_allo(
"Unmapping dedicated allocation not previously mapped.");
1762 }
1763 }
◆ GetAlignment()
VkDeviceSize vkmm::Allocation_T::GetAlignment |
( |
| ) |
const |
|
inline |
◆ GetBlock()
DeviceMemoryBlock * vkmm::Allocation_T::GetBlock |
( |
| ) |
const |
|
inline |
◆ GetFlags()
uint8_t vkmm::Allocation_T::GetFlags |
( |
| ) |
const |
|
inline |
◆ GetLastUseFrameIndex()
uint32_t vkmm::Allocation_T::GetLastUseFrameIndex |
( |
| ) |
const |
|
inline |
Definition at line 1262 of file AllocatorVk.h.
1263 {
1264 return m_LastUseFrameIndex.load();
1265 }
◆ GetMapCount()
uint8_t vkmm::Allocation_T::GetMapCount |
( |
| ) |
const |
|
inline |
Definition at line 1243 of file AllocatorVk.h.
1243 {
1244 return m_MapCount;
1245 };
◆ GetMappedData()
void * vkmm::Allocation_T::GetMappedData |
( |
| ) |
const |
Definition at line 817 of file AllocatorVk.cpp.
818 {
819 switch (m_Type)
820 {
822
823
824
825
826
827
828
829
830
831
832
833
834 break;
838 default:
839 assert(0);
840 return nullptr;
841 }
842 return nullptr;
843 }
◆ GetMemory()
VkDeviceMemory vkmm::Allocation_T::GetMemory |
( |
| ) |
const |
COM return m_BlockAllocation.m_Block->GetDeviceMemory();
Definition at line 789 of file AllocatorVk.cpp.
790 {
791 switch (m_Type)
792 {
797 default:
798 assert(0);
799 return VK_NULL_HANDLE;
800 }
801 }
◆ GetMemoryTypeIndex()
uint32_t vkmm::Allocation_T::GetMemoryTypeIndex |
( |
| ) |
const |
COM return m_BlockAllocation.m_Block->GetMemoryTypeIndex();
Definition at line 803 of file AllocatorVk.cpp.
804 {
805 switch (m_Type)
806 {
811 default:
812 assert(0);
813 return UINT32_MAX;
814 }
815 }
◆ GetOffset()
VkDeviceSize vkmm::Allocation_T::GetOffset |
( |
| ) |
const |
COM return m_BlockAllocation.m_Offset;
Definition at line 775 of file AllocatorVk.cpp.
776 {
777 switch (m_Type)
778 {
782 return 0;
783 default:
784 assert(0);
785 return 0;
786 }
787 }
◆ GetPool()
Pool vkmm::Allocation_T::GetPool |
( |
| ) |
const |
◆ GetSize()
VkDeviceSize vkmm::Allocation_T::GetSize |
( |
| ) |
const |
|
inline |
◆ GetSuballocationType()
◆ GetType()
◆ GetUserData()
void * vkmm::Allocation_T::GetUserData |
( |
| ) |
const |
|
inline |
◆ InitBlockAllocation()
void vkmm::Allocation_T::InitBlockAllocation |
( |
Pool |
hPool, |
|
|
DeviceMemoryBlock * |
block, |
|
|
VkDeviceSize |
offset, |
|
|
VkDeviceSize |
alignment, |
|
|
VkDeviceSize |
size, |
|
|
SuballocationType |
suballocationType, |
|
|
bool |
mapped, |
|
|
bool |
canBecomeLost |
|
) |
| |
|
inline |
Definition at line 1175 of file AllocatorVk.h.
1184 {
1186 assert(block != nullptr);
1188 m_Alignment = alignment;
1189 m_Size = size;
1190 m_MapCount = mapped ? MAP_COUNT_FLAG_PERSISTENT_MAP : 0;
1191 m_SuballocationType = (uint8_t)suballocationType;
1196 }
◆ InitDedicatedAllocation()
void vkmm::Allocation_T::InitDedicatedAllocation |
( |
uint32_t |
memoryTypeIndex, |
|
|
VkDeviceMemory |
hMemory, |
|
|
SuballocationType |
suballocationType, |
|
|
void * |
pMappedData, |
|
|
VkDeviceSize |
size |
|
) |
| |
|
inline |
Definition at line 1215 of file AllocatorVk.h.
1221 {
1223 assert(hMemory != VK_NULL_HANDLE);
1225 m_Alignment = 0;
1226 m_Size = size;
1227 m_SuballocationType = (uint8_t)suballocationType;
1228 m_MapCount = (pMappedData != nullptr) ? MAP_COUNT_FLAG_PERSISTENT_MAP : 0;
1232 }
◆ InitLost()
void vkmm::Allocation_T::InitLost |
( |
| ) |
|
|
inline |
Definition at line 1198 of file AllocatorVk.h.
1199 {
1201 assert(m_LastUseFrameIndex.load() == FRAME_INDEX_LOST);
1207 }
◆ IsPersistentMap()
bool vkmm::Allocation_T::IsPersistentMap |
( |
| ) |
const |
|
inline |
Definition at line 1257 of file AllocatorVk.h.
1257{ return (m_MapCount & MAP_COUNT_FLAG_PERSISTENT_MAP) != 0; }
◆ IsUserDataString()
bool vkmm::Allocation_T::IsUserDataString |
( |
| ) |
const |
|
inline |
Definition at line 1239 of file AllocatorVk.h.
1239{ return (m_Flags & FLAG_USER_DATA_STRING) != 0; }
◆ MakeLost()
bool vkmm::Allocation_T::MakeLost |
( |
uint32_t |
currentFrameIndex, |
|
|
uint32_t |
frameInUseCount |
|
) |
| |
◆ SetUserData()
void vkmm::Allocation_T::SetUserData |
( |
Allocator |
hAllocator, |
|
|
void * |
pUserData |
|
) |
| |
Definition at line 553 of file AllocatorVk.cpp.
554 {
556 {
557 assert(pUserData ==
nullptr || pUserData !=
m_pUserData);
558
559 FreeUserDataString(hAllocator);
560
561 if (pUserData != nullptr)
562 {
563 const char* const newStrSrc = (char*)pUserData;
564 const size_t newStrLen = strlen(newStrSrc);
565 char*
const newStrDst =
vkmm_new_array(hAllocator,
char, newStrLen + 1);
566 memcpy(newStrDst, newStrSrc, newStrLen + 1);
568 }
569 }
570 else
571 {
573 }
574 }
#define vkmm_new_array(allocator, type, count)
bool IsUserDataString() const
◆ ID
const int vkmm::Allocation_T::ID |
◆ m_BlockAllocation
BlockAllocation vkmm::Allocation_T::m_BlockAllocation |
◆ m_DedicatedAllocation
DedicatedAllocation vkmm::Allocation_T::m_DedicatedAllocation |
◆ m_pUserData
void* vkmm::Allocation_T::m_pUserData |
◆ name
char vkmm::Allocation_T::name[16] |
The documentation for this struct was generated from the following files: