Chromium Code Reviews| Index: gpu/command_buffer/service/texture_manager.cc |
| diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc |
| index c7150ee98eee936d0c174cd9246505cbc691eefe..693c0b3cfec8b55e1eedcc288dea105d7758174b 100644 |
| --- a/gpu/command_buffer/service/texture_manager.cc |
| +++ b/gpu/command_buffer/service/texture_manager.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/bits.h" |
| #include "base/lazy_instance.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/trace_event/memory_dump_manager.h" |
| #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| #include "gpu/command_buffer/service/context_state.h" |
| #include "gpu/command_buffer/service/error_state.h" |
| @@ -283,6 +284,9 @@ TextureManager::~TextureManager() { |
| DCHECK_EQ(0, num_unsafe_textures_); |
| DCHECK_EQ(0, num_uncleared_mips_); |
| DCHECK_EQ(0, num_images_); |
| + |
| + base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| + this); |
| } |
| void TextureManager::Destroy(bool have_context) { |
| @@ -1324,6 +1328,7 @@ TextureManager::TextureManager(MemoryTracker* memory_tracker, |
| new MemoryTypeTracker(memory_tracker, MemoryTracker::kManaged)), |
| memory_tracker_unmanaged_( |
| new MemoryTypeTracker(memory_tracker, MemoryTracker::kUnmanaged)), |
| + memory_tracker_(memory_tracker), |
| feature_info_(feature_info), |
| framebuffer_manager_(NULL), |
| max_texture_size_(max_texture_size), |
| @@ -1375,6 +1380,9 @@ bool TextureManager::Initialize() { |
| GL_TEXTURE_RECTANGLE_ARB, &black_texture_ids_[kRectangleARB]); |
| } |
| + base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| + this); |
|
reveman
2015/07/24 21:16:36
You'll need to provide a ThreadTaskRunnerHandle he
ericrk
2015/07/28 21:02:32
Done.
|
| + |
| return true; |
| } |
| @@ -2027,5 +2035,47 @@ ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
| base::TimeTicks::Now() - begin_time_; |
| } |
| +bool TextureManager::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd) { |
| + for (const auto& resource : textures_) { |
| + // Only dump memory info for textures actually owned by this TextureManager. |
| + if (resource.second == resource.second->texture()->memory_tracking_ref_) { |
| + DumpTextureRef(pmd, resource.second.get()); |
| + } |
| + } |
| + |
| + // Also dump TextureManager internal textures, if allocated. |
| + for (int i = 0; i < kNumDefaultTextures; i++) { |
| + if (default_textures_[i]) { |
| + DumpTextureRef(pmd, default_textures_[i].get()); |
| + } |
| + } |
| + |
| + return true; |
| +} |
| + |
| +void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, |
| + TextureRef* ref) { |
| + uint32_t size = ref->texture()->estimated_size(); |
| + |
| + // Ignore unallocated texture IDs. |
| + if (size == 0) |
| + return; |
| + |
| + uint64_t tracing_id = memory_tracker_->ClientTracingId(); |
| + std::string dump_name = base::StringPrintf( |
| + "gl/process_%" PRIx64 "/textures/%d", tracing_id, ref->client_id()); |
|
reveman
2015/07/24 21:16:36
s/%" PRIx64 "/%d/
nit: "gl/textures/client_%d/tex
ericrk
2015/07/28 21:02:32
Re-worked this to be consistent with gpu-memory-bu
|
| + base::trace_event::MemoryAllocatorDump* dump = |
| + pmd->CreateAllocatorDump(dump_name); |
| + dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| + base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| + static_cast<uint64_t>(size)); |
| + |
| + // Add GUID info for shared ownership with client process. |
| + auto guid = base::trace_event::MemoryAllocatorDumpGuid(base::StringPrintf( |
| + "gl-x-process/%" PRIx64 "/texture_%d", tracing_id, ref->client_id())); |
|
reveman
2015/07/24 21:16:36
Can you move this logic to where it can be shared
ericrk
2015/07/28 21:02:32
Done.
|
| + pmd->CreateSharedGlobalAllocatorDump(guid); |
| + pmd->AddOwnershipEdge(dump->guid(), guid); |
| +} |
| + |
| } // namespace gles2 |
| } // namespace gpu |