| 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/third_party/dynamic_annotations/dynamic_annotations.h" | 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 if (gpu_info.secondary_gpus[i].vendor_id == active_vendor_id && | 77 if (gpu_info.secondary_gpus[i].vendor_id == active_vendor_id && |
| 78 gpu_info.secondary_gpus[i].device_id == active_device_id) { | 78 gpu_info.secondary_gpus[i].device_id == active_device_id) { |
| 79 gpu_info.secondary_gpus[i].active = true; | 79 gpu_info.secondary_gpus[i].active = true; |
| 80 break; | 80 break; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 #if !defined(OS_MACOSX) | |
| 88 void CollectGraphicsInfo(gpu::GPUInfo& gpu_info) { | 87 void CollectGraphicsInfo(gpu::GPUInfo& gpu_info) { |
| 89 TRACE_EVENT0("gpu,startup", "Collect Graphics Info"); | 88 TRACE_EVENT0("gpu,startup", "Collect Graphics Info"); |
| 90 | 89 |
| 91 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info); | 90 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info); |
| 92 switch (result) { | 91 switch (result) { |
| 93 case gpu::kCollectInfoFatalFailure: | 92 case gpu::kCollectInfoFatalFailure: |
| 94 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal)."; | 93 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal)."; |
| 95 break; | 94 break; |
| 96 case gpu::kCollectInfoNonFatalFailure: | 95 case gpu::kCollectInfoNonFatalFailure: |
| 97 DVLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal)."; | 96 DVLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal)."; |
| 98 break; | 97 break; |
| 99 case gpu::kCollectInfoNone: | 98 case gpu::kCollectInfoNone: |
| 100 NOTREACHED(); | 99 NOTREACHED(); |
| 101 break; | 100 break; |
| 102 case gpu::kCollectInfoSuccess: | 101 case gpu::kCollectInfoSuccess: |
| 103 break; | 102 break; |
| 104 } | 103 } |
| 105 | 104 |
| 106 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
| 107 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && | 106 if (gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2 && |
| 108 gl::GLSurfaceEGL::IsDirectCompositionSupported() && | 107 gl::GLSurfaceEGL::IsDirectCompositionSupported() && |
| 109 DirectCompositionSurfaceWin::AreOverlaysSupported()) { | 108 DirectCompositionSurfaceWin::AreOverlaysSupported()) { |
| 110 gpu_info.supports_overlays = true; | 109 gpu_info.supports_overlays = true; |
| 111 } | 110 } |
| 112 #endif // defined(OS_WIN) | 111 #endif // defined(OS_WIN) |
| 113 } | 112 } |
| 114 #endif // defined(OS_MACOSX) | |
| 115 | 113 |
| 116 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 114 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 117 bool CanAccessNvidiaDeviceFile() { | 115 bool CanAccessNvidiaDeviceFile() { |
| 118 bool res = true; | 116 bool res = true; |
| 119 base::ThreadRestrictions::AssertIOAllowed(); | 117 base::ThreadRestrictions::AssertIOAllowed(); |
| 120 if (access("/dev/nvidiactl", R_OK) != 0) { | 118 if (access("/dev/nvidiactl", R_OK) != 0) { |
| 121 DVLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; | 119 DVLOG(1) << "NVIDIA device file /dev/nvidiactl access denied"; |
| 122 res = false; | 120 res = false; |
| 123 } | 121 } |
| 124 return res; | 122 return res; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 return false; | 227 return false; |
| 230 } | 228 } |
| 231 | 229 |
| 232 // We need to collect GL strings (VENDOR, RENDERER) for blacklisting purposes. | 230 // We need to collect GL strings (VENDOR, RENDERER) for blacklisting purposes. |
| 233 // However, on Mac we don't actually use them. As documented in | 231 // However, on Mac we don't actually use them. As documented in |
| 234 // crbug.com/222934, due to some driver issues, glGetString could take | 232 // crbug.com/222934, due to some driver issues, glGetString could take |
| 235 // multiple seconds to finish, which in turn cause the GPU process to crash. | 233 // multiple seconds to finish, which in turn cause the GPU process to crash. |
| 236 // By skipping the following code on Mac, we don't really lose anything, | 234 // By skipping the following code on Mac, we don't really lose anything, |
| 237 // because the basic GPU information is passed down from the host process. | 235 // because the basic GPU information is passed down from the host process. |
| 238 base::TimeTicks before_collect_context_graphics_info = base::TimeTicks::Now(); | 236 base::TimeTicks before_collect_context_graphics_info = base::TimeTicks::Now(); |
| 239 #if !defined(OS_MACOSX) | 237 bool skipCollectGraphicsInfo = false; |
| 240 CollectGraphicsInfo(gpu_info_); | 238 #if defined(OS_MACOSX) |
| 241 if (gpu_info_.context_info_state == gpu::kCollectInfoFatalFailure) | 239 if (gpu_info_.gpu.vendor_id == 0x10de) // NVIDIA |
| 242 return false; | 240 skipCollectGraphicsInfo = true; |
| 241 #endif // defined(OS_MACOSX) |
| 242 if (!skipCollectGraphicsInfo) { |
| 243 CollectGraphicsInfo(gpu_info_); |
| 244 if (gpu_info_.context_info_state == gpu::kCollectInfoFatalFailure) |
| 245 return false; |
| 243 | 246 |
| 244 // Recompute gpu driver bug workarounds. | 247 // Recompute gpu driver bug workarounds. |
| 245 // This is necessary on systems where vendor_id/device_id aren't available | 248 // This is necessary on systems where vendor_id/device_id aren't available |
| 246 // (Chrome OS, Android) or where workarounds may be dependent on GL_VENDOR | 249 // (Chrome OS, Android) or where workarounds may be dependent on GL_VENDOR |
| 247 // and GL_RENDERER strings which are lazily computed (Linux). | 250 // and GL_RENDERER strings which are lazily computed (Linux). |
| 248 if (!command_line.HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { | 251 if (!command_line.HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { |
| 249 // TODO: this can not affect disabled extensions, since they're already | 252 // TODO: this can not affect disabled extensions, since they're already |
| 250 // initialized in the bindings. This should be moved before bindings | 253 // initialized in the bindings. This should be moved before bindings |
| 251 // initialization. However, populating GPUInfo fully works only on Android. | 254 // initialization. However, populating GPUInfo fully works only on |
| 252 // Other platforms would need the bindings to query GL strings. | 255 // Android. Other platforms would need the bindings to query GL strings. |
| 253 gpu::ApplyGpuDriverBugWorkarounds( | 256 gpu::ApplyGpuDriverBugWorkarounds( |
| 254 gpu_info_, const_cast<base::CommandLine*>(&command_line)); | 257 gpu_info_, const_cast<base::CommandLine*>(&command_line)); |
| 258 } |
| 255 } | 259 } |
| 256 #endif // !defined(OS_MACOSX) | |
| 257 | 260 |
| 258 gpu_feature_info_ = gpu::GetGpuFeatureInfo(gpu_info_, command_line); | 261 gpu_feature_info_ = gpu::GetGpuFeatureInfo(gpu_info_, command_line); |
| 259 | 262 |
| 260 base::TimeDelta collect_context_time = | 263 base::TimeDelta collect_context_time = |
| 261 base::TimeTicks::Now() - before_collect_context_graphics_info; | 264 base::TimeTicks::Now() - before_collect_context_graphics_info; |
| 262 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); | 265 UMA_HISTOGRAM_TIMES("GPU.CollectContextGraphicsInfo", collect_context_time); |
| 263 | 266 |
| 264 base::TimeDelta initialize_one_off_time = | 267 base::TimeDelta initialize_one_off_time = |
| 265 base::TimeTicks::Now() - before_initialize_one_off; | 268 base::TimeTicks::Now() - before_initialize_one_off; |
| 266 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", | 269 UMA_HISTOGRAM_MEDIUM_TIMES("GPU.InitializeOneOffMediumTime", |
| (...skipping 11 matching lines...) Expand all Loading... |
| 278 | 281 |
| 279 if (!gpu_info_.sandboxed && !attempted_startsandbox) { | 282 if (!gpu_info_.sandboxed && !attempted_startsandbox) { |
| 280 gpu_info_.sandboxed = | 283 gpu_info_.sandboxed = |
| 281 sandbox_helper_->EnsureSandboxInitialized(watchdog_thread_.get()); | 284 sandbox_helper_->EnsureSandboxInitialized(watchdog_thread_.get()); |
| 282 } | 285 } |
| 283 | 286 |
| 284 return true; | 287 return true; |
| 285 } | 288 } |
| 286 | 289 |
| 287 } // namespace gpu | 290 } // namespace gpu |
| OLD | NEW |