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

Side by Side Diff: content/common/gpu/gpu_memory_manager.h

Issue 12475002: Delete memory manager dead code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve against CrOS changes Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | content/common/gpu/gpu_memory_manager.cc » ('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 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ 5 #ifndef CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_
6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ 6 #define CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // Schedule a Manage() call. If immediate is true, we PostTask without delay. 48 // Schedule a Manage() call. If immediate is true, we PostTask without delay.
49 // Otherwise PostDelayedTask using a CancelableClosure and allow multiple 49 // Otherwise PostDelayedTask using a CancelableClosure and allow multiple
50 // delayed calls to "queue" up. This way, we do not spam clients in certain 50 // delayed calls to "queue" up. This way, we do not spam clients in certain
51 // lower priority situations. An immediate schedule manage will cancel any 51 // lower priority situations. An immediate schedule manage will cancel any
52 // queued delayed manage. 52 // queued delayed manage.
53 void ScheduleManage(ScheduleManageTime schedule_manage_time); 53 void ScheduleManage(ScheduleManageTime schedule_manage_time);
54 54
55 // Retrieve GPU Resource consumption statistics for the task manager 55 // Retrieve GPU Resource consumption statistics for the task manager
56 void GetVideoMemoryUsageStats( 56 void GetVideoMemoryUsageStats(
57 content::GPUVideoMemoryUsageStats* video_memory_usage_stats) const; 57 content::GPUVideoMemoryUsageStats* video_memory_usage_stats) const;
58 void SetWindowCount(uint32 count);
59 58
60 GpuMemoryManagerClientState* CreateClientState( 59 GpuMemoryManagerClientState* CreateClientState(
61 GpuMemoryManagerClient* client, bool has_surface, bool visible); 60 GpuMemoryManagerClient* client, bool has_surface, bool visible);
62 61
63 GpuMemoryTrackingGroup* CreateTrackingGroup( 62 GpuMemoryTrackingGroup* CreateTrackingGroup(
64 base::ProcessId pid, gpu::gles2::MemoryTracker* memory_tracker); 63 base::ProcessId pid, gpu::gles2::MemoryTracker* memory_tracker);
65 64
66 private: 65 private:
67 friend class GpuMemoryManagerTest; 66 friend class GpuMemoryManagerTest;
68 friend class GpuMemoryTrackingGroup; 67 friend class GpuMemoryTrackingGroup;
69 friend class GpuMemoryManagerClientState; 68 friend class GpuMemoryManagerClientState;
70 69
71 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 70 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
72 ComparatorTests);
73 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
74 TestManageBasicFunctionality); 71 TestManageBasicFunctionality);
75 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 72 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
76 TestManageChangingVisibility); 73 TestManageChangingVisibility);
77 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 74 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
78 TestManageManyVisibleStubs); 75 TestManageManyVisibleStubs);
79 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 76 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
80 TestManageManyNotVisibleStubs); 77 TestManageManyNotVisibleStubs);
81 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 78 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
82 TestManageChangingLastUsedTime); 79 TestManageChangingLastUsedTime);
83 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 80 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
84 TestManageChangingImportanceShareGroup); 81 TestManageChangingImportanceShareGroup);
85 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 82 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
86 TestForegroundStubsGetBonusAllocation); 83 TestForegroundStubsGetBonusAllocation);
87 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 84 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
88 TestUpdateAvailableGpuMemory); 85 TestUpdateAvailableGpuMemory);
89 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 86 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
90 GpuMemoryAllocationCompareTests); 87 GpuMemoryAllocationCompareTests);
91 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 88 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
92 StubMemoryStatsForLastManageTests); 89 StubMemoryStatsForLastManageTests);
93 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 90 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
94 TestManagedUsageTracking); 91 TestManagedUsageTracking);
95 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 92 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
96 TestBackgroundCutoff); 93 BackgroundMru);
97 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 94 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
98 TestBackgroundMru); 95 BackgroundDiscardPersistent);
99 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest, 96 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
100 TestUnmanagedTracking);
101
102 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform,
103 BackgroundMru);
104 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform,
105 BackgroundDiscardPersistent);
106 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform,
107 UnmanagedTracking); 97 UnmanagedTracking);
108 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTestNonuniform, 98 FRIEND_TEST_ALL_PREFIXES(GpuMemoryManagerTest,
109 DefaultAllocation); 99 DefaultAllocation);
110 100
111 typedef std::map<gpu::gles2::MemoryTracker*, GpuMemoryTrackingGroup*> 101 typedef std::map<gpu::gles2::MemoryTracker*, GpuMemoryTrackingGroup*>
112 TrackingGroupMap; 102 TrackingGroupMap;
113 103
114 typedef std::list<GpuMemoryManagerClientState*> ClientStateList; 104 typedef std::list<GpuMemoryManagerClientState*> ClientStateList;
115 105
116 void Manage(); 106 void Manage();
117 void SetClientsHibernatedState() const; 107 void SetClientsHibernatedState() const;
118 uint64 GetVisibleClientAllocation() const; 108 void AssignSurfacesAllocations();
119 uint64 GetCurrentNonvisibleAvailableGpuMemory() const;
120 void AssignSurfacesAllocationsNonuniform();
121 void AssignSurfacesAllocationsUniform();
122 void AssignNonSurfacesAllocations(); 109 void AssignNonSurfacesAllocations();
123 110
124 // Math helper function to compute the maximum value of cap such that 111 // Math helper function to compute the maximum value of cap such that
125 // sum_i min(bytes[i], cap) <= bytes_sum_limit 112 // sum_i min(bytes[i], cap) <= bytes_sum_limit
126 static uint64 ComputeCap(std::vector<uint64> bytes, uint64 bytes_sum_limit); 113 static uint64 ComputeCap(std::vector<uint64> bytes, uint64 bytes_sum_limit);
127 114
128 // Compute the allocation for clients when visible and not visible. 115 // Compute the allocation for clients when visible and not visible.
129 void ComputeVisibleSurfacesAllocationsNonuniform(); 116 void ComputeVisibleSurfacesAllocations();
130 void ComputeNonvisibleSurfacesAllocationsNonuniform(); 117 void ComputeNonvisibleSurfacesAllocations();
131 void DistributeRemainingMemoryToVisibleSurfaces(); 118 void DistributeRemainingMemoryToVisibleSurfaces();
132 119
133 // Compute the budget for a client. Allow at most bytes_above_required_cap 120 // Compute the budget for a client. Allow at most bytes_above_required_cap
134 // bytes above client_state's required level. Allow at most 121 // bytes above client_state's required level. Allow at most
135 // bytes_above_minimum_cap bytes above client_state's minimum level. Allow 122 // bytes_above_minimum_cap bytes above client_state's minimum level. Allow
136 // at most bytes_overall_cap bytes total. 123 // at most bytes_overall_cap bytes total.
137 uint64 ComputeClientAllocationWhenVisible( 124 uint64 ComputeClientAllocationWhenVisible(
138 GpuMemoryManagerClientState* client_state, 125 GpuMemoryManagerClientState* client_state,
139 uint64 bytes_above_required_cap, 126 uint64 bytes_above_required_cap,
140 uint64 bytes_above_minimum_cap, 127 uint64 bytes_above_minimum_cap,
141 uint64 bytes_overall_cap); 128 uint64 bytes_overall_cap);
142 uint64 ComputeClientAllocationWhenNonvisible( 129 uint64 ComputeClientAllocationWhenNonvisible(
143 GpuMemoryManagerClientState* client_state); 130 GpuMemoryManagerClientState* client_state);
144 131
145 // Update the amount of GPU memory we think we have in the system, based 132 // Update the amount of GPU memory we think we have in the system, based
146 // on what the stubs' contexts report. 133 // on what the stubs' contexts report.
147 void UpdateAvailableGpuMemory(); 134 void UpdateAvailableGpuMemory();
148 void UpdateUnmanagedMemoryLimits(); 135 void UpdateUnmanagedMemoryLimits();
149 void UpdateNonvisibleAvailableGpuMemory();
150 136
151 // The amount of video memory which is available for allocation. 137 // The amount of video memory which is available for allocation.
152 uint64 GetAvailableGpuMemory() const; 138 uint64 GetAvailableGpuMemory() const;
153 139
154 // Minimum value of available GPU memory, no matter how little the GPU 140 // Minimum value of available GPU memory, no matter how little the GPU
155 // reports. This is the default value. 141 // reports. This is the default value.
156 uint64 GetDefaultAvailableGpuMemory() const; 142 uint64 GetDefaultAvailableGpuMemory() const;
157 143
158 // Maximum cap on total GPU memory, no matter how much the GPU reports. 144 // Maximum cap on total GPU memory, no matter how much the GPU reports.
159 uint64 GetMaximumTotalGpuMemory() const; 145 uint64 GetMaximumTotalGpuMemory() const;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 const GpuManagedMemoryStats& stats); 183 const GpuManagedMemoryStats& stats);
198 void OnDestroyClientState(GpuMemoryManagerClientState* client); 184 void OnDestroyClientState(GpuMemoryManagerClientState* client);
199 185
200 // Add or remove a client from its clients list (visible, nonvisible, or 186 // Add or remove a client from its clients list (visible, nonvisible, or
201 // nonsurface). When adding the client, add it to the front of the list. 187 // nonsurface). When adding the client, add it to the front of the list.
202 void AddClientToList(GpuMemoryManagerClientState* client_state); 188 void AddClientToList(GpuMemoryManagerClientState* client_state);
203 void RemoveClientFromList(GpuMemoryManagerClientState* client_state); 189 void RemoveClientFromList(GpuMemoryManagerClientState* client_state);
204 ClientStateList* GetClientList(GpuMemoryManagerClientState* client_state); 190 ClientStateList* GetClientList(GpuMemoryManagerClientState* client_state);
205 191
206 // Interfaces for testing 192 // Interfaces for testing
207 void TestingSetUseNonuniformMemoryPolicy(bool use_nonuniform_memory_policy) {
208 use_nonuniform_memory_policy_ = use_nonuniform_memory_policy;
209 }
210 void TestingDisableScheduleManage() { disable_schedule_manage_ = true; } 193 void TestingDisableScheduleManage() { disable_schedule_manage_ = true; }
211 void TestingSetAvailableGpuMemory(uint64 bytes) { 194 void TestingSetAvailableGpuMemory(uint64 bytes) {
212 bytes_available_gpu_memory_ = bytes; 195 bytes_available_gpu_memory_ = bytes;
213 bytes_available_gpu_memory_overridden_ = true; 196 bytes_available_gpu_memory_overridden_ = true;
214 } 197 }
215 198
216 void TestingSetMinimumClientAllocation(uint64 bytes) { 199 void TestingSetMinimumClientAllocation(uint64 bytes) {
217 bytes_minimum_per_client_ = bytes; 200 bytes_minimum_per_client_ = bytes;
218 } 201 }
219 202
220 void TestingSetDefaultClientAllocation(uint64 bytes) { 203 void TestingSetDefaultClientAllocation(uint64 bytes) {
221 bytes_default_per_client_ = bytes; 204 bytes_default_per_client_ = bytes;
222 } 205 }
223 206
224 void TestingSetUnmanagedLimitStep(uint64 bytes) { 207 void TestingSetUnmanagedLimitStep(uint64 bytes) {
225 bytes_unmanaged_limit_step_ = bytes; 208 bytes_unmanaged_limit_step_ = bytes;
226 } 209 }
227 210
228 void TestingSetNonvisibleAvailableGpuMemory(uint64 bytes) {
229 bytes_nonvisible_available_gpu_memory_ = bytes;
230 }
231
232 GpuChannelManager* channel_manager_; 211 GpuChannelManager* channel_manager_;
233 212
234 // The new memory policy does not uniformly assign memory to tabs, but
235 // scales the assignments to the tabs' needs.
236 bool use_nonuniform_memory_policy_;
237
238 // A list of all visible and nonvisible clients, in most-recently-used 213 // A list of all visible and nonvisible clients, in most-recently-used
239 // order (most recently used is first). 214 // order (most recently used is first).
240 ClientStateList clients_visible_mru_; 215 ClientStateList clients_visible_mru_;
241 ClientStateList clients_nonvisible_mru_; 216 ClientStateList clients_nonvisible_mru_;
242 217
243 // A list of all clients that don't have a surface. 218 // A list of all clients that don't have a surface.
244 ClientStateList clients_nonsurface_; 219 ClientStateList clients_nonsurface_;
245 220
246 // All context groups' tracking structures 221 // All context groups' tracking structures
247 TrackingGroupMap tracking_groups_; 222 TrackingGroupMap tracking_groups_;
248 223
249 base::CancelableClosure delayed_manage_callback_; 224 base::CancelableClosure delayed_manage_callback_;
250 bool manage_immediate_scheduled_; 225 bool manage_immediate_scheduled_;
251 226
252 uint64 max_surfaces_with_frontbuffer_soft_limit_; 227 uint64 max_surfaces_with_frontbuffer_soft_limit_;
253 228
254 // The maximum amount of memory that may be allocated for GPU resources 229 // The maximum amount of memory that may be allocated for GPU resources
255 uint64 bytes_available_gpu_memory_; 230 uint64 bytes_available_gpu_memory_;
256 bool bytes_available_gpu_memory_overridden_; 231 bool bytes_available_gpu_memory_overridden_;
257 232
258 // The minimum and default allocations for a single client. 233 // The minimum and default allocations for a single client.
259 uint64 bytes_minimum_per_client_; 234 uint64 bytes_minimum_per_client_;
260 uint64 bytes_default_per_client_; 235 uint64 bytes_default_per_client_;
261 236
262 // The maximum amount of memory that can be allocated for GPU resources
263 // in nonvisible renderers.
264 uint64 bytes_nonvisible_available_gpu_memory_;
265
266 // The current total memory usage, and historical maximum memory usage 237 // The current total memory usage, and historical maximum memory usage
267 uint64 bytes_allocated_managed_current_; 238 uint64 bytes_allocated_managed_current_;
268 uint64 bytes_allocated_managed_visible_; 239 uint64 bytes_allocated_managed_visible_;
269 uint64 bytes_allocated_managed_nonvisible_; 240 uint64 bytes_allocated_managed_nonvisible_;
270 uint64 bytes_allocated_unmanaged_current_; 241 uint64 bytes_allocated_unmanaged_current_;
271 uint64 bytes_allocated_historical_max_; 242 uint64 bytes_allocated_historical_max_;
272 243
273 // If bytes_allocated_unmanaged_current_ leaves the interval [low_, high_), 244 // If bytes_allocated_unmanaged_current_ leaves the interval [low_, high_),
274 // then ScheduleManage to take the change into account. 245 // then ScheduleManage to take the change into account.
275 uint64 bytes_allocated_unmanaged_high_; 246 uint64 bytes_allocated_unmanaged_high_;
276 uint64 bytes_allocated_unmanaged_low_; 247 uint64 bytes_allocated_unmanaged_low_;
277 248
278 // Update bytes_allocated_unmanaged_low/high_ in intervals of step_. 249 // Update bytes_allocated_unmanaged_low/high_ in intervals of step_.
279 uint64 bytes_unmanaged_limit_step_; 250 uint64 bytes_unmanaged_limit_step_;
280 251
281 // The number of browser windows that exist. If we ever receive a
282 // GpuMsg_SetVideoMemoryWindowCount, then we use this to compute memory
283 // allocations, instead of doing more complicated stub-based calculations.
284 bool window_count_has_been_received_;
285 uint32 window_count_;
286
287 // Used to disable automatic changes to Manage() in testing. 252 // Used to disable automatic changes to Manage() in testing.
288 bool disable_schedule_manage_; 253 bool disable_schedule_manage_;
289 254
290 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager); 255 DISALLOW_COPY_AND_ASSIGN(GpuMemoryManager);
291 }; 256 };
292 257
293 } // namespace content 258 } // namespace content
294 259
295 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_ 260 #endif // CONTENT_COMMON_GPU_GPU_MEMORY_MANAGER_H_
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.cc ('k') | content/common/gpu/gpu_memory_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698