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 #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 Loading... |
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 base::SharedMemoryTracker::AddOwnershipEdges(pmd, dump->guid(), |
| 747 *shared_memory); |
| 748 } else { |
| 749 auto guid = gl::GetGLBufferGUIDForTracing(share_group_tracing_guid, |
| 750 client_buffer_id); |
| 751 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 752 pmd->AddOwnershipEdge(dump->guid(), guid); |
| 753 } |
744 } | 754 } |
745 | 755 |
746 return true; | 756 return true; |
747 } | 757 } |
748 | 758 |
749 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, | 759 Buffer* BufferManager::RequestBufferAccess(ContextState* context_state, |
750 GLenum target, | 760 GLenum target, |
751 GLintptr offset, | 761 GLintptr offset, |
752 GLsizeiptr size, | 762 GLsizeiptr size, |
753 const char* func_name) { | 763 const char* func_name) { |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 message_tag.c_str()); | 887 message_tag.c_str()); |
878 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, | 888 ERRORSTATE_SET_GL_ERROR(error_state, GL_INVALID_OPERATION, func_name, |
879 msg.c_str()); | 889 msg.c_str()); |
880 return false; | 890 return false; |
881 } | 891 } |
882 return true; | 892 return true; |
883 } | 893 } |
884 | 894 |
885 } // namespace gles2 | 895 } // namespace gles2 |
886 } // namespace gpu | 896 } // namespace gpu |
OLD | NEW |