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

Side by Side Diff: gpu/ipc/service/gpu_memory_manager.cc

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources Created 4 years, 8 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
« no previous file with comments | « gpu/ipc/service/gpu_memory_manager.h ('k') | gpu/ipc/service/gpu_memory_tracking.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/common/gpu/gpu_memory_manager.h" 5 #include "gpu/ipc/service/gpu_memory_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/process/process_handle.h" 12 #include "base/process/process_handle.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "content/common/gpu/gpu_channel_manager.h"
16 #include "content/common/gpu/gpu_channel_manager_delegate.h"
17 #include "content/common/gpu/gpu_memory_tracking.h"
18 #include "gpu/command_buffer/common/gpu_memory_allocation.h" 15 #include "gpu/command_buffer/common/gpu_memory_allocation.h"
19 #include "gpu/command_buffer/service/gpu_switches.h" 16 #include "gpu/command_buffer/service/gpu_switches.h"
20 #include "gpu/ipc/common/gpu_memory_uma_stats.h" 17 #include "gpu/ipc/common/gpu_memory_uma_stats.h"
21 #include "gpu/ipc/common/memory_stats.h" 18 #include "gpu/ipc/common/memory_stats.h"
19 #include "gpu/ipc/service/gpu_channel_manager.h"
20 #include "gpu/ipc/service/gpu_channel_manager_delegate.h"
21 #include "gpu/ipc/service/gpu_memory_tracking.h"
22 22
23 using gpu::MemoryAllocation; 23 namespace gpu {
24
25 namespace content {
26 namespace { 24 namespace {
27 25
28 const uint64_t kBytesAllocatedStep = 16 * 1024 * 1024; 26 const uint64_t kBytesAllocatedStep = 16 * 1024 * 1024;
29 27
30 void TrackValueChanged(uint64_t old_size, 28 void TrackValueChanged(uint64_t old_size,
31 uint64_t new_size, 29 uint64_t new_size,
32 uint64_t* total_size) { 30 uint64_t* total_size) {
33 DCHECK(new_size > old_size || *total_size >= (old_size - new_size)); 31 DCHECK(new_size > old_size || *total_size >= (old_size - new_size));
34 *total_size += (new_size - old_size); 32 *total_size += (new_size - old_size);
35 } 33 }
(...skipping 25 matching lines...) Expand all
61 SendUmaStatsToHost(); 59 SendUmaStatsToHost();
62 } 60 }
63 } 61 }
64 62
65 bool GpuMemoryManager::EnsureGPUMemoryAvailable(uint64_t /* size_needed */) { 63 bool GpuMemoryManager::EnsureGPUMemoryAvailable(uint64_t /* size_needed */) {
66 // TODO: Check if there is enough space. Lose contexts until there is. 64 // TODO: Check if there is enough space. Lose contexts until there is.
67 return true; 65 return true;
68 } 66 }
69 67
70 uint64_t GpuMemoryManager::GetTrackerMemoryUsage( 68 uint64_t GpuMemoryManager::GetTrackerMemoryUsage(
71 gpu::gles2::MemoryTracker* tracker) const { 69 gles2::MemoryTracker* tracker) const {
72 TrackingGroupMap::const_iterator tracking_group_it = 70 TrackingGroupMap::const_iterator tracking_group_it =
73 tracking_groups_.find(tracker); 71 tracking_groups_.find(tracker);
74 DCHECK(tracking_group_it != tracking_groups_.end()); 72 DCHECK(tracking_group_it != tracking_groups_.end());
75 return tracking_group_it->second->GetSize(); 73 return tracking_group_it->second->GetSize();
76 } 74 }
77 75
78 GpuMemoryTrackingGroup* GpuMemoryManager::CreateTrackingGroup( 76 GpuMemoryTrackingGroup* GpuMemoryManager::CreateTrackingGroup(
79 base::ProcessId pid, gpu::gles2::MemoryTracker* memory_tracker) { 77 base::ProcessId pid, gles2::MemoryTracker* memory_tracker) {
80 GpuMemoryTrackingGroup* tracking_group = new GpuMemoryTrackingGroup( 78 GpuMemoryTrackingGroup* tracking_group = new GpuMemoryTrackingGroup(
81 pid, memory_tracker, this); 79 pid, memory_tracker, this);
82 DCHECK(!tracking_groups_.count(tracking_group->GetMemoryTracker())); 80 DCHECK(!tracking_groups_.count(tracking_group->GetMemoryTracker()));
83 tracking_groups_.insert(std::make_pair(tracking_group->GetMemoryTracker(), 81 tracking_groups_.insert(std::make_pair(tracking_group->GetMemoryTracker(),
84 tracking_group)); 82 tracking_group));
85 return tracking_group; 83 return tracking_group;
86 } 84 }
87 85
88 void GpuMemoryManager::OnDestroyTrackingGroup( 86 void GpuMemoryManager::OnDestroyTrackingGroup(
89 GpuMemoryTrackingGroup* tracking_group) { 87 GpuMemoryTrackingGroup* tracking_group) {
90 DCHECK(tracking_groups_.count(tracking_group->GetMemoryTracker())); 88 DCHECK(tracking_groups_.count(tracking_group->GetMemoryTracker()));
91 tracking_groups_.erase(tracking_group->GetMemoryTracker()); 89 tracking_groups_.erase(tracking_group->GetMemoryTracker());
92 } 90 }
93 91
94 void GpuMemoryManager::GetVideoMemoryUsageStats( 92 void GpuMemoryManager::GetVideoMemoryUsageStats(
95 gpu::VideoMemoryUsageStats* video_memory_usage_stats) const { 93 VideoMemoryUsageStats* video_memory_usage_stats) const {
96 // For each context group, assign its memory usage to its PID 94 // For each context group, assign its memory usage to its PID
97 video_memory_usage_stats->process_map.clear(); 95 video_memory_usage_stats->process_map.clear();
98 for (TrackingGroupMap::const_iterator i = 96 for (TrackingGroupMap::const_iterator i =
99 tracking_groups_.begin(); i != tracking_groups_.end(); ++i) { 97 tracking_groups_.begin(); i != tracking_groups_.end(); ++i) {
100 const GpuMemoryTrackingGroup* tracking_group = i->second; 98 const GpuMemoryTrackingGroup* tracking_group = i->second;
101 video_memory_usage_stats->process_map[ 99 video_memory_usage_stats->process_map[
102 tracking_group->GetPid()].video_memory += tracking_group->GetSize(); 100 tracking_group->GetPid()].video_memory += tracking_group->GetSize();
103 } 101 }
104 102
105 // Assign the total across all processes in the GPU process 103 // Assign the total across all processes in the GPU process
106 video_memory_usage_stats->process_map[ 104 video_memory_usage_stats->process_map[
107 base::GetCurrentProcId()].video_memory = GetCurrentUsage(); 105 base::GetCurrentProcId()].video_memory = GetCurrentUsage();
108 video_memory_usage_stats->process_map[ 106 video_memory_usage_stats->process_map[
109 base::GetCurrentProcId()].has_duplicates = true; 107 base::GetCurrentProcId()].has_duplicates = true;
110 108
111 video_memory_usage_stats->bytes_allocated = GetCurrentUsage(); 109 video_memory_usage_stats->bytes_allocated = GetCurrentUsage();
112 video_memory_usage_stats->bytes_allocated_historical_max = 110 video_memory_usage_stats->bytes_allocated_historical_max =
113 bytes_allocated_historical_max_; 111 bytes_allocated_historical_max_;
114 } 112 }
115 113
116 void GpuMemoryManager::SendUmaStatsToHost() { 114 void GpuMemoryManager::SendUmaStatsToHost() {
117 if (!channel_manager_) 115 if (!channel_manager_)
118 return; 116 return;
119 gpu::GPUMemoryUmaStats params; 117 GPUMemoryUmaStats params;
120 params.bytes_allocated_current = GetCurrentUsage(); 118 params.bytes_allocated_current = GetCurrentUsage();
121 params.bytes_allocated_max = bytes_allocated_historical_max_; 119 params.bytes_allocated_max = bytes_allocated_historical_max_;
122 params.context_group_count = static_cast<uint32_t>(tracking_groups_.size()); 120 params.context_group_count = static_cast<uint32_t>(tracking_groups_.size());
123 channel_manager_->delegate()->GpuMemoryUmaStats(params); 121 channel_manager_->delegate()->GpuMemoryUmaStats(params);
124 } 122 }
125 } // namespace content 123 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_memory_manager.h ('k') | gpu/ipc/service/gpu_memory_tracking.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698