Further development of custom pool names

This commit is contained in:
Adam Sawicki 2019-11-18 11:45:30 +01:00
parent a020fb81cb
commit 49defd6056
3 changed files with 25 additions and 17 deletions

View File

@ -3113,8 +3113,6 @@ static void TestPool_SameSize()
vmaGetPoolName(g_hAllocator, pool, &fetchedPoolName); vmaGetPoolName(g_hAllocator, pool, &fetchedPoolName);
TEST(strcmp(fetchedPoolName, POOL_NAME) == 0); TEST(strcmp(fetchedPoolName, POOL_NAME) == 0);
SaveAllocatorStatsToFile(L"TEST.json");//DELME
vmaSetPoolName(g_hAllocator, pool, nullptr); vmaSetPoolName(g_hAllocator, pool, nullptr);
} }

View File

@ -2512,14 +2512,21 @@ Possible return values:
*/ */
VMA_CALL_PRE VkResult VMA_CALL_POST vmaCheckPoolCorruption(VmaAllocator allocator, VmaPool pool); VMA_CALL_PRE VkResult VMA_CALL_POST vmaCheckPoolCorruption(VmaAllocator allocator, VmaPool pool);
/** TODO /** \brief Retrieves name of a custom pool.
After the call `ppName` is either null or points to an internally-owned null-terminated string
containing name of the pool that was previously set. The pointer becomes invalid when the pool is
destroyed or its name is changed using vmaSetPoolName().
*/ */
VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolName( VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolName(
VmaAllocator allocator, VmaAllocator allocator,
VmaPool pool, VmaPool pool,
const char** ppName); const char** ppName);
/* TODO /* \brief Sets name of a custom pool.
`pName` can be either null or pointer to a null-terminated string with new name for the pool.
Function makes internal copy of the string, so it can be changed or freed immediately after this call.
*/ */
VMA_CALL_PRE void VMA_CALL_POST vmaSetPoolName( VMA_CALL_PRE void VMA_CALL_POST vmaSetPoolName(
VmaAllocator allocator, VmaAllocator allocator,
@ -12418,6 +12425,13 @@ void VmaBlockVector::PrintDetailedMap(class VmaJsonWriter& json)
if(m_IsCustomPool) if(m_IsCustomPool)
{ {
const char* poolName = m_hParentPool->GetName();
if(poolName != VMA_NULL && poolName[0] != '\0')
{
json.WriteString("Name");
json.WriteString(poolName);
}
json.WriteString("MemoryTypeIndex"); json.WriteString("MemoryTypeIndex");
json.WriteNumber(m_MemoryTypeIndex); json.WriteNumber(m_MemoryTypeIndex);
@ -15819,15 +15833,6 @@ void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json)
{ {
json.BeginString(); json.BeginString();
json.ContinueString(m_Pools[poolIndex]->GetId()); json.ContinueString(m_Pools[poolIndex]->GetId());
const char* poolName = m_Pools[poolIndex]->GetName();
if(poolName != VMA_NULL && poolName[0] != '\0')
{
json.ContinueString(" ");
json.ContinueString(poolName);
}
else
{
}
json.EndString(); json.EndString();
m_Pools[poolIndex]->m_BlockVector.PrintDetailedMap(json); m_Pools[poolIndex]->m_BlockVector.PrintDetailedMap(json);

View File

@ -189,13 +189,18 @@ if 'DefaultPools' in jsonSrc:
ProcessBlock(typeData['DefaultPoolBlocks'], int(sBlockId), objBlock, '') ProcessBlock(typeData['DefaultPoolBlocks'], int(sBlockId), objBlock, '')
if 'Pools' in jsonSrc: if 'Pools' in jsonSrc:
objPools = jsonSrc['Pools'] objPools = jsonSrc['Pools']
for sPoolName, objPool in objPools.items(): for sPoolId, objPool in objPools.items():
iType = int(objPool['MemoryTypeIndex']) iType = int(objPool['MemoryTypeIndex'])
typeData = GetDataForMemoryType(iType) typeData = GetDataForMemoryType(iType)
objBlocks = objPool['Blocks'] objBlocks = objPool['Blocks']
sAlgorithm = objPool.get('Algorithm', '') sAlgorithm = objPool.get('Algorithm', '')
sName = objPool.get('Name', None)
if sName:
sFullName = sPoolId + ' "' + sName + '"'
else:
sFullName = sPoolId
dstBlockArray = [] dstBlockArray = []
typeData['CustomPools'][sPoolName] = dstBlockArray typeData['CustomPools'][sFullName] = dstBlockArray
for sBlockId, objBlock in objBlocks.items(): for sBlockId, objBlock in objBlocks.items():
ProcessBlock(dstBlockArray, int(sBlockId), objBlock, sAlgorithm) ProcessBlock(dstBlockArray, int(sBlockId), objBlock, sAlgorithm)
@ -255,7 +260,7 @@ for iMemTypeIndex in sorted(data.keys()):
sAlgorithm = ' (Algorithm: %s)' % (objBlock['Algorithm']) sAlgorithm = ' (Algorithm: %s)' % (objBlock['Algorithm'])
else: else:
sAlgorithm = '' sAlgorithm = ''
draw.text((IMG_MARGIN, y), "Custom pool \"%s\"%s block %d" % (sPoolName, sAlgorithm, objBlock['ID']), fill=COLOR_TEXT_H2, font=font) draw.text((IMG_MARGIN, y), "Custom pool %s%s block %d" % (sPoolName, sAlgorithm, objBlock['ID']), fill=COLOR_TEXT_H2, font=font)
y += FONT_SIZE + IMG_MARGIN y += FONT_SIZE + IMG_MARGIN
DrawBlock(draw, y, objBlock) DrawBlock(draw, y, objBlock)
y += MAP_SIZE + IMG_MARGIN y += MAP_SIZE + IMG_MARGIN
@ -274,7 +279,7 @@ Main data structure - variable `data` - is a dictionary. Key is integer - memory
- Fixed key 'Size'. Value is int. - Fixed key 'Size'. Value is int.
- Fixed key 'Suballocations'. Value is list of tuples as above. - Fixed key 'Suballocations'. Value is list of tuples as above.
- Fixed key 'CustomPools'. Value is dictionary. - Fixed key 'CustomPools'. Value is dictionary.
- Key is string with pool name. Value is list of objects representing memory blocks, each containing dictionary with: - Key is string with pool ID/name. Value is list of objects representing memory blocks, each containing dictionary with:
- Fixed key 'ID'. Value is int. - Fixed key 'ID'. Value is int.
- Fixed key 'Size'. Value is int. - Fixed key 'Size'. Value is int.
- Fixed key 'Algorithm'. Optional. Value is string. - Fixed key 'Algorithm'. Optional. Value is string.