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();
20 void EnumerateVideoEncodeAcceleratorSupportedProfile(
21 gpu::GPUInfo::Enumerator
* enumerator
,
22 const gpu::VideoEncodeAcceleratorSupportedProfile profile
) {
23 enumerator
->BeginVideoEncodeAcceleratorSupportedProfile();
24 enumerator
->AddInt("profile", profile
.profile
);
25 enumerator
->AddInt("maxResolutionWidth", profile
.max_resolution
.width());
26 enumerator
->AddInt("maxResolutionHeight", profile
.max_resolution
.height());
27 enumerator
->AddInt("maxFramerateNumerator", profile
.max_framerate_numerator
);
28 enumerator
->AddInt("maxFramerateDenominator",
29 profile
.max_framerate_denominator
);
30 enumerator
->EndVideoEncodeAcceleratorSupportedProfile();
37 GPUInfo::GPUDevice::GPUDevice()
43 GPUInfo::GPUDevice::~GPUDevice() { }
47 amd_switchable(false),
50 gl_reset_notification_strategy(0),
51 can_lose_context(false),
52 software_rendering(false),
53 direct_rendering(true),
55 process_crash_count(0),
56 basic_info_state(kCollectInfoNone
),
58 context_info_state(kCollectInfoNone
),
59 dx_diagnostics_info_state(kCollectInfoNone
) {
61 context_info_state(kCollectInfoNone
) {
65 GPUInfo::~GPUInfo() { }
67 void GPUInfo::EnumerateFields(Enumerator
* enumerator
) const {
68 struct GPUInfoKnownFields
{
69 base::TimeDelta initialization_time
;
73 Version display_link_version
;
75 std::vector
<GPUDevice
> secondary_gpus
;
77 std::string driver_vendor
;
78 std::string driver_version
;
79 std::string driver_date
;
80 std::string pixel_shader_version
;
81 std::string vertex_shader_version
;
82 std::string machine_model_name
;
83 std::string machine_model_version
;
84 std::string gl_version_string
;
85 std::string gl_vendor
;
86 std::string gl_renderer
;
87 std::string gl_extensions
;
88 std::string gl_ws_vendor
;
89 std::string gl_ws_version
;
90 std::string gl_ws_extensions
;
91 uint32 gl_reset_notification_strategy
;
92 bool can_lose_context
;
93 bool software_rendering
;
94 bool direct_rendering
;
96 int process_crash_count
;
97 CollectInfoResult basic_info_state
;
98 CollectInfoResult context_info_state
;
100 CollectInfoResult dx_diagnostics_info_state
;
101 DxDiagNode dx_diagnostics
;
103 std::vector
<VideoEncodeAcceleratorSupportedProfile
>
104 video_encode_accelerator_supported_profiles
;
107 // If this assert fails then most likely something below needs to be updated.
108 // Note that this assert is only approximate. If a new field is added to
109 // GPUInfo which fits within the current padding then it will not be caught.
111 sizeof(GPUInfo
) == sizeof(GPUInfoKnownFields
),
112 "fields have changed in GPUInfo, GPUInfoKnownFields must be updated");
114 // Required fields (according to DevTools protocol) first.
115 enumerator
->AddString("machineModelName", machine_model_name
);
116 enumerator
->AddString("machineModelVersion", machine_model_version
);
117 EnumerateGPUDevice(enumerator
, gpu
);
118 for (size_t ii
= 0; ii
< secondary_gpus
.size(); ++ii
) {
119 EnumerateGPUDevice(enumerator
, secondary_gpus
[ii
]);
122 enumerator
->BeginAuxAttributes();
123 enumerator
->AddTimeDeltaInSecondsF("initializationTime",
124 initialization_time
);
125 enumerator
->AddBool("optimus", optimus
);
126 enumerator
->AddBool("amdSwitchable", amd_switchable
);
127 enumerator
->AddBool("lenovoDcute", lenovo_dcute
);
128 if (display_link_version
.IsValid()) {
129 enumerator
->AddString("displayLinkVersion",
130 display_link_version
.GetString());
132 enumerator
->AddInt64("adapterLuid", adapter_luid
);
133 enumerator
->AddString("driverVendor", driver_vendor
);
134 enumerator
->AddString("driverVersion", driver_version
);
135 enumerator
->AddString("driverDate", driver_date
);
136 enumerator
->AddString("pixelShaderVersion", pixel_shader_version
);
137 enumerator
->AddString("vertexShaderVersion", vertex_shader_version
);
138 enumerator
->AddString("glVersion", gl_version
);
139 enumerator
->AddString("glVendor", gl_vendor
);
140 enumerator
->AddString("glRenderer", gl_renderer
);
141 enumerator
->AddString("glExtensions", gl_extensions
);
142 enumerator
->AddString("glWsVendor", gl_ws_vendor
);
143 enumerator
->AddString("glWsVersion", gl_ws_version
);
144 enumerator
->AddString("glWsExtensions", gl_ws_extensions
);
146 "glResetNotificationStrategy",
147 static_cast<int>(gl_reset_notification_strategy
));
148 enumerator
->AddBool("can_lose_context", can_lose_context
);
149 // TODO(kbr): add performance_stats.
150 enumerator
->AddBool("softwareRendering", software_rendering
);
151 enumerator
->AddBool("directRendering", direct_rendering
);
152 enumerator
->AddBool("sandboxed", sandboxed
);
153 enumerator
->AddInt("processCrashCount", process_crash_count
);
154 enumerator
->AddInt("basicInfoState", basic_info_state
);
155 enumerator
->AddInt("contextInfoState", context_info_state
);
157 enumerator
->AddInt("DxDiagnosticsInfoState", dx_diagnostics_info_state
);
159 // TODO(kbr): add dx_diagnostics on Windows.
160 for (size_t ii
= 0; ii
< video_encode_accelerator_supported_profiles
.size();
162 EnumerateVideoEncodeAcceleratorSupportedProfile(
163 enumerator
, video_encode_accelerator_supported_profiles
[ii
]);
165 enumerator
->EndAuxAttributes();