Skip to content

Commit 49defd6

Browse files
Further development of custom pool names
1 parent a020fb8 commit 49defd6

3 files changed

Lines changed: 25 additions & 17 deletions

File tree

src/Tests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,8 +3113,6 @@ static void TestPool_SameSize()
31133113
vmaGetPoolName(g_hAllocator, pool, &fetchedPoolName);
31143114
TEST(strcmp(fetchedPoolName, POOL_NAME) == 0);
31153115

3116-
SaveAllocatorStatsToFile(L"TEST.json");//DELME
3117-
31183116
vmaSetPoolName(g_hAllocator, pool, nullptr);
31193117
}
31203118

src/vk_mem_alloc.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,14 +2512,21 @@ Possible return values:
25122512
*/
25132513
VMA_CALL_PRE VkResult VMA_CALL_POST vmaCheckPoolCorruption(VmaAllocator allocator, VmaPool pool);
25142514

2515-
/** TODO
2515+
/** \brief Retrieves name of a custom pool.
2516+
2517+
After the call `ppName` is either null or points to an internally-owned null-terminated string
2518+
containing name of the pool that was previously set. The pointer becomes invalid when the pool is
2519+
destroyed or its name is changed using vmaSetPoolName().
25162520
*/
25172521
VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolName(
25182522
VmaAllocator allocator,
25192523
VmaPool pool,
25202524
const char** ppName);
25212525

2522-
/* TODO
2526+
/* \brief Sets name of a custom pool.
2527+
2528+
`pName` can be either null or pointer to a null-terminated string with new name for the pool.
2529+
Function makes internal copy of the string, so it can be changed or freed immediately after this call.
25232530
*/
25242531
VMA_CALL_PRE void VMA_CALL_POST vmaSetPoolName(
25252532
VmaAllocator allocator,
@@ -12418,6 +12425,13 @@ void VmaBlockVector::PrintDetailedMap(class VmaJsonWriter& json)
1241812425

1241912426
if(m_IsCustomPool)
1242012427
{
12428+
const char* poolName = m_hParentPool->GetName();
12429+
if(poolName != VMA_NULL && poolName[0] != '\0')
12430+
{
12431+
json.WriteString("Name");
12432+
json.WriteString(poolName);
12433+
}
12434+
1242112435
json.WriteString("MemoryTypeIndex");
1242212436
json.WriteNumber(m_MemoryTypeIndex);
1242312437

@@ -15819,15 +15833,6 @@ void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json)
1581915833
{
1582015834
json.BeginString();
1582115835
json.ContinueString(m_Pools[poolIndex]->GetId());
15822-
const char* poolName = m_Pools[poolIndex]->GetName();
15823-
if(poolName != VMA_NULL && poolName[0] != '\0')
15824-
{
15825-
json.ContinueString(" ");
15826-
json.ContinueString(poolName);
15827-
}
15828-
else
15829-
{
15830-
}
1583115836
json.EndString();
1583215837

1583315838
m_Pools[poolIndex]->m_BlockVector.PrintDetailedMap(json);

tools/VmaDumpVis/VmaDumpVis.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,18 @@ def BytesToStr(iBytes):
189189
ProcessBlock(typeData['DefaultPoolBlocks'], int(sBlockId), objBlock, '')
190190
if 'Pools' in jsonSrc:
191191
objPools = jsonSrc['Pools']
192-
for sPoolName, objPool in objPools.items():
192+
for sPoolId, objPool in objPools.items():
193193
iType = int(objPool['MemoryTypeIndex'])
194194
typeData = GetDataForMemoryType(iType)
195195
objBlocks = objPool['Blocks']
196196
sAlgorithm = objPool.get('Algorithm', '')
197+
sName = objPool.get('Name', None)
198+
if sName:
199+
sFullName = sPoolId + ' "' + sName + '"'
200+
else:
201+
sFullName = sPoolId
197202
dstBlockArray = []
198-
typeData['CustomPools'][sPoolName] = dstBlockArray
203+
typeData['CustomPools'][sFullName] = dstBlockArray
199204
for sBlockId, objBlock in objBlocks.items():
200205
ProcessBlock(dstBlockArray, int(sBlockId), objBlock, sAlgorithm)
201206

@@ -255,7 +260,7 @@ def BytesToStr(iBytes):
255260
sAlgorithm = ' (Algorithm: %s)' % (objBlock['Algorithm'])
256261
else:
257262
sAlgorithm = ''
258-
draw.text((IMG_MARGIN, y), "Custom pool \"%s\"%s block %d" % (sPoolName, sAlgorithm, objBlock['ID']), fill=COLOR_TEXT_H2, font=font)
263+
draw.text((IMG_MARGIN, y), "Custom pool %s%s block %d" % (sPoolName, sAlgorithm, objBlock['ID']), fill=COLOR_TEXT_H2, font=font)
259264
y += FONT_SIZE + IMG_MARGIN
260265
DrawBlock(draw, y, objBlock)
261266
y += MAP_SIZE + IMG_MARGIN
@@ -274,7 +279,7 @@ def BytesToStr(iBytes):
274279
- Fixed key 'Size'. Value is int.
275280
- Fixed key 'Suballocations'. Value is list of tuples as above.
276281
- Fixed key 'CustomPools'. Value is dictionary.
277-
- Key is string with pool name. Value is list of objects representing memory blocks, each containing dictionary with:
282+
- Key is string with pool ID/name. Value is list of objects representing memory blocks, each containing dictionary with:
278283
- Fixed key 'ID'. Value is int.
279284
- Fixed key 'Size'. Value is int.
280285
- Fixed key 'Algorithm'. Optional. Value is string.

0 commit comments

Comments
 (0)