OLD | NEW |
---|---|
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 "gpu/config/gpu_info_collector.h" | 5 #include "gpu/config/gpu_info_collector.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/command_line.h" | |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
17 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
21 #include "gpu/config/gpu_switches.h" | |
20 #include "ui/gl/gl_bindings.h" | 22 #include "ui/gl/gl_bindings.h" |
21 #include "ui/gl/gl_context.h" | 23 #include "ui/gl/gl_context.h" |
22 #include "ui/gl/gl_implementation.h" | 24 #include "ui/gl/gl_implementation.h" |
23 #include "ui/gl/gl_surface.h" | 25 #include "ui/gl/gl_surface.h" |
24 #include "ui/gl/gl_version_info.h" | 26 #include "ui/gl/gl_version_info.h" |
25 | 27 |
26 namespace { | 28 namespace { |
27 | 29 |
28 scoped_refptr<gfx::GLSurface> InitializeGLSurface() { | 30 scoped_refptr<gfx::GLSurface> InitializeGLSurface() { |
29 scoped_refptr<gfx::GLSurface> surface( | 31 scoped_refptr<gfx::GLSurface> surface( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 } | 112 } |
111 | 113 |
112 scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get())); | 114 scoped_refptr<gfx::GLContext> context(InitializeGLContext(surface.get())); |
113 if (!context.get()) { | 115 if (!context.get()) { |
114 LOG(ERROR) << "Could not create context for info collection."; | 116 LOG(ERROR) << "Could not create context for info collection."; |
115 return kCollectInfoFatalFailure; | 117 return kCollectInfoFatalFailure; |
116 } | 118 } |
117 | 119 |
118 gpu_info->gl_renderer = GetGLString(GL_RENDERER); | 120 gpu_info->gl_renderer = GetGLString(GL_RENDERER); |
119 gpu_info->gl_vendor = GetGLString(GL_VENDOR); | 121 gpu_info->gl_vendor = GetGLString(GL_VENDOR); |
122 gpu_info->gl_version = GetGLString(GL_VERSION); | |
123 | |
124 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
125 if (command_line->HasSwitch(switches::kGpuTestingGLVendor)) { | |
126 gpu_info->gl_vendor = | |
127 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVendor); | |
128 } | |
129 if (command_line->HasSwitch(switches::kGpuTestingGLRenderer)) { | |
130 gpu_info->gl_renderer = | |
131 command_line->GetSwitchValueASCII(switches::kGpuTestingGLRenderer); | |
132 } | |
133 if (command_line->HasSwitch(switches::kGpuTestingGLVersion)) { | |
134 gpu_info->gl_version = | |
135 command_line->GetSwitchValueASCII(switches::kGpuTestingGLVersion); | |
136 } | |
137 | |
120 gpu_info->gl_extensions = gfx::GetGLExtensionsFromCurrentContext(); | 138 gpu_info->gl_extensions = gfx::GetGLExtensionsFromCurrentContext(); |
121 gpu_info->gl_version = GetGLString(GL_VERSION); | |
122 std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION); | 139 std::string glsl_version_string = GetGLString(GL_SHADING_LANGUAGE_VERSION); |
123 | 140 |
124 gfx::GLVersionInfo gl_info(gpu_info->gl_version.c_str(), | 141 gfx::GLVersionInfo gl_info(gpu_info->gl_version.c_str(), |
125 gpu_info->gl_renderer.c_str(), | 142 gpu_info->gl_renderer.c_str(), |
126 gpu_info->gl_extensions.c_str()); | 143 gpu_info->gl_extensions.c_str()); |
127 GLint max_samples = 0; | 144 GLint max_samples = 0; |
128 if (gl_info.IsAtLeastGL(3, 0) || gl_info.IsAtLeastGLES(3, 0) || | 145 if (gl_info.IsAtLeastGL(3, 0) || gl_info.IsAtLeastGLES(3, 0) || |
129 gpu_info->gl_extensions.find("GL_ANGLE_framebuffer_multisample") != | 146 gpu_info->gl_extensions.find("GL_ANGLE_framebuffer_multisample") != |
130 std::string::npos || | 147 std::string::npos || |
131 gpu_info->gl_extensions.find("GL_APPLE_framebuffer_multisample") != | 148 gpu_info->gl_extensions.find("GL_APPLE_framebuffer_multisample") != |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 basic_gpu_info->video_decode_accelerator_capabilities = | 224 basic_gpu_info->video_decode_accelerator_capabilities = |
208 context_gpu_info.video_decode_accelerator_capabilities; | 225 context_gpu_info.video_decode_accelerator_capabilities; |
209 basic_gpu_info->video_encode_accelerator_supported_profiles = | 226 basic_gpu_info->video_encode_accelerator_supported_profiles = |
210 context_gpu_info.video_encode_accelerator_supported_profiles; | 227 context_gpu_info.video_encode_accelerator_supported_profiles; |
211 basic_gpu_info->jpeg_decode_accelerator_supported = | 228 basic_gpu_info->jpeg_decode_accelerator_supported = |
212 context_gpu_info.jpeg_decode_accelerator_supported; | 229 context_gpu_info.jpeg_decode_accelerator_supported; |
213 } | 230 } |
214 | 231 |
215 void IdentifyActiveGPU(GPUInfo* gpu_info) { | 232 void IdentifyActiveGPU(GPUInfo* gpu_info) { |
216 const std::string kNVidiaName = "nvidia"; | 233 const std::string kNVidiaName = "nvidia"; |
234 const std::string kNouveauName = "nouveau"; | |
217 const std::string kIntelName = "intel"; | 235 const std::string kIntelName = "intel"; |
218 const std::string kAMDName = "amd"; | 236 const std::string kAMDName = "amd"; |
219 const std::string kATIName = "ati"; | 237 const std::string kATIName = "ati"; |
220 const std::string kVendorNames[] = { | 238 const std::string kRadeonName = "radeon"; |
Zhenyao Mo
2016/04/19 21:05:27
Really? We have drivers with "Radeon" as vendor s
Julien Isorce Samsung
2016/04/20 17:19:21
You are right it is wrong, I double checked in Mes
| |
221 kNVidiaName, kIntelName, kAMDName, kATIName}; | 239 const std::string kVendorNames[] = {kNVidiaName, kNouveauName, kIntelName, |
240 kAMDName, kATIName, kRadeonName}; | |
222 | 241 |
223 const uint32_t kNVidiaID = 0x10de; | 242 const uint32_t kNVidiaID = 0x10de; |
224 const uint32_t kIntelID = 0x8086; | 243 const uint32_t kIntelID = 0x8086; |
225 const uint32_t kAMDID = 0x1002; | 244 const uint32_t kAMDID = 0x1002; |
226 const uint32_t kATIID = 0x1002; | 245 const uint32_t kATIID = 0x1002; |
227 const uint32_t kVendorIDs[] = {kNVidiaID, kIntelID, kAMDID, kATIID}; | 246 const uint32_t kVendorIDs[] = {kNVidiaID, kNVidiaID, kIntelID, |
247 kAMDID, kATIID, kAMDID}; | |
228 | 248 |
229 DCHECK(gpu_info); | 249 DCHECK(gpu_info); |
230 if (gpu_info->secondary_gpus.size() == 0) | 250 if (gpu_info->secondary_gpus.size() == 0) |
231 return; | 251 return; |
232 | 252 |
233 uint32_t active_vendor_id = 0; | 253 uint32_t active_vendor_id = 0; |
234 if (!gpu_info->gl_vendor.empty()) { | 254 if (!gpu_info->gl_vendor.empty()) { |
235 std::string gl_vendor_lower = base::ToLowerASCII(gpu_info->gl_vendor); | 255 std::string gl_vendor_lower = base::ToLowerASCII(gpu_info->gl_vendor); |
236 int index = StringContainsName( | 256 int index = StringContainsName( |
237 gl_vendor_lower, kVendorNames, arraysize(kVendorNames)); | 257 gl_vendor_lower, kVendorNames, arraysize(kVendorNames)); |
(...skipping 26 matching lines...) Expand all Loading... | |
264 for (size_t ii = 0; ii < gpu_info->secondary_gpus.size(); ++ii) { | 284 for (size_t ii = 0; ii < gpu_info->secondary_gpus.size(); ++ii) { |
265 if (active_vendor_id == gpu_info->secondary_gpus[ii].vendor_id) { | 285 if (active_vendor_id == gpu_info->secondary_gpus[ii].vendor_id) { |
266 gpu_info->secondary_gpus[ii].active = true; | 286 gpu_info->secondary_gpus[ii].active = true; |
267 return; | 287 return; |
268 } | 288 } |
269 } | 289 } |
270 } | 290 } |
271 | 291 |
272 } // namespace gpu | 292 } // namespace gpu |
273 | 293 |
OLD | NEW |