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

Side by Side Diff: services/ui/gpu/gpu_service.cc

Issue 2814843002: gpu: GPU service scheduler. (Closed)
Patch Set: rebase Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/gpu/gpu_service.h" 5 #include "services/ui/gpu/gpu_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "cc/output/in_process_context_provider.h" 14 #include "cc/output/in_process_context_provider.h"
15 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 15 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
16 #include "gpu/command_buffer/service/gpu_switches.h" 16 #include "gpu/command_buffer/service/gpu_switches.h"
17 #include "gpu/command_buffer/service/scheduler.h"
17 #include "gpu/command_buffer/service/sync_point_manager.h" 18 #include "gpu/command_buffer/service/sync_point_manager.h"
18 #include "gpu/config/gpu_info_collector.h" 19 #include "gpu/config/gpu_info_collector.h"
19 #include "gpu/config/gpu_switches.h" 20 #include "gpu/config/gpu_switches.h"
20 #include "gpu/config/gpu_util.h" 21 #include "gpu/config/gpu_util.h"
21 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 22 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
22 #include "gpu/ipc/common/memory_stats.h" 23 #include "gpu/ipc/common/memory_stats.h"
23 #include "gpu/ipc/gpu_in_process_thread_service.h" 24 #include "gpu/ipc/gpu_in_process_thread_service.h"
24 #include "gpu/ipc/service/gpu_channel.h" 25 #include "gpu/ipc/service/gpu_channel.h"
25 #include "gpu/ipc/service/gpu_channel_manager.h" 26 #include "gpu/ipc/service/gpu_channel_manager.h"
26 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" 27 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, 89 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread,
89 scoped_refptr<base::SingleThreadTaskRunner> io_runner, 90 scoped_refptr<base::SingleThreadTaskRunner> io_runner,
90 const gpu::GpuFeatureInfo& gpu_feature_info) 91 const gpu::GpuFeatureInfo& gpu_feature_info)
91 : main_runner_(base::ThreadTaskRunnerHandle::Get()), 92 : main_runner_(base::ThreadTaskRunnerHandle::Get()),
92 io_runner_(std::move(io_runner)), 93 io_runner_(std::move(io_runner)),
93 watchdog_thread_(std::move(watchdog_thread)), 94 watchdog_thread_(std::move(watchdog_thread)),
94 gpu_memory_buffer_factory_( 95 gpu_memory_buffer_factory_(
95 gpu::GpuMemoryBufferFactory::CreateNativeType()), 96 gpu::GpuMemoryBufferFactory::CreateNativeType()),
96 gpu_info_(gpu_info), 97 gpu_info_(gpu_info),
97 gpu_feature_info_(gpu_feature_info), 98 gpu_feature_info_(gpu_feature_info),
98 sync_point_manager_(nullptr),
99 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()), 99 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()),
100 weak_ptr_factory_(this) { 100 weak_ptr_factory_(this) {
101 DCHECK(!io_runner_->BelongsToCurrentThread()); 101 DCHECK(!io_runner_->BelongsToCurrentThread());
102 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); 102 weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
103 } 103 }
104 104
105 GpuService::~GpuService() { 105 GpuService::~GpuService() {
106 DCHECK(main_runner_->BelongsToCurrentThread()); 106 DCHECK(main_runner_->BelongsToCurrentThread());
107 bind_task_tracker_.TryCancelAll(); 107 bind_task_tracker_.TryCancelAll();
108 logging::SetLogMessageHandler(nullptr); 108 logging::SetLogMessageHandler(nullptr);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 shutdown_event_ = shutdown_event; 169 shutdown_event_ = shutdown_event;
170 if (!shutdown_event_) { 170 if (!shutdown_event_) {
171 owned_shutdown_event_ = base::MakeUnique<base::WaitableEvent>( 171 owned_shutdown_event_ = base::MakeUnique<base::WaitableEvent>(
172 base::WaitableEvent::ResetPolicy::MANUAL, 172 base::WaitableEvent::ResetPolicy::MANUAL,
173 base::WaitableEvent::InitialState::NOT_SIGNALED); 173 base::WaitableEvent::InitialState::NOT_SIGNALED);
174 shutdown_event_ = owned_shutdown_event_.get(); 174 shutdown_event_ = owned_shutdown_event_.get();
175 } 175 }
176 176
177 if (gpu_preferences_.enable_gpu_scheduler) {
178 scheduler_ = base::MakeUnique<gpu::Scheduler>(
179 base::ThreadTaskRunnerHandle::Get(), sync_point_manager_);
180 }
181
177 // Defer creation of the render thread. This is to prevent it from handling 182 // Defer creation of the render thread. This is to prevent it from handling
178 // IPC messages before the sandbox has been enabled and all other necessary 183 // IPC messages before the sandbox has been enabled and all other necessary
179 // initialization has succeeded. 184 // initialization has succeeded.
180 gpu_channel_manager_.reset(new gpu::GpuChannelManager( 185 gpu_channel_manager_.reset(new gpu::GpuChannelManager(
181 gpu_preferences_, this, watchdog_thread_.get(), 186 gpu_preferences_, this, watchdog_thread_.get(),
182 base::ThreadTaskRunnerHandle::Get(), io_runner_, sync_point_manager_, 187 base::ThreadTaskRunnerHandle::Get(), io_runner_, scheduler_.get(),
183 gpu_memory_buffer_factory_.get(), gpu_feature_info_, 188 sync_point_manager_, gpu_memory_buffer_factory_.get(), gpu_feature_info_,
184 std::move(activity_flags))); 189 std::move(activity_flags)));
185 190
186 media_gpu_channel_manager_.reset( 191 media_gpu_channel_manager_.reset(
187 new media::MediaGpuChannelManager(gpu_channel_manager_.get())); 192 new media::MediaGpuChannelManager(gpu_channel_manager_.get()));
188 if (watchdog_thread()) 193 if (watchdog_thread())
189 watchdog_thread()->AddPowerObserver(); 194 watchdog_thread()->AddPowerObserver();
190 } 195 }
191 196
192 void GpuService::Bind(mojom::GpuServiceRequest request) { 197 void GpuService::Bind(mojom::GpuServiceRequest request) {
193 if (main_runner_->BelongsToCurrentThread()) { 198 if (main_runner_->BelongsToCurrentThread()) {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 503
499 void GpuService::Stop(const StopCallback& callback) { 504 void GpuService::Stop(const StopCallback& callback) {
500 DCHECK(io_runner_->BelongsToCurrentThread()); 505 DCHECK(io_runner_->BelongsToCurrentThread());
501 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { 506 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] {
502 base::MessageLoop::current()->QuitWhenIdle(); 507 base::MessageLoop::current()->QuitWhenIdle();
503 }), 508 }),
504 callback); 509 callback);
505 } 510 }
506 511
507 } // namespace ui 512 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698