OLD | NEW |
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 "gpu/ipc/service/gpu_init.h" | 5 #include "gpu/ipc/service/gpu_init.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/sys_info.h" |
10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 11 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
11 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
12 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
13 #include "gpu/command_buffer/service/gpu_switches.h" | 14 #include "gpu/command_buffer/service/gpu_switches.h" |
14 #include "gpu/config/gpu_driver_bug_list.h" | 15 #include "gpu/config/gpu_driver_bug_list.h" |
15 #include "gpu/config/gpu_info_collector.h" | 16 #include "gpu/config/gpu_info_collector.h" |
16 #include "gpu/config/gpu_switches.h" | 17 #include "gpu/config/gpu_switches.h" |
17 #include "gpu/config/gpu_util.h" | 18 #include "gpu/config/gpu_util.h" |
18 #include "gpu/ipc/service/gpu_watchdog_thread.h" | 19 #include "gpu/ipc/service/gpu_watchdog_thread.h" |
19 #include "gpu/ipc/service/switches.h" | 20 #include "gpu/ipc/service/switches.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 GetGpuInfoFromCommandLine(gpu_info_, command_line); | 154 GetGpuInfoFromCommandLine(gpu_info_, command_line); |
154 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 155 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
155 if (gpu_info_.gpu.vendor_id == 0x10de && // NVIDIA | 156 if (gpu_info_.gpu.vendor_id == 0x10de && // NVIDIA |
156 gpu_info_.driver_vendor == "NVIDIA" && !CanAccessNvidiaDeviceFile()) | 157 gpu_info_.driver_vendor == "NVIDIA" && !CanAccessNvidiaDeviceFile()) |
157 return false; | 158 return false; |
158 #endif | 159 #endif |
159 gpu_info_.in_process_gpu = false; | 160 gpu_info_.in_process_gpu = false; |
160 | 161 |
161 sandbox_helper_->PreSandboxStartup(); | 162 sandbox_helper_->PreSandboxStartup(); |
162 | 163 |
| 164 std::string os_version; |
| 165 |
163 #if defined(OS_LINUX) | 166 #if defined(OS_LINUX) |
164 // On Chrome OS ARM Mali, GPU driver userspace creates threads when | 167 // On Chrome OS ARM Mali, GPU driver userspace creates threads when |
165 // initializing a GL context, so start the sandbox early. | 168 // initializing a GL context, so start the sandbox early. |
166 if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) | 169 if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) { |
| 170 os_version = base::SysInfo::OperatingSystemVersion(); |
167 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); | 171 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); |
| 172 } |
168 #endif // defined(OS_LINUX) | 173 #endif // defined(OS_LINUX) |
169 | 174 |
170 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); | 175 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); |
171 | 176 |
172 // Load and initialize the GL implementation and locate the GL entry points if | 177 // Load and initialize the GL implementation and locate the GL entry points if |
173 // needed. This initialization may have already happened if running in the | 178 // needed. This initialization may have already happened if running in the |
174 // browser process, for example. | 179 // browser process, for example. |
175 bool gl_initialized = gl::GetGLImplementation() != gl::kGLImplementationNone; | 180 bool gl_initialized = gl::GetGLImplementation() != gl::kGLImplementationNone; |
176 if (!gl_initialized) | 181 if (!gl_initialized) |
177 gl_initialized = gl::init::InitializeGLOneOff(); | 182 gl_initialized = gl::init::InitializeGLOneOff(); |
(...skipping 18 matching lines...) Expand all Loading... |
196 // Recompute gpu driver bug workarounds. | 201 // Recompute gpu driver bug workarounds. |
197 // This is necessary on systems where vendor_id/device_id aren't available | 202 // This is necessary on systems where vendor_id/device_id aren't available |
198 // (Chrome OS, Android) or where workarounds may be dependent on GL_VENDOR | 203 // (Chrome OS, Android) or where workarounds may be dependent on GL_VENDOR |
199 // and GL_RENDERER strings which are lazily computed (Linux). | 204 // and GL_RENDERER strings which are lazily computed (Linux). |
200 if (!command_line.HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { | 205 if (!command_line.HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { |
201 // TODO: this can not affect disabled extensions, since they're already | 206 // TODO: this can not affect disabled extensions, since they're already |
202 // initialized in the bindings. This should be moved before bindings | 207 // initialized in the bindings. This should be moved before bindings |
203 // initialization. However, populating GPUInfo fully works only on Android. | 208 // initialization. However, populating GPUInfo fully works only on Android. |
204 // Other platforms would need the bindings to query GL strings. | 209 // Other platforms would need the bindings to query GL strings. |
205 gpu::ApplyGpuDriverBugWorkarounds( | 210 gpu::ApplyGpuDriverBugWorkarounds( |
206 gpu_info_, const_cast<base::CommandLine*>(&command_line)); | 211 gpu_info_, os_version, const_cast<base::CommandLine*>(&command_line)); |
207 } | 212 } |
208 #endif // !defined(OS_MACOSX) | 213 #endif // !defined(OS_MACOSX) |
209 | 214 |
210 base::TimeDelta collect_context_time = | 215 base::TimeDelta collect_context_time = |
211 base::TimeTicks::Now() - before_collect_context_graphics_info; | 216 base::TimeTicks::Now() - before_collect_context_graphics_info; |
212 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); | 217 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); |
213 | 218 |
214 base::TimeDelta initialize_one_off_time = | 219 base::TimeDelta initialize_one_off_time = |
215 base::TimeTicks::Now() - before_initialize_one_off; | 220 base::TimeTicks::Now() - before_initialize_one_off; |
216 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", | 221 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", |
217 initialize_one_off_time); | 222 initialize_one_off_time); |
218 | 223 |
219 // OSMesa is expected to run very slowly, so disable the watchdog in that | 224 // OSMesa is expected to run very slowly, so disable the watchdog in that |
220 // case. | 225 // case. |
221 if (gl::GetGLImplementation() == gl::kGLImplementationOSMesaGL) { | 226 if (gl::GetGLImplementation() == gl::kGLImplementationOSMesaGL) { |
222 if (watchdog_thread_) | 227 if (watchdog_thread_) |
223 watchdog_thread_->Stop(); | 228 watchdog_thread_->Stop(); |
224 watchdog_thread_ = nullptr; | 229 watchdog_thread_ = nullptr; |
225 } else if (enable_watchdog && delayed_watchdog_enable) { | 230 } else if (enable_watchdog && delayed_watchdog_enable) { |
226 watchdog_thread_ = gpu::GpuWatchdogThread::Create(); | 231 watchdog_thread_ = gpu::GpuWatchdogThread::Create(); |
227 } | 232 } |
228 | 233 |
229 if (!gpu_info_.sandboxed) | 234 if (!gpu_info_.sandboxed) |
230 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); | 235 gpu_info_.sandboxed = sandbox_helper_->EnsureSandboxInitialized(); |
231 return true; | 236 return true; |
232 } | 237 } |
233 | 238 |
234 } // namespace gpu | 239 } // namespace gpu |
OLD | NEW |