0

Add BACKGROUND dump mode to various GPU/CC MemoryDumpProviders

BUG=
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Committed: https://crrev.com/c624f3d71afc0077b16ac8ca9d54296050b5d5d8
Review-Url: https://codereview.chromium.org/2382573002
Cr-Original-Commit-Position: refs/heads/master@{#428769}
Cr-Commit-Position: refs/heads/master@{#429701}
This commit is contained in:
ericrk
2016-11-03 14:37:31 -07:00
committed by Commit bot
parent 389d080846
commit eff776983e
12 changed files with 235 additions and 119 deletions

@ -17,6 +17,10 @@
#include "gpu/command_buffer/client/gles2_interface.h"
#include "ui/gfx/gpu_memory_buffer_tracing.h"
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryAllocatorDumpGuid;
using base::trace_event::MemoryDumpLevelOfDetail;
namespace cc {
namespace {
@ -96,23 +100,21 @@ void StagingBuffer::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
gfx::GpuMemoryBufferId buffer_id = gpu_memory_buffer->GetId();
std::string buffer_dump_name =
base::StringPrintf("cc/one_copy/staging_memory/buffer_%d", buffer_id.id);
base::trace_event::MemoryAllocatorDump* buffer_dump =
pmd->CreateAllocatorDump(buffer_dump_name);
MemoryAllocatorDump* buffer_dump = pmd->CreateAllocatorDump(buffer_dump_name);
uint64_t buffer_size_in_bytes =
ResourceUtil::UncheckedSizeInBytes<uint64_t>(size, format);
buffer_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
buffer_dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
buffer_size_in_bytes);
buffer_dump->AddScalar("free_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
buffer_dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes,
in_free_list ? buffer_size_in_bytes : 0);
// Emit an ownership edge towards a global allocator dump node.
const uint64_t tracing_process_id =
base::trace_event::MemoryDumpManager::GetInstance()
->GetTracingProcessId();
base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid =
MemoryAllocatorDumpGuid shared_buffer_guid =
gfx::GetGpuMemoryBufferGUIDForTracing(tracing_process_id, buffer_id);
pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid);
@ -187,16 +189,23 @@ bool StagingBufferPool::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd) {
base::AutoLock lock(lock_);
for (const auto* buffer : buffers_) {
auto in_free_buffers =
std::find_if(free_buffers_.begin(), free_buffers_.end(),
[buffer](const std::unique_ptr<StagingBuffer>& b) {
return b.get() == buffer;
});
buffer->OnMemoryDump(pmd, buffer->format,
in_free_buffers != free_buffers_.end());
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name("cc/one_copy/staging_memory");
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
staging_buffer_usage_in_bytes_);
} else {
for (const auto* buffer : buffers_) {
auto in_free_buffers =
std::find_if(free_buffers_.begin(), free_buffers_.end(),
[buffer](const std::unique_ptr<StagingBuffer>& b) {
return b.get() == buffer;
});
buffer->OnMemoryDump(pmd, buffer->format,
in_free_buffers != free_buffers_.end());
}
}
return true;
}

@ -20,6 +20,9 @@
#include "cc/resources/resource_util.h"
#include "cc/resources/scoped_resource.h"
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
namespace cc {
base::TimeDelta ResourcePool::kDefaultExpirationDelay =
base::TimeDelta::FromSeconds(1);
@ -37,21 +40,16 @@ void ResourcePool::PoolResource::OnMemoryDump(
std::string dump_name =
base::StringPrintf("cc/tile_memory/provider_%d/resource_%d",
resource_provider->tracing_id(), id());
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(dump_name);
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
pmd->AddSuballocation(dump->guid(), parent_node);
uint64_t total_bytes =
ResourceUtil::UncheckedSizeInBytesAligned<size_t>(size(), format());
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
total_bytes);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, total_bytes);
if (is_free) {
dump->AddScalar("free_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
total_bytes);
dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, total_bytes);
}
}
@ -447,14 +445,23 @@ base::TimeTicks ResourcePool::GetUsageTimeForLRUResource() const {
bool ResourcePool::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
for (const auto& resource : unused_resources_) {
resource->OnMemoryDump(pmd, resource_provider_, true /* is_free */);
}
for (const auto& resource : busy_resources_) {
resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
}
for (const auto& entry : in_use_resources_) {
entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name = base::StringPrintf(
"cc/tile_memory/provider_%d", resource_provider_->tracing_id());
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
total_memory_usage_bytes_);
} else {
for (const auto& resource : unused_resources_) {
resource->OnMemoryDump(pmd, resource_provider_, true /* is_free */);
}
for (const auto& resource : busy_resources_) {
resource->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
}
for (const auto& entry : in_use_resources_) {
entry.second->OnMemoryDump(pmd, resource_provider_, false /* is_free */);
}
}
return true;
}

