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

Side by Side Diff: gpu/command_buffer/service/buffer_manager.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: Implement buckets Created 3 years, 11 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 #include "gpu/command_buffer/service/buffer_manager.h" 5 #include "gpu/command_buffer/service/buffer_manager.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/shared_memory_tracker.h"
13 #include "base/numerics/safe_math.h" 14 #include "base/numerics/safe_math.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/trace_event/memory_dump_manager.h" 17 #include "base/trace_event/memory_dump_manager.h"
17 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
18 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 19 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
19 #include "gpu/command_buffer/service/context_state.h" 20 #include "gpu/command_buffer/service/context_state.h"
20 #include "gpu/command_buffer/service/error_state.h" 21 #include "gpu/command_buffer/service/error_state.h"
21 #include "gpu/command_buffer/service/feature_info.h" 22 #include "gpu/command_buffer/service/feature_info.h"
22 #include "gpu/command_buffer/service/memory_tracking.h" 23 #include "gpu/command_buffer/service/memory_tracking.h"
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 const auto& buffer = buffer_entry.second; 731 const auto& buffer = buffer_entry.second;
731 732
732 std::string dump_name = 733 std::string dump_name =
733 base::StringPrintf("gpu/gl/buffers/share_group_%" PRIu64 "/buffer_%d", 734 base::StringPrintf("gpu/gl/buffers/share_group_%" PRIu64 "/buffer_%d",
734 share_group_tracing_guid, client_buffer_id); 735 share_group_tracing_guid, client_buffer_id);
735 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); 736 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
736 dump->AddScalar(MemoryAllocatorDump::kNameSize, 737 dump->AddScalar(MemoryAllocatorDump::kNameSize,
737 MemoryAllocatorDump::kUnitsBytes, 738 MemoryAllocatorDump::kUnitsBytes,
738 static_cast<uint64_t>(buffer->size())); 739 static_cast<uint64_t>(buffer->size()));
739 740
740 auto guid = gl::GetGLBufferGUIDForTracing(share_group_tracing_guid, 741 auto mapped_range = buffer->GetMappedRange();
741 client_buffer_id); 742 if (!mapped_range)
742 pmd->CreateSharedGlobalAllocatorDump(guid); 743 continue;
743 pmd->AddOwnershipEdge(dump->guid(), guid); 744 auto shared_memory = mapped_range->shm->backing()->shared_memory();
745 if (shared_memory) {
746 auto guid = gl::GetGLBufferGUIDForTracing(share_group_tracing_guid,
747 client_buffer_id);
748 pmd->CreateSharedGlobalAllocatorDump(guid);
749 pmd->AddOwnershipEdge(dump->guid(), guid);
750 base::SharedMemoryTracker::AddOwnershipEdgeToSharedGlobalDump(pmd, guid,
751 shared_memory->handle(), shared_memory->mapped_size());
752 }
744 } 753 }
745 754
746 return true; 755 return true;
747 } 756 }
748 757
749 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, 758 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state,
750 GLenum target, 759 GLenum target,
751 GLintptr offset, 760 GLintptr offset,
752 GLsizeiptr size, 761 GLsizeiptr size,
753 const char* func_name) { 762 const char* func_name) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 message_tag.c_str()); 886 message_tag.c_str());
878 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, 887 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name,
879 msg.c_str()); 888 msg.c_str());
880 return false; 889 return false;
881 } 890 }
882 return true; 891 return true;
883 } 892 }
884 893
885 } // namespace gles2 894 } // namespace gles2
886 } // namespace gpu 895 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698