0

[gpu] Add dawn vulkan allocator support for dumps and UMA

Support Graphite-Dawn-Vulkan allocator dumps to be reported as both
background and detailed reports. Also add a new prefix under
"gpu/vulkan" for graphite_allocator which will be used for reporting
the dumps. The same prefix is also used for reporting to UMAs so the
same Memory.Experimental.Gpu2.Vulkan UMA can be used for both
ganesh and graphite (since vma_allocator will only report for ganesh
and graphite_allocator only for graphite).

Bug: 397720827
Change-Id: Ie851c7c08cde4c5e2db0df220427c25263891f1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6387675
Reviewed-by: Kyle Charbonneau <kylechar@chromium.org>
Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org>
Commit-Queue: Saifuddin Hitawala <hitawala@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1437919}
This commit is contained in:
Saifuddin Hitawala
2025-03-25 20:49:17 -07:00
committed by Chromium LUCI CQ
parent 18968035ee
commit 4ed3e36549
2 changed files with 27 additions and 4 deletions
base/trace_event
gpu/command_buffer/service

@ -101,6 +101,8 @@ constexpr auto kDumpProviderAllowlist =
// A list of string names that are allowed for the memory allocator dumps in
// background mode.
// NOTE: There is no generic pattern matching support and only names containing
// "0x?" match "0x" followed by hex digits.
constexpr auto kAllocatorDumpNameAllowlist =
base::MakeFixedFlatSet<std::string_view>({
// clang-format off
@ -180,6 +182,7 @@ constexpr auto kAllocatorDumpNameAllowlist =
"gpu/transfer_cache/cache_0x?",
"gpu/transfer_cache/cache_0x?/avg_image_size",
"gpu/vulkan/vma_allocator_0x?",
"gpu/vulkan/graphite_allocator",
"history/delta_file_service/leveldb_0x?",
"history/usage_reports_buffer/leveldb_0x?",
#if BUILDFLAG(IS_MAC)

@ -828,6 +828,9 @@ void DawnSharedContext::OnError(wgpu::ErrorType error_type,
namespace {
static constexpr char kDawnMemoryDumpPrefix[] = "gpu/dawn";
static constexpr char kAllocatorMemoryDumpPrefix[] =
"gpu/vulkan/graphite_allocator";
class DawnMemoryDump : public dawn::native::MemoryDump {
public:
explicit DawnMemoryDump(base::trace_event::ProcessMemoryDump* pmd)
@ -862,10 +865,9 @@ class DawnMemoryDump : public dawn::native::MemoryDump {
bool DawnSharedContext::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
if (args.level_of_detail ==
base::trace_event::MemoryDumpLevelOfDetail::kBackground) {
using base::trace_event::MemoryAllocatorDump;
const dawn::native::MemoryUsageInfo mem_usage =
dawn::native::ComputeEstimatedMemoryUsageInfo(device_.Get());
@ -892,9 +894,27 @@ bool DawnSharedContext::OnMemoryDump(
->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, mem_usage.buffersUsage);
} else {
DawnMemoryDump dump(pmd);
dawn::native::DumpMemoryStatistics(device_.Get(), &dump);
DawnMemoryDump dawnMemoryDump(pmd);
dawn::native::DumpMemoryStatistics(device_.Get(), &dawnMemoryDump);
}
if (backend_type() == wgpu::BackendType::Vulkan) {
// For Graphite-Vulkan backend, report vulkan allocator dumps and
// statistics.
auto* dump = pmd->GetOrCreateAllocatorDump(kAllocatorMemoryDumpPrefix);
const dawn::native::AllocatorMemoryInfo allocator_usage =
dawn::native::GetAllocatorMemoryInfo(device_.Get());
// `allocated_size` is memory allocated from the device, used is what is
// actually used.
dump->AddScalar("allocated_size", MemoryAllocatorDump::kUnitsBytes,
allocator_usage.totalAllocatedMemory);
dump->AddScalar("used_size", MemoryAllocatorDump::kUnitsBytes,
allocator_usage.totalUsedMemory);
dump->AddScalar(
"fragmentation_size", MemoryAllocatorDump::kUnitsBytes,
allocator_usage.totalAllocatedMemory - allocator_usage.totalUsedMemory);
}
return true;
}