@ -551,8 +551,25 @@ void GpuImageDecodeController::SetShouldAggressivelyFreeResources(
bool GpuImageDecodeController::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryAllocatorDumpGuid;
using base::trace_event::MemoryDumpLevelOfDetail;
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
"GpuImageDecodeController::OnMemoryDump");
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name =
base::StringPrintf("cc/image_memory/controller_0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(this));
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, bytes_used_);
// Early out, no need for more detail in a BACKGROUND dump.
return true;
}
for (const auto& image_pair : persistent_cache_) {
const ImageData* image_data = image_pair.second.get();
const uint32_t image_id = image_pair.first;
@ -562,41 +579,40 @@ bool GpuImageDecodeController::OnMemoryDump(
std::string discardable_dump_name = base::StringPrintf(
"cc/image_memory/controller_0x%" PRIXPTR "/discardable/image_%d",
reinterpret_cast<uintptr_t>(this), image_id);
base::trace_event::MemoryAllocatorDump* dump =
MemoryAllocatorDump* dump =
image_data->decode.data()->CreateMemoryAllocatorDump(
discardable_dump_name.c_str(), pmd);
// If our image is locked, dump the "locked_size" as an additional column.
// If our image is locked, dump the "locked_size" as an additional
// column.
// This lets us see the amount of discardable which is contributing to
// memory pressure.
if (image_data->decode.is_locked()) {
dump->AddScalar("locked_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes,
image_data->size);
}
}
// If we have an uploaded image (that is actually on the GPU, not just a CPU
// If we have an uploaded image (that is actually on the GPU, not just a
// CPU
// wrapper), upload it here.
if (image_data->upload.image() &&
image_data->mode == DecodedDataMode::GPU) {
std::string gpu_dump_name = base::StringPrintf(
"cc/image_memory/controller_0x%" PRIXPTR "/gpu/image_%d",
reinterpret_cast<uintptr_t>(this), image_id);
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(gpu_dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
image_data->size);
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(gpu_dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, image_data->size);
// Create a global shred GUID to associate this data with its GPU process
// Create a global shred GUID to associate this data with its GPU
// process
// counterpart.
GLuint gl_id = skia::GrBackendObjectToGrGLTextureInfo(
image_data->upload.image()->getTextureHandle(
false /* flushPendingGrContextIO */))
->fID;
base::trace_event::MemoryAllocatorDumpGuid guid =
gl::GetGLTextureClientGUIDForTracing(
context_->ContextSupport()->ShareGroupTracingGUID(), gl_id);
MemoryAllocatorDumpGuid guid = gl::GetGLTextureClientGUIDForTracing(
context_->ContextSupport()->ShareGroupTracingGUID(), gl_id);
// kImportance is somewhat arbitrary - we chose 3 to be higher than the
// value used in the GPU process (1), and Skia (2), causing us to appear

@ -28,6 +28,9 @@
#include "third_party/skia/include/core/SkPixmap.h"
#include "ui/gfx/skia_util.h"
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
namespace cc {
namespace {
@ -778,9 +781,18 @@ bool SoftwareImageDecodeController::OnMemoryDump(
base::trace_event::ProcessMemoryDump* pmd) {
base::AutoLock lock(lock_);
// Dump each of our caches.
DumpImageMemoryForCache(decoded_images_, "cached", pmd);
DumpImageMemoryForCache(at_raster_decoded_images_, "at_raster", pmd);
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name =
base::StringPrintf("cc/image_memory/controller_0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(this));
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes,
locked_images_budget_.GetCurrentUsageSafe());
} else {
// Dump each of our caches.
DumpImageMemoryForCache(decoded_images_, "cached", pmd);
DumpImageMemoryForCache(at_raster_decoded_images_, "at_raster", pmd);
}
// Memory dump can't fail, always return true.
return true;
@ -793,17 +805,17 @@ void SoftwareImageDecodeController::DumpImageMemoryForCache(
lock_.AssertAcquired();
for (const auto& image_pair : cache) {
std::string dump_name = base::StringPrintf(
"cc/image_memory/controller_0x%" PRIXPTR "/%s/image_%" PRIu64 "_id_%d",
reinterpret_cast<uintptr_t>(this), cache_name,
image_pair.second->tracing_id(), image_pair.first.image_id());
base::trace_event::MemoryAllocatorDump* dump =
image_pair.second->memory()->CreateMemoryAllocatorDump(
dump_name.c_str(), pmd);
DCHECK(dump);
if (image_pair.second->is_locked()) {
dump->AddScalar("locked_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
std::string dump_name = base::StringPrintf(
"cc/image_memory/controller_0x%" PRIXPTR "/%s/image_%" PRIu64
"_id_%d",
reinterpret_cast<uintptr_t>(this), cache_name,
image_pair.second->tracing_id(), image_pair.first.image_id());
MemoryAllocatorDump* dump =
image_pair.second->memory()->CreateMemoryAllocatorDump(
dump_name.c_str(), pmd);
DCHECK(dump);
dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes,
image_pair.first.locked_bytes());
}
}

@ -198,10 +198,9 @@ class CC_EXPORT SoftwareImageDecodeController
void SubtractUsage(size_t usage);
void ResetUsage();
size_t total_limit_bytes() const { return limit_bytes_; }
private:
size_t GetCurrentUsageSafe() const;
private:
size_t limit_bytes_;
base::CheckedNumeric<size_t> current_usage_bytes_;
};

@ -340,6 +340,9 @@ int32_t CommandBufferHelper::GetTotalFreeEntriesNoWaiting() const {
bool CommandBufferHelper::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
if (!HaveRingBuffer())
return true;
@ -347,19 +350,20 @@ bool CommandBufferHelper::OnMemoryDump(
base::trace_event::MemoryDumpManager::GetInstance()
->GetTracingProcessId();
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(base::StringPrintf(
"gpu/command_buffer_memory/buffer_%d", ring_buffer_id_));
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
ring_buffer_size_);
dump->AddScalar("free_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry));
auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_);
const int kImportance = 2;
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf(
"gpu/command_buffer_memory/buffer_%d", ring_buffer_id_));
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, ring_buffer_size_);
if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) {
dump->AddScalar(
"free_size", MemoryAllocatorDump::kUnitsBytes,
GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry));
auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_);
const int kImportance = 2;
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
}
return true;
}

