| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains the implementation of the command buffer helper class. | 5 // This file contains the implementation of the command buffer helper class. |
| 6 | 6 |
| 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/shared_memory_tracker.h" |
| 13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "base/trace_event/memory_allocator_dump.h" | 17 #include "base/trace_event/memory_allocator_dump.h" |
| 17 #include "base/trace_event/memory_dump_manager.h" | 18 #include "base/trace_event/memory_dump_manager.h" |
| 18 #include "base/trace_event/process_memory_dump.h" | 19 #include "base/trace_event/process_memory_dump.h" |
| 19 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
| 20 #include "gpu/command_buffer/common/buffer.h" | 21 #include "gpu/command_buffer/common/buffer.h" |
| 21 #include "gpu/command_buffer/common/command_buffer.h" | 22 #include "gpu/command_buffer/common/command_buffer.h" |
| 22 #include "gpu/command_buffer/common/constants.h" | 23 #include "gpu/command_buffer/common/constants.h" |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 358 |
| 358 bool CommandBufferHelper::OnMemoryDump( | 359 bool CommandBufferHelper::OnMemoryDump( |
| 359 const base::trace_event::MemoryDumpArgs& args, | 360 const base::trace_event::MemoryDumpArgs& args, |
| 360 base::trace_event::ProcessMemoryDump* pmd) { | 361 base::trace_event::ProcessMemoryDump* pmd) { |
| 361 using base::trace_event::MemoryAllocatorDump; | 362 using base::trace_event::MemoryAllocatorDump; |
| 362 using base::trace_event::MemoryDumpLevelOfDetail; | 363 using base::trace_event::MemoryDumpLevelOfDetail; |
| 363 | 364 |
| 364 if (!HaveRingBuffer()) | 365 if (!HaveRingBuffer()) |
| 365 return true; | 366 return true; |
| 366 | 367 |
| 367 const uint64_t tracing_process_id = | |
| 368 base::trace_event::MemoryDumpManager::GetInstance() | |
| 369 ->GetTracingProcessId(); | |
| 370 | |
| 371 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( | 368 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( |
| 372 "gpu/command_buffer_memory/buffer_%d", ring_buffer_id_)); | 369 "gpu/command_buffer_memory/buffer_%d", ring_buffer_id_)); |
| 373 dump->AddScalar(MemoryAllocatorDump::kNameSize, | 370 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 374 MemoryAllocatorDump::kUnitsBytes, ring_buffer_size_); | 371 MemoryAllocatorDump::kUnitsBytes, ring_buffer_size_); |
| 375 | 372 |
| 376 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) { | 373 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) { |
| 377 dump->AddScalar( | 374 dump->AddScalar( |
| 378 "free_size", MemoryAllocatorDump::kUnitsBytes, | 375 "free_size", MemoryAllocatorDump::kUnitsBytes, |
| 379 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry)); | 376 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry)); |
| 380 auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_); | 377 auto* shared_memory = ring_buffer_->backing()->shared_memory(); |
| 381 const int kImportance = 2; | 378 if (shared_memory) { |
| 382 pmd->CreateSharedGlobalAllocatorDump(guid); | 379 // TODO: Importance |
| 383 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 380 base::SharedMemoryTracker::AddOwnershipEdges( |
| 381 pmd, dump->guid(), shared_memory->handle(), |
| 382 shared_memory->mapped_size()); |
| 383 } |
| 384 } | 384 } |
| 385 | 385 |
| 386 return true; | 386 return true; |
| 387 } | 387 } |
| 388 | 388 |
| 389 } // namespace gpu | 389 } // namespace gpu |
| OLD | NEW |