Commit 1e435d07 by Tim Van Patten Committed by Commit Bot

Vulkan: Support dumping VMA stats string

This CL adds support for dumping the VMA stats string, which can be given to VmaDumpVis.py to visualize the allocations that the VMA has performed. To enable dumping the string, set: RendererVk.cpp rx::kOutputVmaStatsString = true Copy the desired JSON output into a text file, and pass that to VmaDumpVis.py: python3 \ third_party/vulkan_memory_allocator/tools/VmaDumpVis/VmaDumpVis.py \ -o stats.png stats.txt The legend for the visualization is available at: https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/tree/master/tools/VmaDumpVis Bug: angleproject:2162 Test: Manual verification Change-Id: Ic8c1002805dd57e594df724bcf1cdbc1d1599a3e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2472525Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCharlie Lao <cclao@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
parent 12462910
......@@ -64,6 +64,8 @@ constexpr uint32_t kPipelineCacheVkUpdatePeriod = 60;
// version of Vulkan.
constexpr uint32_t kPreferredVulkanAPIVersion = VK_API_VERSION_1_1;
constexpr bool kOutputVmaStatsString = false;
angle::vk::ICD ChooseICDFromAttribs(const egl::AttributeMap &attribs)
{
#if !defined(ANGLE_PLATFORM_ANDROID)
......@@ -2182,6 +2184,17 @@ angle::Result RendererVk::queueSubmit(vk::Context *context,
const vk::Fence *fence,
Serial *serialOut)
{
if (kOutputVmaStatsString)
{
// Output the VMA stats string
// This JSON string can be passed to VmaDumpVis.py to generate a visualization of the
// allocations the VMA has performed.
char *statsString;
mAllocator.buildStatsString(&statsString, true);
INFO() << std::endl << statsString << std::endl;
mAllocator.freeStatsString(statsString);
}
if (getFeatures().enableCommandProcessingThread.enabled)
{
// For initial threading phase 1 code make sure any outstanding command processing
......
......@@ -148,4 +148,14 @@ void InvalidateAllocation(VmaAllocator allocator,
{
vmaInvalidateAllocation(allocator, allocation, offset, size);
}
void BuildStatsString(VmaAllocator allocator, char **statsString, VkBool32 detailedMap)
{
vmaBuildStatsString(allocator, statsString, detailedMap);
}
void FreeStatsString(VmaAllocator allocator, char *statsString)
{
vmaFreeStatsString(allocator, statsString);
}
} // namespace vma
......@@ -62,6 +62,9 @@ void InvalidateAllocation(VmaAllocator allocator,
VkDeviceSize offset,
VkDeviceSize size);
void BuildStatsString(VmaAllocator allocator, char **statsString, VkBool32 detailedMap);
void FreeStatsString(VmaAllocator allocator, char *statsString);
} // namespace vma
#endif // LIBANGLE_RENDERER_VULKAN_VK_MEM_ALLOC_WRAPPER_H_
......@@ -490,6 +490,9 @@ class Allocator : public WrappedObject<Allocator, VmaAllocator>
VkMemoryPropertyFlags preferredFlags,
bool persistentlyMappedBuffers,
uint32_t *memoryTypeIndexOut) const;
void buildStatsString(char **statsString, VkBool32 detailedMap);
void freeStatsString(char *statsString);
};
class Allocation final : public WrappedObject<Allocation, VmaAllocation>
......@@ -1457,6 +1460,18 @@ Allocator::findMemoryTypeIndexForBufferInfo(const VkBufferCreateInfo &bufferCrea
memoryTypeIndexOut);
}
ANGLE_INLINE void Allocator::buildStatsString(char **statsString, VkBool32 detailedMap)
{
ASSERT(valid());
vma::BuildStatsString(mHandle, statsString, detailedMap);
}
ANGLE_INLINE void Allocator::freeStatsString(char *statsString)
{
ASSERT(valid());
vma::FreeStatsString(mHandle, statsString);
}
// Allocation implementation.
ANGLE_INLINE void Allocation::destroy(const Allocator &allocator)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment