| 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 = | 171 gpu_info_.sandboxed = |
| 168 sandbox_helper_->EnsureSandboxInitialized(watchdog_thread_.get()); | 172 sandbox_helper_->EnsureSandboxInitialized(watchdog_thread_.get()); |
| 173 } |
| 169 #endif // defined(OS_LINUX) | 174 #endif // defined(OS_LINUX) |
| 170 | 175 |
| 171 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); | 176 base::TimeTicks before_initialize_one_off = base::TimeTicks::Now(); |
| 172 | 177 |
| 173 // Load and initialize the GL implementation and locate the GL entry points if | 178 // Load and initialize the GL implementation and locate the GL entry points if |
| 174 // needed. This initialization may have already happened if running in the | 179 // needed. This initialization may have already happened if running in the |
| 175 // browser process, for example. | 180 // browser process, for example. |
| 176 bool gl_initialized = gl::GetGLImplementation() != gl::kGLImplementationNone; | 181 bool gl_initialized = gl::GetGLImplementation() != gl::kGLImplementationNone; |
| 177 if (!gl_initialized) | 182 if (!gl_initialized) |
| 178 gl_initialized = gl::init::InitializeGLOneOff(); | 183 gl_initialized = gl::init::InitializeGLOneOff(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 197 // Recompute gpu driver bug workarounds. | 202 // Recompute gpu driver bug workarounds. |
| 198 // This is necessary on systems where vendor_id/device_id aren't available | 203 // This is necessary on systems where vendor_id/device_id aren't available |
| 199 // (Chrome OS, Android) or where workarounds may be dependent on GL_VENDOR | 204 // (Chrome OS, Android) or where workarounds may be dependent on GL_VENDOR |
| 200 // and GL_RENDERER strings which are lazily computed (Linux). | 205 // and GL_RENDERER strings which are lazily computed (Linux). |
| 201 if (!command_line.HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { | 206 if (!command_line.HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { |
| 202 // TODO: this can not affect disabled extensions, since they're already | 207 // TODO: this can not affect disabled extensions, since they're already |
| 203 // initialized in the bindings. This should be moved before bindings | 208 // initialized in the bindings. This should be moved before bindings |
| 204 // initialization. However, populating GPUInfo fully works only on Android. | 209 // initialization. However, populating GPUInfo fully works only on Android. |
| 205 // Other platforms would need the bindings to query GL strings. | 210 // Other platforms would need the bindings to query GL strings. |
| 206 gpu::ApplyGpuDriverBugWorkarounds( | 211 gpu::ApplyGpuDriverBugWorkarounds( |
| 207 gpu_info_, const_cast<base::CommandLine*>(&command_line)); | 212 gpu_info_, os_version, const_cast<base::CommandLine*>(&command_line)); |
| 208 } | 213 } |
| 209 #endif // !defined(OS_MACOSX) | 214 #endif // !defined(OS_MACOSX) |
| 210 | 215 |
| 211 base::TimeDelta collect_context_time = | 216 base::TimeDelta collect_context_time = |
| 212 base::TimeTicks::Now() - before_collect_context_graphics_info; | 217 base::TimeTicks::Now() - before_collect_context_graphics_info; |
| 213 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); | 218 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); |
| 214 | 219 |
| 215 base::TimeDelta initialize_one_off_time = | 220 base::TimeDelta initialize_one_off_time = |
| 216 base::TimeTicks::Now() - before_initialize_one_off; | 221 base::TimeTicks::Now() - before_initialize_one_off; |
| 217 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", | 222 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", |
| 218 initialize_one_off_time); | 223 initialize_one_off_time); |
| 219 | 224 |
| 220 // OSMesa is expected to run very slowly, so disable the watchdog in that | 225 // OSMesa is expected to run very slowly, so disable the watchdog in that |
| 221 // case. | 226 // case. |
| 222 if (gl::GetGLImplementation() == gl::kGLImplementationOSMesaGL) { | 227 if (gl::GetGLImplementation() == gl::kGLImplementationOSMesaGL) { |
| 223 if (watchdog_thread_) | 228 if (watchdog_thread_) |
| 224 watchdog_thread_->Stop(); | 229 watchdog_thread_->Stop(); |
| 225 watchdog_thread_ = nullptr; | 230 watchdog_thread_ = nullptr; |
| 226 } else if (enable_watchdog && delayed_watchdog_enable) { | 231 } else if (enable_watchdog && delayed_watchdog_enable) { |
| 227 watchdog_thread_ = gpu::GpuWatchdogThread::Create(); | 232 watchdog_thread_ = gpu::GpuWatchdogThread::Create(); |
| 228 } | 233 } |
| 229 | 234 |
| 230 if (!gpu_info_.sandboxed) | 235 if (!gpu_info_.sandboxed) |
| 231 gpu_info_.sandboxed = | 236 gpu_info_.sandboxed = |
| 232 sandbox_helper_->EnsureSandboxInitialized(watchdog_thread_.get()); | 237 sandbox_helper_->EnsureSandboxInitialized(watchdog_thread_.get()); |
| 233 return true; | 238 return true; |
| 234 } | 239 } |
| 235 | 240 |
| 236 } // namespace gpu | 241 } // namespace gpu |
| OLD | NEW |