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

Side by Side Diff: content/common/gpu/gpu_channel_manager.cc

Issue 1365563002: Make channel preemption not require view contexts for hookup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wakeup_gpu
Patch Set: fix build and broken rebase Created 5 years, 3 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
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_channel_manager.h" 5 #include "content/common/gpu/gpu_channel_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/location.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "content/common/gpu/gpu_channel.h" 14 #include "content/common/gpu/gpu_channel.h"
15 #include "content/common/gpu/gpu_memory_buffer_factory.h" 15 #include "content/common/gpu/gpu_memory_buffer_factory.h"
16 #include "content/common/gpu/gpu_memory_manager.h" 16 #include "content/common/gpu/gpu_memory_manager.h"
17 #include "content/common/gpu/gpu_messages.h" 17 #include "content/common/gpu/gpu_messages.h"
18 #include "content/common/message_router.h" 18 #include "content/common/message_router.h"
19 #include "content/public/common/content_switches.h"
19 #include "gpu/command_buffer/common/value_state.h" 20 #include "gpu/command_buffer/common/value_state.h"
20 #include "gpu/command_buffer/service/feature_info.h" 21 #include "gpu/command_buffer/service/feature_info.h"
21 #include "gpu/command_buffer/service/gpu_switches.h" 22 #include "gpu/command_buffer/service/gpu_switches.h"
22 #include "gpu/command_buffer/service/mailbox_manager.h" 23 #include "gpu/command_buffer/service/mailbox_manager.h"
23 #include "gpu/command_buffer/service/memory_program_cache.h" 24 #include "gpu/command_buffer/service/memory_program_cache.h"
24 #include "gpu/command_buffer/service/shader_translator_cache.h" 25 #include "gpu/command_buffer/service/shader_translator_cache.h"
25 #include "gpu/command_buffer/service/sync_point_manager.h" 26 #include "gpu/command_buffer/service/sync_point_manager.h"
26 #include "ipc/message_filter.h" 27 #include "ipc/message_filter.h"
27 #include "ui/gl/gl_bindings.h" 28 #include "ui/gl/gl_bindings.h"
28 #include "ui/gl/gl_share_group.h" 29 #include "ui/gl/gl_share_group.h"
(...skipping 17 matching lines...) Expand all
46 base::SingleThreadTaskRunner* task_runner, 47 base::SingleThreadTaskRunner* task_runner,
47 base::SingleThreadTaskRunner* io_task_runner, 48 base::SingleThreadTaskRunner* io_task_runner,
48 base::WaitableEvent* shutdown_event, 49 base::WaitableEvent* shutdown_event,
49 gpu::SyncPointManager* sync_point_manager, 50 gpu::SyncPointManager* sync_point_manager,
50 GpuMemoryBufferFactory* gpu_memory_buffer_factory) 51 GpuMemoryBufferFactory* gpu_memory_buffer_factory)
51 : task_runner_(task_runner), 52 : task_runner_(task_runner),
52 io_task_runner_(io_task_runner), 53 io_task_runner_(io_task_runner),
53 channel_(channel), 54 channel_(channel),
54 watchdog_(watchdog), 55 watchdog_(watchdog),
55 shutdown_event_(shutdown_event), 56 shutdown_event_(shutdown_event),
57 share_group_(new gfx::GLShareGroup),
58 mailbox_manager_(gpu::gles2::MailboxManager::Create()),
56 gpu_memory_manager_( 59 gpu_memory_manager_(
57 this, 60 this,
58 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), 61 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit),
59 sync_point_manager_(sync_point_manager), 62 sync_point_manager_(sync_point_manager),
60 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), 63 gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
61 weak_factory_(this) { 64 weak_factory_(this) {
62 DCHECK(task_runner); 65 DCHECK(task_runner);
63 DCHECK(io_task_runner); 66 DCHECK(io_task_runner);
67 const base::CommandLine* command_line =
68 base::CommandLine::ForCurrentProcess();
69 if (command_line->HasSwitch(switches::kUIPrioritizeInGpuProcess))
70 preemption_flag_ = new gpu::PreemptionFlag;
64 } 71 }
65 72
66 GpuChannelManager::~GpuChannelManager() { 73 GpuChannelManager::~GpuChannelManager() {
67 // Destroy channels before anything else because of dependencies. 74 // Destroy channels before anything else because of dependencies.
68 gpu_channels_.clear(); 75 gpu_channels_.clear();
69 if (default_offscreen_surface_.get()) { 76 if (default_offscreen_surface_.get()) {
70 default_offscreen_surface_->Destroy(); 77 default_offscreen_surface_->Destroy();
71 default_offscreen_surface_ = NULL; 78 default_offscreen_surface_ = NULL;
72 } 79 }
73 } 80 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 return OnControlMessageReceived(msg); 151 return OnControlMessageReceived(msg);
145 152
146 return router_.RouteMessage(msg); 153 return router_.RouteMessage(msg);
147 } 154 }
148 155
149 bool GpuChannelManager::Send(IPC::Message* msg) { 156 bool GpuChannelManager::Send(IPC::Message* msg) {
150 return channel_->Send(msg); 157 return channel_->Send(msg);
151 } 158 }
152 159
153 scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel( 160 scoped_ptr<GpuChannel> GpuChannelManager::CreateGpuChannel(
154 gfx::GLShareGroup* share_group,
155 gpu::gles2::MailboxManager* mailbox_manager,
156 int client_id, 161 int client_id,
157 uint64_t client_tracing_id, 162 uint64_t client_tracing_id,
163 bool preempts,
158 bool allow_future_sync_points, 164 bool allow_future_sync_points,
159 bool allow_real_time_streams) { 165 bool allow_real_time_streams) {
160 return make_scoped_ptr(new GpuChannel( 166 return make_scoped_ptr(
161 this, watchdog_, share_group, mailbox_manager, task_runner_.get(), 167 new GpuChannel(this, watchdog_, share_group(), mailbox_manager(),
162 io_task_runner_.get(), client_id, client_tracing_id, false, 168 preempts ? preemption_flag() : nullptr, task_runner_.get(),
163 allow_future_sync_points, allow_real_time_streams)); 169 io_task_runner_.get(), client_id, client_tracing_id,
170 allow_future_sync_points, allow_real_time_streams));
164 } 171 }
165 172
166 void GpuChannelManager::OnEstablishChannel(int client_id, 173 void GpuChannelManager::OnEstablishChannel(
167 uint64_t client_tracing_id, 174 const GpuMsg_EstablishChannel_Params& params) {
168 bool share_context, 175 DCHECK(!params.preempts || !params.preempted);
no sievers 2015/09/23 21:53:21 nit: don't feel strongly at all, but you could als
piman 2015/09/23 23:33:37 I'm expecting this to be superseded by the per-str
169 bool allow_future_sync_points, 176 scoped_ptr<GpuChannel> channel(CreateGpuChannel(
170 bool allow_real_time_streams) { 177 params.client_id, params.client_tracing_id, params.preempts,
171 gfx::GLShareGroup* share_group = nullptr; 178 params.allow_future_sync_points, params.allow_real_time_streams));
172 gpu::gles2::MailboxManager* mailbox_manager = nullptr; 179 if (params.preempted)
173 if (share_context) { 180 channel->SetPreemptByFlag(preemption_flag_.get());
174 if (!share_group_.get()) {
175 share_group_ = new gfx::GLShareGroup;
176 DCHECK(!mailbox_manager_.get());
177 mailbox_manager_ = gpu::gles2::MailboxManager::Create();
178 }
179 share_group = share_group_.get();
180 mailbox_manager = mailbox_manager_.get();
181 }
182
183 scoped_ptr<GpuChannel> channel = CreateGpuChannel(
184 share_group, mailbox_manager, client_id, client_tracing_id,
185 allow_future_sync_points, allow_real_time_streams);
186 IPC::ChannelHandle channel_handle = channel->Init(shutdown_event_); 181 IPC::ChannelHandle channel_handle = channel->Init(shutdown_event_);
187 182
188 gpu_channels_.set(client_id, channel.Pass()); 183 gpu_channels_.set(params.client_id, channel.Pass());
189 184
190 Send(new GpuHostMsg_ChannelEstablished(channel_handle)); 185 Send(new GpuHostMsg_ChannelEstablished(channel_handle));
191 } 186 }
192 187
193 void GpuChannelManager::OnCloseChannel( 188 void GpuChannelManager::OnCloseChannel(
194 const IPC::ChannelHandle& channel_handle) { 189 const IPC::ChannelHandle& channel_handle) {
195 for (auto it = gpu_channels_.begin(); it != gpu_channels_.end(); ++it) { 190 for (auto it = gpu_channels_.begin(); it != gpu_channels_.end(); ++it) {
196 if (it->second->channel_id() == channel_handle.name) { 191 if (it->second->channel_id() == channel_handle.name) {
197 gpu_channels_.erase(it); 192 gpu_channels_.erase(it);
198 return; 193 return;
199 } 194 }
200 } 195 }
201 } 196 }
202 197
203 void GpuChannelManager::OnCreateViewCommandBuffer( 198 void GpuChannelManager::OnCreateViewCommandBuffer(
204 const gfx::GLSurfaceHandle& window, 199 const gfx::GLSurfaceHandle& window,
205 int32 surface_id,
206 int32 client_id, 200 int32 client_id,
207 const GPUCreateCommandBufferConfig& init_params, 201 const GPUCreateCommandBufferConfig& init_params,
208 int32 route_id) { 202 int32 route_id) {
209 DCHECK(surface_id);
210 CreateCommandBufferResult result = CREATE_COMMAND_BUFFER_FAILED; 203 CreateCommandBufferResult result = CREATE_COMMAND_BUFFER_FAILED;
211 204
212 auto it = gpu_channels_.find(client_id); 205 auto it = gpu_channels_.find(client_id);
213 if (it != gpu_channels_.end()) { 206 if (it != gpu_channels_.end()) {
214 result = it->second->CreateViewCommandBuffer(window, surface_id, 207 result = it->second->CreateViewCommandBuffer(window, init_params, route_id);
215 init_params, route_id);
216 } 208 }
217 209
218 Send(new GpuHostMsg_CommandBufferCreated(result)); 210 Send(new GpuHostMsg_CommandBufferCreated(result));
219 } 211 }
220 212
221 void GpuChannelManager::DestroyGpuMemoryBuffer( 213 void GpuChannelManager::DestroyGpuMemoryBuffer(
222 gfx::GpuMemoryBufferId id, 214 gfx::GpuMemoryBufferId id,
223 int client_id) { 215 int client_id) {
224 io_task_runner_->PostTask( 216 io_task_runner_->PostTask(
225 FROM_HERE, base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO, 217 FROM_HERE, base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 334 }
343 } 335 }
344 if (!stub || !stub->decoder()->MakeCurrent()) 336 if (!stub || !stub->decoder()->MakeCurrent())
345 return; 337 return;
346 glFinish(); 338 glFinish();
347 DidAccessGpu(); 339 DidAccessGpu();
348 } 340 }
349 #endif 341 #endif
350 342
351 } // namespace content 343 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698