@ -438,6 +438,9 @@ void GLES2Implementation::SetAggressivelyFreeResources(
bool GLES2Implementation::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
if (!transfer_buffer_->HaveBuffer())
return true;
@ -445,20 +448,21 @@ bool GLES2Implementation::OnMemoryDump(
base::trace_event::MemoryDumpManager::GetInstance()
->GetTracingProcessId();
base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(
base::StringPrintf("gpu/transfer_buffer_memory/buffer_%d",
transfer_buffer_->GetShmId()));
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf(
"gpu/transfer_buffer_memory/buffer_%d", transfer_buffer_->GetShmId()));
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
transfer_buffer_->GetSize());
dump->AddScalar("free_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
transfer_buffer_->GetFreeSize());
auto guid =
GetBufferGUIDForTracing(tracing_process_id, transfer_buffer_->GetShmId());
const int kImportance = 2;
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) {
dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes,
transfer_buffer_->GetFreeSize());
auto guid = GetBufferGUIDForTracing(tracing_process_id,
transfer_buffer_->GetShmId());
const int kImportance = 2;
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
}
return true;
}

@ -169,21 +169,31 @@ void MappedMemoryManager::FreeUnused() {
bool MappedMemoryManager::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name =
base::StringPrintf("gpu/mapped_memory/manager_%d", tracing_id_);
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, allocated_memory_);
// Early out, no need for more detail in a BACKGROUND dump.
return true;
}
const uint64_t tracing_process_id =
base::trace_event::MemoryDumpManager::GetInstance()
->GetTracingProcessId();
for (const auto& chunk : chunks_) {
std::string dump_name = base::StringPrintf(
"gpu/mapped_memory/manager_%d/chunk_%d", tracing_id_, chunk->shm_id());
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(dump_name);
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
chunk->GetSize());
dump->AddScalar("free_size",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, chunk->GetSize());
dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes,
chunk->GetFreeSize());
auto guid = GetBufferGUIDForTracing(tracing_process_id, chunk->shm_id());

@ -708,6 +708,21 @@ void BufferManager::SetPrimitiveRestartFixedIndexIfNecessary(GLenum type) {
bool BufferManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name =
base::StringPrintf("gpu/gl/buffers/share_group_%" PRIu64 "",
memory_tracker_->ShareGroupTracingGUID());
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, mem_represented());
// Early out, no need for more detail in a BACKGROUND dump.
return true;
}
const uint64_t share_group_tracing_guid =
memory_tracker_->ShareGroupTracingGUID();
for (const auto& buffer_entry : buffers_) {
@ -717,10 +732,9 @@ bool BufferManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
std::string dump_name =
base::StringPrintf("gpu/gl/buffers/share_group_%" PRIu64 "/buffer_%d",
share_group_tracing_guid, client_buffer_id);
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
static_cast<uint64_t>(buffer->size()));
auto guid = gl::GetGLBufferGUIDForTracing(share_group_tracing_guid,
@ -728,6 +742,7 @@ bool BufferManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid);
}
return true;
}

