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

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

Issue 2372593003: Iterative cleanup for GL programs in GPU process (Closed)
Patch Set: fix build Created 4 years, 2 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_channel_manager.h ('k') | no next file » | 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 "gpu/ipc/service/gpu_channel_manager.h" 5 #include "gpu/ipc/service/gpu_channel_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 22 matching lines...) Expand all
33 33
34 namespace { 34 namespace {
35 #if defined(OS_ANDROID) 35 #if defined(OS_ANDROID)
36 // Amount of time we expect the GPU to stay powered up without being used. 36 // Amount of time we expect the GPU to stay powered up without being used.
37 const int kMaxGpuIdleTimeMs = 40; 37 const int kMaxGpuIdleTimeMs = 40;
38 // Maximum amount of time we keep pinging the GPU waiting for the client to 38 // Maximum amount of time we keep pinging the GPU waiting for the client to
39 // draw. 39 // draw.
40 const int kMaxKeepAliveTimeMs = 200; 40 const int kMaxKeepAliveTimeMs = 200;
41 #endif 41 #endif
42 42
43 // The maximum amount of time we will spend deleting channels before yielding
44 // to other tasks.
45 const int kMaxChannelDeleterRuntimeS = 1;
43 } 46 }
44 47
45 GpuChannelManager::GpuChannelManager( 48 GpuChannelManager::GpuChannelManager(
46 const GpuPreferences& gpu_preferences, 49 const GpuPreferences& gpu_preferences,
47 GpuChannelManagerDelegate* delegate, 50 GpuChannelManagerDelegate* delegate,
48 GpuWatchdogThread* watchdog, 51 GpuWatchdogThread* watchdog,
49 base::SingleThreadTaskRunner* task_runner, 52 base::SingleThreadTaskRunner* task_runner,
50 base::SingleThreadTaskRunner* io_task_runner, 53 base::SingleThreadTaskRunner* io_task_runner,
51 base::WaitableEvent* shutdown_event, 54 base::WaitableEvent* shutdown_event,
52 SyncPointManager* sync_point_manager, 55 SyncPointManager* sync_point_manager,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 109 }
107 110
108 gles2::FramebufferCompletenessCache* 111 gles2::FramebufferCompletenessCache*
109 GpuChannelManager::framebuffer_completeness_cache() { 112 GpuChannelManager::framebuffer_completeness_cache() {
110 if (!framebuffer_completeness_cache_.get()) 113 if (!framebuffer_completeness_cache_.get())
111 framebuffer_completeness_cache_ = 114 framebuffer_completeness_cache_ =
112 new gles2::FramebufferCompletenessCache; 115 new gles2::FramebufferCompletenessCache;
113 return framebuffer_completeness_cache_.get(); 116 return framebuffer_completeness_cache_.get();
114 } 117 }
115 118
119 void GpuChannelManager::RunChannelDeleter() {
120 base::TimeTicks timeout =
121 base::TimeTicks::Now() +
122 base::TimeDelta::FromSeconds(kMaxChannelDeleterRuntimeS);
123
124 for (; pending_deleters_.size() > 0; pending_deleters_.pop()) {
125 if (!pending_deleters_.front()->DeleteWithTimeout(timeout)) {
126 // If DeleteWithTimeout returns false, the timeout was reached
127 // before deletion completed. We should not continue deleting.
128 break;
129 }
130 }
131
132 if (pending_deleters_.size() > 0) {
133 task_runner_->PostTask(FROM_HERE,
134 base::Bind(&GpuChannelManager::RunChannelDeleter,
135 weak_factory_.GetWeakPtr()));
136 } else {
137 channel_deleter_running_ = false;
138 }
139 }
140
116 void GpuChannelManager::RemoveChannel(int client_id) { 141 void GpuChannelManager::RemoveChannel(int client_id) {
117 delegate_->DidDestroyChannel(client_id); 142 delegate_->DidDestroyChannel(client_id);
118 gpu_channels_.erase(client_id); 143 pending_deleters_.emplace(
144 new GpuChannelDeleter(gpu_channels_.take_and_erase(client_id)));
145 if (!channel_deleter_running_) {
146 channel_deleter_running_ = true;
147 task_runner_->PostTask(FROM_HERE,
148 base::Bind(&GpuChannelManager::RunChannelDeleter,
149 weak_factory_.GetWeakPtr()));
150 }
119 } 151 }
120 152
121 GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const { 153 GpuChannel* GpuChannelManager::LookupChannel(int32_t client_id) const {
122 const auto& it = gpu_channels_.find(client_id); 154 const auto& it = gpu_channels_.find(client_id);
123 return it != gpu_channels_.end() ? it->second : nullptr; 155 return it != gpu_channels_.end() ? it->second : nullptr;
124 } 156 }
125 157
126 std::unique_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( 158 std::unique_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel(
127 int client_id, 159 int client_id,
128 uint64_t client_tracing_id, 160 uint64_t client_tracing_id,
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 315 }
284 } 316 }
285 if (!stub || !stub->decoder()->MakeCurrent()) 317 if (!stub || !stub->decoder()->MakeCurrent())
286 return; 318 return;
287 glFinish(); 319 glFinish();
288 DidAccessGpu(); 320 DidAccessGpu();
289 } 321 }
290 #endif 322 #endif
291 323
292 } // namespace gpu 324 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_channel_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698