diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-08 18:03:21 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-08 18:03:21 +0000 |
commit | 81f85b378c9d8c7c3e23233a78d28da785c97a9a (patch) | |
tree | bd6a621b4eea4810e101bf5bf56ced34583573fe /chrome/gpu | |
parent | d1fdc6f83a75e316aafef3ff0f84f30a132f08c3 (diff) | |
download | chromium_src-81f85b378c9d8c7c3e23233a78d28da785c97a9a.zip chromium_src-81f85b378c9d8c7c3e23233a78d28da785c97a9a.tar.gz chromium_src-81f85b378c9d8c7c3e23233a78d28da785c97a9a.tar.bz2 |
Relanding 61904 with missing file this time.
Original description:
Added DirectX Diagnostics information to about:gpu on Windows.
This includes the name of the GPU hardware and the driver version and release
date and some other information that might potentially also be valuable in the
GPU stats.
TEST=try
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r-- | chrome/gpu/gpu_dx_diagnostics_win.cc | 132 | ||||
-rw-r--r-- | chrome/gpu/gpu_info_collector.h | 5 | ||||
-rw-r--r-- | chrome/gpu/gpu_info_collector_win.cc | 6 |
3 files changed, 143 insertions, 0 deletions
diff --git a/chrome/gpu/gpu_dx_diagnostics_win.cc b/chrome/gpu/gpu_dx_diagnostics_win.cc new file mode 100644 index 0000000..f6ee3c0 --- /dev/null +++ b/chrome/gpu/gpu_dx_diagnostics_win.cc @@ -0,0 +1,132 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Functions to enumerate the Dx Diagnostic Tool hierarchy and build up +// a tree of nodes with name / value properties. + +#define INITGUID +#include <dxdiag.h> +#include <windows.h> + +#include "chrome/gpu/gpu_info_collector.h" + +#include "base/string_number_conversions.h" +#include "base/utf_string_conversions.h" + +namespace { + +// Traverses the IDxDiagContainer tree and populates a tree of DxDiagNode +// structures that contains property name / value pairs and subtrees of DirectX +// diagnostic information. +void RecurseDiagnosticTree(DxDiagNode* output, + IDxDiagContainer* container) { + HRESULT hr; + + VARIANT variant; + VariantInit(&variant); + + DWORD prop_count; + hr = container->GetNumberOfProps(&prop_count); + if (SUCCEEDED(hr)) { + for (DWORD i = 0; i < prop_count; i++) { + WCHAR prop_name16[256]; + hr = container->EnumPropNames(i, prop_name16, arraysize(prop_name16)); + if (SUCCEEDED(hr)) { + std::string prop_name8 = WideToUTF8(prop_name16); + + hr = container->GetProp(prop_name16, &variant); + if (SUCCEEDED(hr)) { + switch (variant.vt) { + case VT_UI4: + output->values[prop_name8] = base::UintToString(variant.ulVal); + break; + case VT_I4: + output->values[prop_name8] = base::IntToString(variant.lVal); + break; + case VT_BOOL: + output->values[prop_name8] = variant.boolVal ? "true" : "false"; + break; + case VT_BSTR: + output->values[prop_name8] = WideToUTF8(variant.bstrVal); + break; + default: + break; + } + + // Clear the variant (this is needed to free BSTR memory). + VariantClear(&variant); + } + } + } + } + + DWORD child_count; + hr = container->GetNumberOfChildContainers(&child_count); + if (SUCCEEDED(hr)) { + for (DWORD i = 0; i < child_count; i++) { + WCHAR child_name16[256]; + hr = container->EnumChildContainerNames(i, + child_name16, + arraysize(child_name16)); + if (SUCCEEDED(hr)) { + std::string child_name8 = WideToUTF8(child_name16); + DxDiagNode* output_child = + &output->children[child_name8]; + + IDxDiagContainer* child_container = NULL; + hr = container->GetChildContainer(child_name16, &child_container); + if (SUCCEEDED(hr)) { + RecurseDiagnosticTree(output_child, child_container); + + child_container->Release(); + } + } + } + } +} +} // namespace anonymous + +namespace gpu_info_collector { + +bool GetDxDiagnostics(DxDiagNode* output) { + HRESULT hr; + bool success = false; + + IDxDiagProvider* provider = NULL; + hr = CoCreateInstance(CLSID_DxDiagProvider, + NULL, + CLSCTX_INPROC_SERVER, + IID_IDxDiagProvider, + reinterpret_cast<void**>(&provider)); + if (SUCCEEDED(hr)) { + DXDIAG_INIT_PARAMS params = { sizeof(params) }; + params.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION; + params.bAllowWHQLChecks = FALSE; + params.pReserved = NULL; + + hr = provider->Initialize(¶ms); + if (SUCCEEDED(hr)) { + IDxDiagContainer* root = NULL; + hr = provider->GetRootContainer(&root); + if (SUCCEEDED(hr)) { + // Limit to the DisplayDevices subtree. The tree in its entirity is + // enormous and only this branch contains useful information. + IDxDiagContainer* display_devices = NULL; + hr = root->GetChildContainer(L"DxDiag_DisplayDevices", + &display_devices); + if (SUCCEEDED(hr)) { + RecurseDiagnosticTree(output, display_devices); + success = true; + display_devices->Release(); + } + + root->Release(); + } + } + provider->Release(); + } + + return success; +} +} // namespace gpu_info_collector diff --git a/chrome/gpu/gpu_info_collector.h b/chrome/gpu/gpu_info_collector.h index 2b647c9..ea11093 100644 --- a/chrome/gpu/gpu_info_collector.h +++ b/chrome/gpu/gpu_info_collector.h @@ -7,6 +7,8 @@ #pragma once #include "base/basictypes.h" +#include "build/build_config.h" +#include "chrome/common/dx_diag_node.h" #include "chrome/common/gpu_info.h" struct IDirect3D9; @@ -27,6 +29,9 @@ bool CollectGraphicsInfoD3D(IDirect3D9* d3d, GPUInfo* gpu_info); // The GL version of collecting information bool CollectGraphicsInfoGL(GPUInfo* gpu_info); + +// Collect the DirectX Disagnostics information about the attached displays. +bool GetDxDiagnostics(DxDiagNode* output); #endif } // namespace gpu_info_collector diff --git a/chrome/gpu/gpu_info_collector_win.cc b/chrome/gpu/gpu_info_collector_win.cc index 1e3124b..b5d30b4 100644 --- a/chrome/gpu/gpu_info_collector_win.cc +++ b/chrome/gpu/gpu_info_collector_win.cc @@ -37,6 +37,12 @@ bool CollectGraphicsInfo(GPUInfo* gpu_info) { if (FAILED(device->GetDirect3D(&d3d))) return false; + // Don't fail if DirectX diagnostics are not available. Just leave the tree + // empty. The other GPU info is still valuable. + DxDiagNode dx_diagnostics; + if (GetDxDiagnostics(&dx_diagnostics)) + gpu_info->SetDxDiagnostics(dx_diagnostics); + return CollectGraphicsInfoD3D(d3d, gpu_info); } |