diff --git a/tools/VmaDumpVis/README.md b/tools/VmaDumpVis/README.md index fee2392..97a396b 100644 --- a/tools/VmaDumpVis/README.md +++ b/tools/VmaDumpVis/README.md @@ -28,7 +28,15 @@ You can also use typical options: ## Legend * ![Free space](README_files/Legend_Bkg.png "Free space") Light gray without border - a space in Vulkan device memory block unused by any allocation. -* ![Buffer](README_files/Legend_Buffer.png "Buffer") Yellow rectangle - buffer. -* ![Image Optimal](README_files/Legend_ImageOptimal.png "Image Optimal") Aqua rectangle - image with TILING_OPTIMAL. -* ![Image Linear](README_files/Legend_ImageLinear.png "Image Linear") Green rectangle - image with TILING_LINEAR. -* ![Details](README_files/Legend_Details.png "Details") Black bar or rectangle - one or more allocations of any kind too small to be visualized as filled rectangles. +* ![Buffer 1](README_files/Legend_Buffer_1.png "Buffer 1") Buffer with usage containing INDIRECT_BUFFER, VERTEX_BUFFER, or INDEX_BUFFER. +* ![Buffer 2](README_files/Legend_Buffer_2.png "Buffer 2") Buffer with usage containing STORAGE_BUFFER or STORAGE_TEXEL_BUFFER. +* ![Buffer 3](README_files/Legend_Buffer_3.png "Buffer 3") Buffer with usage containing UNIFORM_BUFFER or UNIFORM_TEXEL_BUFFER. +* ![Buffer 4](README_files/Legend_Buffer_4.png "Buffer 4") Other buffer. +* ![Image 1](README_files/Legend_Image_1.png "Image 1") Image with OPTIMAL tiling and usage containing DEPTH_STENCIL_ATTACHMENT. +* ![Image 2](README_files/Legend_Image_2.png "Image 2") Image with OPTIMAL tiling and usage containing INPUT_ATTACHMENT, TRANSIENT_ATTACHMENT, or COLOR_ATTACHMENT. +* ![Image 3](README_files/Legend_Image_3.png "Image 3") Image with OPTIMAL tiling and usage containing SAMPLED. +* ![Image 4](README_files/Legend_Image_4.png "Image 4") Other image with OPTIMAL tiling. +* ![Image Linear](README_files/Legend_Image_Linear.png "Image Linear") Image with LINEAR tiling. +* ![Image Unknown](README_files/Legend_Image_Unknown.png "Image Unknown") Image with tiling unknown to the allocator. +* ![Unknown](README_files/Legend_Unknown.png "Unknown") Allocation of unknown type. +* ![Details](README_files/Legend_Details.png "Details") Black bar - one or more allocations of any kind too small to be visualized as filled rectangles. diff --git a/tools/VmaDumpVis/README_files/ExampleOutput.png b/tools/VmaDumpVis/README_files/ExampleOutput.png index 0aba87e..2646ed2 100644 Binary files a/tools/VmaDumpVis/README_files/ExampleOutput.png and b/tools/VmaDumpVis/README_files/ExampleOutput.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Buffer.png b/tools/VmaDumpVis/README_files/Legend_Buffer.png deleted file mode 100644 index 3acc825..0000000 Binary files a/tools/VmaDumpVis/README_files/Legend_Buffer.png and /dev/null differ diff --git a/tools/VmaDumpVis/README_files/Legend_Buffer_1.png b/tools/VmaDumpVis/README_files/Legend_Buffer_1.png new file mode 100644 index 0000000..3805225 Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Buffer_1.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Buffer_2.png b/tools/VmaDumpVis/README_files/Legend_Buffer_2.png new file mode 100644 index 0000000..bc3773f Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Buffer_2.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Buffer_3.png b/tools/VmaDumpVis/README_files/Legend_Buffer_3.png new file mode 100644 index 0000000..992d8b2 Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Buffer_3.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Buffer_4.png b/tools/VmaDumpVis/README_files/Legend_Buffer_4.png new file mode 100644 index 0000000..d29f54e Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Buffer_4.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Details.png b/tools/VmaDumpVis/README_files/Legend_Details.png index 450c7c7..a9c8535 100644 Binary files a/tools/VmaDumpVis/README_files/Legend_Details.png and b/tools/VmaDumpVis/README_files/Legend_Details.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_ImageLinear.png b/tools/VmaDumpVis/README_files/Legend_ImageLinear.png deleted file mode 100644 index 4bd3672..0000000 Binary files a/tools/VmaDumpVis/README_files/Legend_ImageLinear.png and /dev/null differ diff --git a/tools/VmaDumpVis/README_files/Legend_ImageOptimal.png b/tools/VmaDumpVis/README_files/Legend_ImageOptimal.png deleted file mode 100644 index 8d74288..0000000 Binary files a/tools/VmaDumpVis/README_files/Legend_ImageOptimal.png and /dev/null differ diff --git a/tools/VmaDumpVis/README_files/Legend_Image_1.png b/tools/VmaDumpVis/README_files/Legend_Image_1.png new file mode 100644 index 0000000..dc180af Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Image_1.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Image_2.png b/tools/VmaDumpVis/README_files/Legend_Image_2.png new file mode 100644 index 0000000..fc35c7c Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Image_2.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Image_3.png b/tools/VmaDumpVis/README_files/Legend_Image_3.png new file mode 100644 index 0000000..b69849d Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Image_3.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Image_4.png b/tools/VmaDumpVis/README_files/Legend_Image_4.png new file mode 100644 index 0000000..7f3980e Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Image_4.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Image_Linear.png b/tools/VmaDumpVis/README_files/Legend_Image_Linear.png new file mode 100644 index 0000000..36d8be5 Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Image_Linear.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Image_Unknown.png b/tools/VmaDumpVis/README_files/Legend_Image_Unknown.png new file mode 100644 index 0000000..f3f40ec Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Image_Unknown.png differ diff --git a/tools/VmaDumpVis/README_files/Legend_Unknown.png b/tools/VmaDumpVis/README_files/Legend_Unknown.png new file mode 100644 index 0000000..3053726 Binary files /dev/null and b/tools/VmaDumpVis/README_files/Legend_Unknown.png differ diff --git a/tools/VmaDumpVis/VmaDumpVis.py b/tools/VmaDumpVis/VmaDumpVis.py index 5bf3d5b..455ee7e 100644 --- a/tools/VmaDumpVis/VmaDumpVis.py +++ b/tools/VmaDumpVis/VmaDumpVis.py @@ -32,7 +32,7 @@ FONT_SIZE = 10 MAP_SIZE = 24 COLOR_TEXT_H1 = (0, 0, 0, 255) COLOR_TEXT_H2 = (150, 150, 150, 255) -COLOR_OUTLINE = (160, 160, 160, 255) +COLOR_OUTLINE = (155, 155, 155, 255) COLOR_OUTLINE_HARD = (0, 0, 0, 255) COLOR_GRID_LINE = (224, 224, 224, 255) @@ -52,7 +52,7 @@ def ProcessBlock(dstBlockList, objBlock): dstBlockObj = {'Size':iBlockSize, 'Suballocations':[]} dstBlockList.append(dstBlockObj) for objSuballoc in arrSuballocs: - dstBlockObj['Suballocations'].append((objSuballoc['Type'], int(objSuballoc['Size']))) + dstBlockObj['Suballocations'].append((objSuballoc['Type'], int(objSuballoc['Size']), int(objSuballoc['Usage']) if ('Usage' in objSuballoc) else 0)) def GetDataForMemoryType(iMemTypeIndex): @@ -88,31 +88,49 @@ def CalcParams(): return iImgSizeY, fPixelsPerByte -def TypeToColor(sType): +def TypeToColor(sType, iUsage): if sType == 'FREE': return 220, 220, 220, 255 elif sType == 'BUFFER': - return 255, 255, 0, 255 + if (iUsage & 0x1C0) != 0: # INDIRECT_BUFFER | VERTEX_BUFFER | INDEX_BUFFER + return 255, 148, 148, 255 # Red + elif (iUsage & 0x28) != 0: # STORAGE_BUFFER | STORAGE_TEXEL_BUFFER + return 255, 187, 121, 255 # Orange + elif (iUsage & 0x14) != 0: # UNIFORM_BUFFER | UNIFORM_TEXEL_BUFFER + return 255, 255, 0, 255 # Yellow + else: + return 255, 255, 165, 255 # Light yellow elif sType == 'IMAGE_OPTIMAL': - return 128, 255, 255, 255 + if (iUsage & 0x20) != 0: # DEPTH_STENCIL_ATTACHMENT + return 246, 128, 255, 255 # Pink + elif (iUsage & 0xD0) != 0: # INPUT_ATTACHMENT | TRANSIENT_ATTACHMENT | COLOR_ATTACHMENT + return 179, 179, 255, 255 # Blue + elif (iUsage & 0x4) != 0: # SAMPLED + return 0, 255, 255, 255 # Aqua + else: + return 183, 255, 255, 255 # Light aqua elif sType == 'IMAGE_LINEAR': - return 64, 255, 64, 255 + return 0, 255, 0, 255 # Green + elif sType == 'IMAGE_UNKNOWN': + return 0, 255, 164, 255 # Green/aqua + elif sType == 'UNKNOWN': + return 175, 175, 175, 255 # Gray assert False return 0, 0, 0, 255 -def DrawDedicatedAllocationBlock(draw, y, tDedicatedAlloc): +def DrawDedicatedAllocationBlock(draw, y, tDedicatedAlloc): global fPixelsPerByte iSizeBytes = tDedicatedAlloc[1] iSizePixels = int(iSizeBytes * fPixelsPerByte) - draw.rectangle([IMG_MARGIN, y, IMG_MARGIN + iSizePixels, y + MAP_SIZE], fill=TypeToColor(tDedicatedAlloc[0]), outline=COLOR_OUTLINE) + draw.rectangle([IMG_MARGIN, y, IMG_MARGIN + iSizePixels, y + MAP_SIZE], fill=TypeToColor(tDedicatedAlloc[0], tDedicatedAlloc[2]), outline=COLOR_OUTLINE) def DrawBlock(draw, y, objBlock): global fPixelsPerByte iSizeBytes = objBlock['Size'] iSizePixels = int(iSizeBytes * fPixelsPerByte) - draw.rectangle([IMG_MARGIN, y, IMG_MARGIN + iSizePixels, y + MAP_SIZE], fill=TypeToColor('FREE'), outline=None) + draw.rectangle([IMG_MARGIN, y, IMG_MARGIN + iSizePixels, y + MAP_SIZE], fill=TypeToColor('FREE', 0), outline=None) iByte = 0 iX = 0 iLastHardLineX = -1 @@ -122,7 +140,8 @@ def DrawBlock(draw, y, objBlock): iXEnd = int(iByteEnd * fPixelsPerByte) if sType != 'FREE': if iXEnd > iX + 1: - draw.rectangle([IMG_MARGIN + iX, y, IMG_MARGIN + iXEnd, y + MAP_SIZE], fill=TypeToColor(sType), outline=COLOR_OUTLINE) + iUsage = tSuballoc[2] + draw.rectangle([IMG_MARGIN + iX, y, IMG_MARGIN + iXEnd, y + MAP_SIZE], fill=TypeToColor(sType, iUsage), outline=COLOR_OUTLINE) # Hard line was been overwritten by rectangle outline: redraw it. if iLastHardLineX == iX: draw.line([IMG_MARGIN + iX, y, IMG_MARGIN + iX, y + MAP_SIZE], fill=COLOR_OUTLINE_HARD) @@ -154,7 +173,7 @@ if 'DedicatedAllocations' in jsonSrc: iType = int(sType[5:]) typeData = GetDataForMemoryType(iType) for objAlloc in tType[1]: - typeData['DedicatedAllocations'].append((objAlloc['Type'], int(objAlloc['Size']))) + typeData['DedicatedAllocations'].append((objAlloc['Type'], int(objAlloc['Size']), int(objAlloc['Usage']) if ('Usage' in objAlloc) else 0)) if 'DefaultPools' in jsonSrc: for tType in jsonSrc['DefaultPools'].items(): sType = tType[0] @@ -171,7 +190,6 @@ if 'Pools' in jsonSrc: arrBlocks = objPool['Blocks'] for objBlock in arrBlocks: ProcessBlock(typeData['CustomPoolBlocks'], objBlock) - iImgSizeY, fPixelsPerByte = CalcParams() @@ -234,6 +252,7 @@ Main data structure - variable `data` - is a dictionary. Key is integer - memory - Fixed key 'DedicatedAllocations'. Value is list of tuples, each containing: - [0]: Type : string - [1]: Size : integer + - [2]: Usage : integer (0 if unknown) - Fixed key 'DefaultPoolBlocks'. Value is list of objects, each containing dictionary with: - Fixed key 'Size'. Value is int. - Fixed key 'Suballocations'. Value is list of tuples as above.