| 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 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 Loading... |
| 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 |
| OLD | NEW |