Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (rebase) Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
11 #include <GLES2/gl2extchromium.h> 11 #include <GLES2/gl2extchromium.h>
12 #include <GLES3/gl3.h> 12 #include <GLES3/gl3.h>
13 #include <stddef.h> 13 #include <stddef.h>
14 #include <stdint.h> 14 #include <stdint.h>
15 #include <algorithm> 15 #include <algorithm>
16 #include <map> 16 #include <map>
17 #include <set> 17 #include <set>
18 #include <sstream> 18 #include <sstream>
19 #include <string> 19 #include <string>
20 #include "base/atomic_sequence_num.h" 20 #include "base/atomic_sequence_num.h"
21 #include "base/bits.h" 21 #include "base/bits.h"
22 #include "base/compiler_specific.h" 22 #include "base/compiler_specific.h"
23 #include "base/memory/shared_memory_tracker.h"
23 #include "base/numerics/safe_math.h" 24 #include "base/numerics/safe_math.h"
24 #include "base/strings/string_split.h" 25 #include "base/strings/string_split.h"
25 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
26 #include "base/sys_info.h" 27 #include "base/sys_info.h"
27 #include "base/threading/thread_task_runner_handle.h" 28 #include "base/threading/thread_task_runner_handle.h"
28 #include "base/trace_event/memory_allocator_dump.h" 29 #include "base/trace_event/memory_allocator_dump.h"
29 #include "base/trace_event/memory_dump_manager.h" 30 #include "base/trace_event/memory_dump_manager.h"
30 #include "base/trace_event/process_memory_dump.h" 31 #include "base/trace_event/process_memory_dump.h"
31 #include "base/trace_event/trace_event.h" 32 #include "base/trace_event/trace_event.h"
32 #include "gpu/command_buffer/client/buffer_tracker.h" 33 #include "gpu/command_buffer/client/buffer_tracker.h"
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 base::trace_event::ProcessMemoryDump* pmd) { 446 base::trace_event::ProcessMemoryDump* pmd) {
446 using base::trace_event::MemoryAllocatorDump; 447 using base::trace_event::MemoryAllocatorDump;
447 using base::trace_event::MemoryDumpLevelOfDetail; 448 using base::trace_event::MemoryDumpLevelOfDetail;
448 449
449 // Dump owned MappedMemoryManager memory as well. 450 // Dump owned MappedMemoryManager memory as well.
450 mapped_memory_->OnMemoryDump(args, pmd); 451 mapped_memory_->OnMemoryDump(args, pmd);
451 452
452 if (!transfer_buffer_->HaveBuffer()) 453 if (!transfer_buffer_->HaveBuffer())
453 return true; 454 return true;
454 455
455 const uint64_t tracing_process_id =
456 base::trace_event::MemoryDumpManager::GetInstance()
457 ->GetTracingProcessId();
458
459 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( 456 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf(
460 "gpu/transfer_buffer_memory/buffer_%d", transfer_buffer_->GetShmId())); 457 "gpu/transfer_buffer_memory/buffer_%d", transfer_buffer_->GetShmId()));
461 dump->AddScalar(MemoryAllocatorDump::kNameSize, 458 dump->AddScalar(MemoryAllocatorDump::kNameSize,
462 MemoryAllocatorDump::kUnitsBytes, 459 MemoryAllocatorDump::kUnitsBytes,
463 transfer_buffer_->GetSize()); 460 transfer_buffer_->GetSize());
464 461
465 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) { 462 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) {
466 dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, 463 dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes,
467 transfer_buffer_->GetFreeSize()); 464 transfer_buffer_->GetFreeSize());
468 auto guid = GetBufferGUIDForTracing(tracing_process_id, 465 auto* shared_memory = transfer_buffer_->GetSharedMemory();
469 transfer_buffer_->GetShmId()); 466 if (shared_memory) {
470 const int kImportance = 2; 467 base::SharedMemoryTracker::AddOwnershipEdges(pmd, dump->guid(),
471 pmd->CreateSharedGlobalAllocatorDump(guid); 468 *shared_memory);
472 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 469 } else {
470 const uint64_t tracing_process_id =
471 base::trace_event::MemoryDumpManager::GetInstance()
472 ->GetTracingProcessId();
473 auto guid = GetBufferGUIDForTracing(tracing_process_id,
474 transfer_buffer_->GetShmId());
475 const int kImportance = 2;
476 pmd->CreateSharedGlobalAllocatorDump(guid);
477 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
478 }
473 } 479 }
474 480
475 return true; 481 return true;
476 } 482 }
477 483
478 void GLES2Implementation::WaitForCmd() { 484 void GLES2Implementation::WaitForCmd() {
479 TRACE_EVENT0("gpu", "GLES2::WaitForCmd"); 485 TRACE_EVENT0("gpu", "GLES2::WaitForCmd");
480 helper_->CommandBufferHelper::Finish(); 486 helper_->CommandBufferHelper::Finish();
481 } 487 }
482 488
(...skipping 6626 matching lines...) Expand 10 before | Expand all | Expand 10 after
7109 CheckGLError(); 7115 CheckGLError();
7110 } 7116 }
7111 7117
7112 // Include the auto-generated part of this file. We split this because it means 7118 // Include the auto-generated part of this file. We split this because it means
7113 // we can easily edit the non-auto generated parts right here in this file 7119 // we can easily edit the non-auto generated parts right here in this file
7114 // instead of having to edit some template or the code generator. 7120 // instead of having to edit some template or the code generator.
7115 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 7121 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
7116 7122
7117 } // namespace gles2 7123 } // namespace gles2
7118 } // namespace gpu 7124 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.cc ('k') | gpu/command_buffer/client/gles2_implementation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698