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 "content/gpu/gpu_info_collector.h" | 5 #include "content/gpu/gpu_info_collector.h" |
6 | 6 |
7 // This has to be included before windows.h. | 7 // This has to be included before windows.h. |
8 #include "third_party/re2/re2/re2.h" | 8 #include "third_party/re2/re2/re2.h" |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 #if !defined(GOOGLE_CHROME_BUILD) | 192 #if !defined(GOOGLE_CHROME_BUILD) |
193 AMDVideoCardType GetAMDVideocardType() { | 193 AMDVideoCardType GetAMDVideocardType() { |
194 return UNKNOWN; | 194 return UNKNOWN; |
195 } | 195 } |
196 #else | 196 #else |
197 // This function has a real implementation for official builds that can | 197 // This function has a real implementation for official builds that can |
198 // be found in src/third_party/amd. | 198 // be found in src/third_party/amd. |
199 AMDVideoCardType GetAMDVideocardType(); | 199 AMDVideoCardType GetAMDVideocardType(); |
200 #endif | 200 #endif |
201 | 201 |
202 // Collects information about the level of D3D11 support and records it in | 202 void CollectD3D11Support() { |
203 // the UMA stats. Records no stats when D3D11 in not supported at all. | |
204 // | |
205 // http://crbug.com/175525. Using D3D11 seems to crash when dlumd32.dll is | |
206 // loaded. This function is not currently called. | |
207 void CollectD3D11Support(HMODULE d3d11_module) { | |
208 TRACE_EVENT0("gpu", "CollectD3D11Support"); | |
209 | |
210 typedef HRESULT (WINAPI *D3D11CreateDeviceFunc)( | 203 typedef HRESULT (WINAPI *D3D11CreateDeviceFunc)( |
211 IDXGIAdapter* adapter, | 204 IDXGIAdapter* adapter, |
212 D3D_DRIVER_TYPE driver_type, | 205 D3D_DRIVER_TYPE driver_type, |
213 HMODULE software, | 206 HMODULE software, |
214 UINT flags, | 207 UINT flags, |
215 const D3D_FEATURE_LEVEL* feature_levels, | 208 const D3D_FEATURE_LEVEL* feature_levels, |
216 UINT num_feature_levels, | 209 UINT num_feature_levels, |
217 UINT sdk_version, | 210 UINT sdk_version, |
218 ID3D11Device** device, | 211 ID3D11Device** device, |
219 D3D_FEATURE_LEVEL* feature_level, | 212 D3D_FEATURE_LEVEL* feature_level, |
220 ID3D11DeviceContext** immediate_context); | 213 ID3D11DeviceContext** immediate_context); |
221 | 214 |
222 // This enumeration must be kept in sync with histograms.xml. Do not reorder | 215 // This enumeration must be kept in sync with histograms.xml. Do not reorder |
223 // the members; always add to the end. | 216 // the members; always add to the end. |
224 enum FeatureLevel { | 217 enum FeatureLevel { |
225 FEATURE_LEVEL_UNKNOWN, | 218 FEATURE_LEVEL_UNKNOWN, |
226 FEATURE_LEVEL_NO_D3D11_DLL, | 219 FEATURE_LEVEL_NO_D3D11_DLL, |
227 FEATURE_LEVEL_NO_CREATE_DEVICE_ENTRY_POINT, | 220 FEATURE_LEVEL_NO_CREATE_DEVICE_ENTRY_POINT, |
228 FEATURE_LEVEL_DEVICE_CREATION_FAILED, | 221 FEATURE_LEVEL_DEVICE_CREATION_FAILED, |
229 FEATURE_LEVEL_9_1, | 222 FEATURE_LEVEL_9_1, |
230 FEATURE_LEVEL_9_2, | 223 FEATURE_LEVEL_9_2, |
231 FEATURE_LEVEL_9_3, | 224 FEATURE_LEVEL_9_3, |
232 FEATURE_LEVEL_10_0, | 225 FEATURE_LEVEL_10_0, |
233 FEATURE_LEVEL_10_1, | 226 FEATURE_LEVEL_10_1, |
234 FEATURE_LEVEL_11_0, | 227 FEATURE_LEVEL_11_0, |
235 NUM_FEATURE_LEVELS | 228 NUM_FEATURE_LEVELS |
236 }; | 229 }; |
237 | 230 |
| 231 TRACE_EVENT0("gpu", "CollectD3D11Support"); |
| 232 |
| 233 // Windows XP is expected to not support D3D11. |
| 234 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 235 return; |
| 236 |
238 FeatureLevel feature_level = FEATURE_LEVEL_UNKNOWN; | 237 FeatureLevel feature_level = FEATURE_LEVEL_UNKNOWN; |
239 UINT bgra_support = 0; | 238 UINT bgra_support = 0; |
240 | 239 |
| 240 // This is leaked in case it is hooked by a third party DLL. |
| 241 base::NativeLibrary d3d11_module = base::LoadNativeLibrary( |
| 242 base::FilePath(L"d3d11.dll"), |
| 243 NULL); |
| 244 |
241 if (!d3d11_module) { | 245 if (!d3d11_module) { |
242 feature_level = FEATURE_LEVEL_NO_D3D11_DLL; | 246 feature_level = FEATURE_LEVEL_NO_D3D11_DLL; |
243 } else { | 247 } else { |
244 D3D11CreateDeviceFunc create_func = | 248 D3D11CreateDeviceFunc create_func = |
245 reinterpret_cast<D3D11CreateDeviceFunc>( | 249 reinterpret_cast<D3D11CreateDeviceFunc>( |
246 GetProcAddress(d3d11_module, "D3D11CreateDevice")); | 250 base::GetFunctionPointerFromNativeLibrary(d3d11_module, |
| 251 "D3D11CreateDevice")); |
247 if (!create_func) { | 252 if (!create_func) { |
248 feature_level = FEATURE_LEVEL_NO_CREATE_DEVICE_ENTRY_POINT; | 253 feature_level = FEATURE_LEVEL_NO_CREATE_DEVICE_ENTRY_POINT; |
249 } else { | 254 } else { |
250 static const D3D_FEATURE_LEVEL d3d_feature_levels[] = { | 255 static const D3D_FEATURE_LEVEL d3d_feature_levels[] = { |
251 D3D_FEATURE_LEVEL_11_0, | 256 D3D_FEATURE_LEVEL_11_0, |
252 D3D_FEATURE_LEVEL_10_1, | 257 D3D_FEATURE_LEVEL_10_1, |
253 D3D_FEATURE_LEVEL_10_0, | 258 D3D_FEATURE_LEVEL_10_0, |
254 D3D_FEATURE_LEVEL_9_3, | 259 D3D_FEATURE_LEVEL_9_3, |
255 D3D_FEATURE_LEVEL_9_2, | 260 D3D_FEATURE_LEVEL_9_2, |
256 D3D_FEATURE_LEVEL_9_1 | 261 D3D_FEATURE_LEVEL_9_1 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 return; | 318 return; |
314 | 319 |
315 UMA_HISTOGRAM_BOOLEAN( | 320 UMA_HISTOGRAM_BOOLEAN( |
316 "GPU.D3D11_B8G8R8A8_Texture2DSupport", | 321 "GPU.D3D11_B8G8R8A8_Texture2DSupport", |
317 (bgra_support & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0); | 322 (bgra_support & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0); |
318 UMA_HISTOGRAM_BOOLEAN( | 323 UMA_HISTOGRAM_BOOLEAN( |
319 "GPU.D3D11_B8G8R8A8_RenderTargetSupport", | 324 "GPU.D3D11_B8G8R8A8_RenderTargetSupport", |
320 (bgra_support & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0); | 325 (bgra_support & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0); |
321 } | 326 } |
322 | 327 |
323 void CollectD3D11SupportDelayed( | |
324 const scoped_refptr<base::MessageLoopProxy> main_loop) { | |
325 // Windows XP is expected to not support D3D11. | |
326 if (base::win::GetVersion() <= base::win::VERSION_XP) | |
327 return; | |
328 | |
329 // This is leaked in case it is hooked by a third party DLL. | |
330 HMODULE d3d11_module = LoadLibrary(L"d3d11.dll"); | |
331 | |
332 // Collect the D3D11 stats after a delay to allow third party DLLs | |
333 // to hook D3D11 before we try to use it. Also do it on the main thread | |
334 // in case the third party DLL does this on the main thread. | |
335 main_loop->PostDelayedTask( | |
336 FROM_HERE, | |
337 base::Bind(CollectD3D11Support, d3d11_module), | |
338 base::TimeDelta::FromSeconds(10)); | |
339 } | |
340 | |
341 bool CollectDriverInfoD3D(const std::wstring& device_id, | 328 bool CollectDriverInfoD3D(const std::wstring& device_id, |
342 content::GPUInfo* gpu_info) { | 329 content::GPUInfo* gpu_info) { |
343 TRACE_EVENT0("gpu", "CollectDriverInfoD3D"); | 330 TRACE_EVENT0("gpu", "CollectDriverInfoD3D"); |
344 | 331 |
345 // create device info for the display device | 332 // create device info for the display device |
346 HDEVINFO device_info = SetupDiGetClassDevsW( | 333 HDEVINFO device_info = SetupDiGetClassDevsW( |
347 NULL, device_id.c_str(), NULL, | 334 NULL, device_id.c_str(), NULL, |
348 DIGCF_PRESENT | DIGCF_PROFILE | DIGCF_ALLCLASSES); | 335 DIGCF_PRESENT | DIGCF_PROFILE | DIGCF_ALLCLASSES); |
349 if (device_info == INVALID_HANDLE_VALUE) { | 336 if (device_info == INVALID_HANDLE_VALUE) { |
350 LOG(ERROR) << "Creating device info failed"; | 337 LOG(ERROR) << "Creating device info failed"; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 basic_gpu_info->software_rendering = true; | 564 basic_gpu_info->software_rendering = true; |
578 return; | 565 return; |
579 } | 566 } |
580 | 567 |
581 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); | 568 MergeGPUInfoGL(basic_gpu_info, context_gpu_info); |
582 | 569 |
583 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; | 570 basic_gpu_info->dx_diagnostics = context_gpu_info.dx_diagnostics; |
584 } | 571 } |
585 | 572 |
586 } // namespace gpu_info_collector | 573 } // namespace gpu_info_collector |
OLD | NEW |