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

Side by Side Diff: content/gpu/gpu_info_collector_linux.cc

Issue 11576052: Revert 173248, broke building on the official chrome/win bot: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « content/gpu/gpu_info_collector_android.cc ('k') | content/gpu/gpu_info_collector_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/gpu/gpu_info_collector.h" 5 #include "content/gpu/gpu_info_collector.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return driver_version; 90 return driver_version;
91 } 91 }
92 } 92 }
93 return std::string(); 93 return std::string();
94 } 94 }
95 95
96 const uint32 kVendorIDIntel = 0x8086; 96 const uint32 kVendorIDIntel = 0x8086;
97 const uint32 kVendorIDNVidia = 0x10de; 97 const uint32 kVendorIDNVidia = 0x10de;
98 const uint32 kVendorIDAMD = 0x1002; 98 const uint32 kVendorIDAMD = 0x1002;
99 99
100 bool CollectPCIVideoCardInfo(content::GPUInfo* gpu_info) { 100 } // namespace anonymous
101
102 namespace gpu_info_collector {
103
104 bool CollectGraphicsInfo(content::GPUInfo* gpu_info) {
105 DCHECK(gpu_info);
106 *gpu_info = content::GPUInfo();
107
108 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo");
109
110 if (CommandLine::ForCurrentProcess()->HasSwitch(
111 switches::kGpuNoContextLost)) {
112 gpu_info->can_lose_context = false;
113 } else {
114 #if defined(OS_CHROMEOS)
115 gpu_info->can_lose_context = false;
116 #else
117 // TODO(zmo): need to consider the case where we are running on top
118 // of desktop GL and GL_ARB_robustness extension is available.
119 gpu_info->can_lose_context =
120 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2);
121 #endif
122 }
123
124 gpu_info->finalized = true;
125 bool rt = CollectGraphicsInfoGL(gpu_info);
126
127 return rt;
128 }
129
130 bool CollectPreliminaryGraphicsInfo(content::GPUInfo* gpu_info) {
131 DCHECK(gpu_info);
132
133 bool rt = CollectVideoCardInfo(gpu_info);
134
135 std::string driver_version;
136 switch (gpu_info->gpu.vendor_id) {
137 case kVendorIDAMD:
138 driver_version = CollectDriverVersionATI();
139 if (!driver_version.empty()) {
140 gpu_info->driver_vendor = "ATI / AMD";
141 gpu_info->driver_version = driver_version;
142 }
143 break;
144 case kVendorIDNVidia:
145 driver_version = CollectDriverVersionNVidia();
146 if (!driver_version.empty()) {
147 gpu_info->driver_vendor = "NVIDIA";
148 gpu_info->driver_version = driver_version;
149 }
150 break;
151 case kVendorIDIntel:
152 // In dual-GPU cases, sometimes PCI scan only gives us the
153 // integrated GPU (i.e., the Intel one).
154 driver_version = CollectDriverVersionNVidia();
155 if (!driver_version.empty()) {
156 gpu_info->driver_vendor = "NVIDIA";
157 gpu_info->driver_version = driver_version;
158 // Machines with more than two GPUs are not handled.
159 if (gpu_info->secondary_gpus.size() <= 1)
160 gpu_info->optimus = true;
161 }
162 break;
163 }
164
165 return rt;
166 }
167
168 bool CollectVideoCardInfo(content::GPUInfo* gpu_info) {
101 DCHECK(gpu_info); 169 DCHECK(gpu_info);
102 170
103 if (IsPciSupported() == false) { 171 if (IsPciSupported() == false) {
104 VLOG(1) << "PCI bus scanning is not supported"; 172 VLOG(1) << "PCI bus scanning is not supported";
105 return false; 173 return false;
106 } 174 }
107 175
108 // TODO(zmo): be more flexible about library name. 176 // TODO(zmo): be more flexible about library name.
109 LibPciLoader libpci_loader; 177 LibPciLoader libpci_loader;
110 if (!libpci_loader.Load("libpci.so.3") && 178 if (!libpci_loader.Load("libpci.so.3") &&
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (gpu_info->gpu.vendor_id == kVendorIDNVidia) 249 if (gpu_info->gpu.vendor_id == kVendorIDNVidia)
182 gpu_info->optimus = true; 250 gpu_info->optimus = true;
183 if (gpu_info->gpu.vendor_id == kVendorIDAMD) 251 if (gpu_info->gpu.vendor_id == kVendorIDAMD)
184 gpu_info->amd_switchable = true; 252 gpu_info->amd_switchable = true;
185 } 253 }
186 254
187 (libpci_loader.pci_cleanup)(access); 255 (libpci_loader.pci_cleanup)(access);
188 return (primary_gpu_identified); 256 return (primary_gpu_identified);
189 } 257 }
190 258
191 } // namespace anonymous
192
193 namespace gpu_info_collector {
194
195 bool CollectContextGraphicsInfo(content::GPUInfo* gpu_info) {
196 DCHECK(gpu_info);
197
198 TRACE_EVENT0("gpu", "gpu_info_collector::CollectGraphicsInfo");
199
200 if (CommandLine::ForCurrentProcess()->HasSwitch(
201 switches::kGpuNoContextLost)) {
202 gpu_info->can_lose_context = false;
203 } else {
204 #if defined(OS_CHROMEOS)
205 gpu_info->can_lose_context = false;
206 #else
207 // TODO(zmo): need to consider the case where we are running on top
208 // of desktop GL and GL_ARB_robustness extension is available.
209 gpu_info->can_lose_context =
210 (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2);
211 #endif
212 }
213
214 gpu_info->finalized = true;
215 bool rt = CollectGraphicsInfoGL(gpu_info);
216
217 return rt;
218 }
219
220 bool CollectBasicGraphicsInfo(content::GPUInfo* gpu_info) {
221 DCHECK(gpu_info);
222
223 bool rt = CollectPCIVideoCardInfo(gpu_info);
224
225 std::string driver_version;
226 switch (gpu_info->gpu.vendor_id) {
227 case kVendorIDAMD:
228 driver_version = CollectDriverVersionATI();
229 if (!driver_version.empty()) {
230 gpu_info->driver_vendor = "ATI / AMD";
231 gpu_info->driver_version = driver_version;
232 }
233 break;
234 case kVendorIDNVidia:
235 driver_version = CollectDriverVersionNVidia();
236 if (!driver_version.empty()) {
237 gpu_info->driver_vendor = "NVIDIA";
238 gpu_info->driver_version = driver_version;
239 }
240 break;
241 case kVendorIDIntel:
242 // In dual-GPU cases, sometimes PCI scan only gives us the
243 // integrated GPU (i.e., the Intel one).
244 driver_version = CollectDriverVersionNVidia();
245 if (!driver_version.empty()) {
246 gpu_info->driver_vendor = "NVIDIA";
247 gpu_info->driver_version = driver_version;
248 // Machines with more than two GPUs are not handled.
249 if (gpu_info->secondary_gpus.size() <= 1)
250 gpu_info->optimus = true;
251 }
252 break;
253 }
254
255 return rt;
256 }
257
258 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) { 259 bool CollectDriverInfoGL(content::GPUInfo* gpu_info) {
259 DCHECK(gpu_info); 260 DCHECK(gpu_info);
260 261
261 std::string gl_version_string = gpu_info->gl_version_string; 262 std::string gl_version_string = gpu_info->gl_version_string;
262 if (StartsWithASCII(gl_version_string, "OpenGL ES", true)) 263 if (StartsWithASCII(gl_version_string, "OpenGL ES", true))
263 gl_version_string = gl_version_string.substr(10); 264 gl_version_string = gl_version_string.substr(10);
264 std::vector<std::string> pieces; 265 std::vector<std::string> pieces;
265 base::SplitStringAlongWhitespace(gl_version_string, &pieces); 266 base::SplitStringAlongWhitespace(gl_version_string, &pieces);
266 // In linux, the gl version string might be in the format of 267 // In linux, the gl version string might be in the format of
267 // GLVersion DriverVendor DriverVersion 268 // GLVersion DriverVendor DriverVersion
268 if (pieces.size() < 3) 269 if (pieces.size() < 3)
269 return false; 270 return false;
270 271
271 std::string driver_version = pieces[2]; 272 std::string driver_version = pieces[2];
272 size_t pos = driver_version.find_first_not_of("0123456789."); 273 size_t pos = driver_version.find_first_not_of("0123456789.");
273 if (pos == 0) 274 if (pos == 0)
274 return false; 275 return false;
275 if (pos != std::string::npos) 276 if (pos != std::string::npos)
276 driver_version = driver_version.substr(0, pos); 277 driver_version = driver_version.substr(0, pos);
277 278
278 gpu_info->driver_vendor = pieces[1]; 279 gpu_info->driver_vendor = pieces[1];
279 gpu_info->driver_version = driver_version; 280 gpu_info->driver_version = driver_version;
280 return true; 281 return true;
281 } 282 }
282 283
283 void MergeGPUInfo(content::GPUInfo* basic_gpu_info,
284 const content::GPUInfo& context_gpu_info) {
285 MergeGPUInfoGL(basic_gpu_info, context_gpu_info);
286 }
287
288 } // namespace gpu_info_collector 284 } // namespace gpu_info_collector
OLDNEW
« no previous file with comments | « content/gpu/gpu_info_collector_android.cc ('k') | content/gpu/gpu_info_collector_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698