@ -250,6 +250,20 @@ GLenum RenderbufferManager::InternalRenderbufferFormatToImplFormat(
bool RenderbufferManager::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name = base::StringPrintf(
"gpu/gl/renderbuffers/client_%d/", memory_tracker_->ClientId());
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, mem_represented());
// Early out, no need for more detail in a BACKGROUND dump.
return true;
}
int client_id = memory_tracker_->ClientId();
for (const auto& renderbuffer_entry : renderbuffers_) {
const auto& client_renderbuffer_id = renderbuffer_entry.first;
@ -258,10 +272,9 @@ bool RenderbufferManager::OnMemoryDump(
std::string dump_name =
base::StringPrintf("gpu/gl/renderbuffers/client_%d/renderbuffer_%d",
client_id, client_renderbuffer_id);
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
static_cast<uint64_t>(renderbuffer->EstimatedSize()));
auto guid = gl::GetGLRenderbufferGUIDForTracing(
@ -269,6 +282,7 @@ bool RenderbufferManager::OnMemoryDump(
pmd->CreateSharedGlobalAllocatorDump(guid);
pmd->AddOwnershipEdge(dump->guid(), guid);
}
return true;
}

@ -34,6 +34,9 @@
#include "ui/gl/gl_version_info.h"
#include "ui/gl/trace_util.h"
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
namespace gpu {
namespace gles2 {
@ -1718,12 +1721,10 @@ void Texture::DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd,
// texture allocation also as the storage is not provided by the
// GLImage in that case.
if (level_infos[level_index].image_state != BOUND) {
base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(
base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(),
face_index, level_index));
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf(
"%s/face_%d/level_%d", dump_name.c_str(), face_index, level_index));
dump->AddScalar(
base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
MemoryAllocatorDump::kNameSize, MemoryAllocatorDump::kUnitsBytes,
static_cast<uint64_t>(level_infos[level_index].estimated_size));
}
}
@ -3261,8 +3262,21 @@ ScopedTextureUploadTimer::~ScopedTextureUploadTimer() {
bool TextureManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name =
base::StringPrintf("gpu/gl/textures/share_group_%" PRIu64 "",
memory_tracker_->ShareGroupTracingGUID());
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, mem_represented());
// Early out, no need for more detail in a BACKGROUND dump.
return true;
}
for (const auto& resource : textures_) {
// Only dump memory info for textures actually owned by this TextureManager.
// Only dump memory info for textures actually owned by this
// TextureManager.
DumpTextureRef(pmd, resource.second.get());
}
@ -3288,10 +3302,9 @@ void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd,
"gpu/gl/textures/share_group_%" PRIu64 "/texture_%d",
memory_tracker_->ShareGroupTracingGUID(), ref->client_id());
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
static_cast<uint64_t>(size));
// Add the |client_guid| which expresses shared ownership with the client

@ -111,17 +111,30 @@ scoped_refptr<Buffer> TransferBufferManager::GetTransferBuffer(int32_t id) {
bool TransferBufferManager::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
using base::trace_event::MemoryAllocatorDump;
using base::trace_event::MemoryDumpLevelOfDetail;
if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
std::string dump_name = base::StringPrintf("gpu/transfer_memory/client_%d",
memory_tracker_->ClientId());
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes,
shared_memory_bytes_allocated_);
// Early out, no need for more detail in a BACKGROUND dump.
return true;
}
for (const auto& buffer_entry : registered_buffers_) {
int32_t buffer_id = buffer_entry.first;
const Buffer* buffer = buffer_entry.second.get();
std::string dump_name =
base::StringPrintf("gpu/transfer_memory/client_%d/buffer_%d",
memory_tracker_->ClientId(), buffer_id);
base::trace_event::MemoryAllocatorDump* dump =
pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
buffer->size());
MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
dump->AddScalar(MemoryAllocatorDump::kNameSize,
MemoryAllocatorDump::kUnitsBytes, buffer->size());
auto guid =
GetBufferGUIDForTracing(memory_tracker_->ClientTracingId(), buffer_id);
pmd->CreateSharedGlobalAllocatorDump(guid);