mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-12-26 02:41:01 +00:00
VmaDumpVis.py: Fixed wrong visualization of custom pools that have multiple blocks.
This commit is contained in:
parent
90eb51c225
commit
ee79c63d61
@ -48,13 +48,13 @@ data = {}
|
|||||||
|
|
||||||
def ProcessBlock(dstBlockList, iBlockId, objBlock, bLinearAlgorithm):
|
def ProcessBlock(dstBlockList, iBlockId, objBlock, bLinearAlgorithm):
|
||||||
iBlockSize = int(objBlock['TotalBytes'])
|
iBlockSize = int(objBlock['TotalBytes'])
|
||||||
arrSuballocs = objBlock['Suballocations']
|
arrSuballocs = objBlock['Suballocations']
|
||||||
dstBlockObj = {'ID': iBlockId, 'Size':iBlockSize, 'Suballocations':[]}
|
dstBlockObj = {'ID': iBlockId, 'Size':iBlockSize, 'Suballocations':[]}
|
||||||
if bLinearAlgorithm:
|
if bLinearAlgorithm:
|
||||||
dstBlockObj['LinearAlgorithm'] = True
|
dstBlockObj['LinearAlgorithm'] = True
|
||||||
dstBlockList.append(dstBlockObj)
|
|
||||||
for objSuballoc in arrSuballocs:
|
for objSuballoc in arrSuballocs:
|
||||||
dstBlockObj['Suballocations'].append((objSuballoc['Type'], int(objSuballoc['Size']), int(objSuballoc['Usage']) if ('Usage' in objSuballoc) else 0))
|
dstBlockObj['Suballocations'].append((objSuballoc['Type'], int(objSuballoc['Size']), int(objSuballoc['Usage']) if ('Usage' in objSuballoc) else 0))
|
||||||
|
dstBlockList.append(dstBlockObj)
|
||||||
|
|
||||||
|
|
||||||
def GetDataForMemoryType(iMemTypeIndex):
|
def GetDataForMemoryType(iMemTypeIndex):
|
||||||
@ -77,15 +77,18 @@ def CalcParams():
|
|||||||
iMaxBlockSize = 0
|
iMaxBlockSize = 0
|
||||||
for dictMemType in data.values():
|
for dictMemType in data.values():
|
||||||
iImgSizeY += IMG_MARGIN + FONT_SIZE
|
iImgSizeY += IMG_MARGIN + FONT_SIZE
|
||||||
iImgSizeY += len(dictMemType['DedicatedAllocations']) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE)
|
lDedicatedAllocations = dictMemType['DedicatedAllocations']
|
||||||
for tDedicatedAlloc in dictMemType['DedicatedAllocations']:
|
iImgSizeY += len(lDedicatedAllocations) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE)
|
||||||
|
for tDedicatedAlloc in lDedicatedAllocations:
|
||||||
iMaxBlockSize = max(iMaxBlockSize, tDedicatedAlloc[1])
|
iMaxBlockSize = max(iMaxBlockSize, tDedicatedAlloc[1])
|
||||||
iImgSizeY += len(dictMemType['DefaultPoolBlocks']) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE)
|
lDefaultPoolBlocks = dictMemType['DefaultPoolBlocks']
|
||||||
for objBlock in dictMemType['DefaultPoolBlocks']:
|
iImgSizeY += len(lDefaultPoolBlocks) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE)
|
||||||
|
for objBlock in lDefaultPoolBlocks:
|
||||||
iMaxBlockSize = max(iMaxBlockSize, objBlock['Size'])
|
iMaxBlockSize = max(iMaxBlockSize, objBlock['Size'])
|
||||||
iImgSizeY += len(dictMemType['CustomPools']) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE)
|
dCustomPools = dictMemType['CustomPools']
|
||||||
for listPool in dictMemType['CustomPools'].values():
|
for lBlocks in dCustomPools.values():
|
||||||
for objBlock in listPool:
|
iImgSizeY += len(lBlocks) * (IMG_MARGIN * 2 + FONT_SIZE + MAP_SIZE)
|
||||||
|
for objBlock in lBlocks:
|
||||||
iMaxBlockSize = max(iMaxBlockSize, objBlock['Size'])
|
iMaxBlockSize = max(iMaxBlockSize, objBlock['Size'])
|
||||||
fPixelsPerByte = (IMG_SIZE_X - IMG_MARGIN * 2) / float(iMaxBlockSize)
|
fPixelsPerByte = (IMG_SIZE_X - IMG_MARGIN * 2) / float(iMaxBlockSize)
|
||||||
return iImgSizeY, fPixelsPerByte
|
return iImgSizeY, fPixelsPerByte
|
||||||
@ -192,9 +195,9 @@ if 'Pools' in jsonSrc:
|
|||||||
typeData = GetDataForMemoryType(iType)
|
typeData = GetDataForMemoryType(iType)
|
||||||
objBlocks = objPool['Blocks']
|
objBlocks = objPool['Blocks']
|
||||||
bLinearAlgorithm = 'LinearAlgorithm' in objPool and objPool['LinearAlgorithm']
|
bLinearAlgorithm = 'LinearAlgorithm' in objPool and objPool['LinearAlgorithm']
|
||||||
|
dstBlockArray = []
|
||||||
|
typeData['CustomPools'][int(sPoolId)] = dstBlockArray
|
||||||
for sBlockId, objBlock in objBlocks.items():
|
for sBlockId, objBlock in objBlocks.items():
|
||||||
dstBlockArray = []
|
|
||||||
typeData['CustomPools'][int(sPoolId)] = dstBlockArray
|
|
||||||
ProcessBlock(dstBlockArray, int(sBlockId), objBlock, bLinearAlgorithm)
|
ProcessBlock(dstBlockArray, int(sBlockId), objBlock, bLinearAlgorithm)
|
||||||
|
|
||||||
iImgSizeY, fPixelsPerByte = CalcParams()
|
iImgSizeY, fPixelsPerByte = CalcParams()
|
||||||
@ -244,15 +247,15 @@ for iMemTypeIndex in sorted(data.keys()):
|
|||||||
index = 0
|
index = 0
|
||||||
for iPoolId, listPool in dictMemType['CustomPools'].items():
|
for iPoolId, listPool in dictMemType['CustomPools'].items():
|
||||||
for objBlock in listPool:
|
for objBlock in listPool:
|
||||||
if 'LinearAlgorithm' in objBlock:
|
if 'LinearAlgorithm' in objBlock:
|
||||||
linearAlgorithmStr = ' (linear algorithm)';
|
linearAlgorithmStr = ' (linear algorithm)';
|
||||||
else:
|
else:
|
||||||
linearAlgorithmStr = '';
|
linearAlgorithmStr = '';
|
||||||
draw.text((IMG_MARGIN, y), "Custom pool %d%s block %d" % (iPoolId, linearAlgorithmStr, objBlock['ID']), fill=COLOR_TEXT_H2, font=font)
|
draw.text((IMG_MARGIN, y), "Custom pool %d%s block %d" % (iPoolId, linearAlgorithmStr, 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
|
||||||
index += 1
|
index += 1
|
||||||
del draw
|
del draw
|
||||||
img.save(args.output)
|
img.save(args.output)
|
||||||
|
|
||||||
@ -267,7 +270,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 integer pool ID. Value is list of objects, each containing dictionary with:
|
- Key is integer pool ID. 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 'LinearAlgorithm'. Optional. Value is True.
|
- Fixed key 'LinearAlgorithm'. Optional. Value is True.
|
||||||
|
Loading…
Reference in New Issue
Block a user