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
3 // found in the LICENSE file.
5 #include "gpu/config/gpu_info.h"
9 void EnumerateGPUDevice(gpu::GPUInfo::Enumerator
* enumerator
,
10 const gpu::GPUInfo::GPUDevice
& device
) {
11 enumerator
->BeginGPUDevice();
12 enumerator
->AddInt("vendorId", device
.vendor_id
);
13 enumerator
->AddInt("deviceId", device
.device_id
);
14 enumerator
->AddBool("active", device
.active
);
15 enumerator
->AddString("vendorString", device
.vendor_string
);
16 enumerator
->AddString("deviceString", device
.device_string
);
17 enumerator
->EndGPUDevice();
24 GPUInfo::GPUDevice::GPUDevice()
30 GPUInfo::GPUDevice::~GPUDevice() { }
35 amd_switchable(false),
38 gl_reset_notification_strategy(0),
39 can_lose_context(false),
40 software_rendering(false),
41 direct_rendering(true),
43 process_crash_count(0) {
46 GPUInfo::~GPUInfo() { }
48 void GPUInfo::EnumerateFields(Enumerator
* enumerator
) const {
49 struct GPUInfoKnownFields
{
51 base::TimeDelta initialization_time
;
55 Version display_link_version
;
57 std::vector
<GPUDevice
> secondary_gpus
;
59 std::string driver_vendor
;
60 std::string driver_version
;
61 std::string driver_date
;
62 std::string pixel_shader_version
;
63 std::string vertex_shader_version
;
64 std::string machine_model_name
;
65 std::string machine_model_version
;
66 std::string gl_version_string
;
67 std::string gl_vendor
;
68 std::string gl_renderer
;
69 std::string gl_extensions
;
70 std::string gl_ws_vendor
;
71 std::string gl_ws_version
;
72 std::string gl_ws_extensions
;
73 uint32 gl_reset_notification_strategy
;
74 bool can_lose_context
;
75 GpuPerformanceStats performance_stats
;
76 bool software_rendering
;
77 bool direct_rendering
;
79 int process_crash_count
;
81 DxDiagNode dx_diagnostics
;
85 // If this assert fails then most likely something below needs to be updated.
86 // Note that this assert is only approximate. If a new field is added to
87 // GPUInfo which fits within the current padding then it will not be caught.
89 sizeof(GPUInfo
) == sizeof(GPUInfoKnownFields
),
90 Fields_Have_Changed_In_GPUInfo_So_Update_Below
);
92 // Required fields (according to DevTools protocol) first.
93 enumerator
->AddString("machineModelName", machine_model_name
);
94 enumerator
->AddString("machineModelVersion", machine_model_version
);
95 EnumerateGPUDevice(enumerator
, gpu
);
96 for (size_t ii
= 0; ii
< secondary_gpus
.size(); ++ii
) {
97 EnumerateGPUDevice(enumerator
, secondary_gpus
[ii
]);
100 enumerator
->BeginAuxAttributes();
101 enumerator
->AddBool("finalized", finalized
);
102 enumerator
->AddTimeDeltaInSecondsF("initializationTime",
103 initialization_time
);
104 enumerator
->AddBool("optimus", optimus
);
105 enumerator
->AddBool("amdSwitchable", amd_switchable
);
106 enumerator
->AddBool("lenovoDcute", lenovo_dcute
);
107 if (display_link_version
.IsValid()) {
108 enumerator
->AddString("displayLinkVersion",
109 display_link_version
.GetString());
111 enumerator
->AddInt64("adapterLuid", adapter_luid
);
112 enumerator
->AddString("driverVendor", driver_vendor
);
113 enumerator
->AddString("driverVersion", driver_version
);
114 enumerator
->AddString("driverDate", driver_date
);
115 enumerator
->AddString("pixelShaderVersion", pixel_shader_version
);
116 enumerator
->AddString("vertexShaderVersion", vertex_shader_version
);
117 enumerator
->AddString("glVersion", gl_version
);
118 enumerator
->AddString("glVendor", gl_vendor
);
119 enumerator
->AddString("glRenderer", gl_renderer
);
120 enumerator
->AddString("glExtensions", gl_extensions
);
121 enumerator
->AddString("glWsVendor", gl_ws_vendor
);
122 enumerator
->AddString("glWsVersion", gl_ws_version
);
123 enumerator
->AddString("glWsExtensions", gl_ws_extensions
);
125 "glResetNotificationStrategy",
126 static_cast<int>(gl_reset_notification_strategy
));
127 enumerator
->AddBool("can_lose_context", can_lose_context
);
128 // TODO(kbr): add performance_stats.
129 enumerator
->AddBool("softwareRendering", software_rendering
);
130 enumerator
->AddBool("directRendering", direct_rendering
);
131 enumerator
->AddBool("sandboxed", sandboxed
);
132 enumerator
->AddInt("processCrashCount", process_crash_count
);
133 // TODO(kbr): add dx_diagnostics on Windows.
134 enumerator
->EndAuxAttributes();