blob: 6ce2d784dcfc97eb6192091f10404f88545d059b [file] [log] [blame]
[email protected]84ad3a72012-02-07 00:29:451// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]a80f5ece2011-10-20 23:56:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
avif15d60a2015-12-21 17:06:335#include <stdint.h>
6
[email protected]d7b5cc72013-05-23 20:05:007#include "gpu/config/gpu_info.h"
[email protected]a80f5ece2011-10-20 23:56:558
[email protected]fd4dcc52013-08-15 11:37:439namespace {
10
henryhsud1185442015-04-10 06:39:1411void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device,
12 gpu::GPUInfo::Enumerator* enumerator) {
[email protected]fd4dcc52013-08-15 11:37:4313 enumerator->BeginGPUDevice();
14 enumerator->AddInt("vendorId", device.vendor_id);
15 enumerator->AddInt("deviceId", device.device_id);
[email protected]20e7cfc2014-04-02 17:33:1316 enumerator->AddBool("active", device.active);
[email protected]fd4dcc52013-08-15 11:37:4317 enumerator->AddString("vendorString", device.vendor_string);
18 enumerator->AddString("deviceString", device.device_string);
19 enumerator->EndGPUDevice();
20}
21
henryhsud1185442015-04-10 06:39:1422void EnumerateVideoDecodeAcceleratorSupportedProfile(
23 const gpu::VideoDecodeAcceleratorSupportedProfile& profile,
24 gpu::GPUInfo::Enumerator* enumerator) {
25 enumerator->BeginVideoDecodeAcceleratorSupportedProfile();
26 enumerator->AddInt("profile", profile.profile);
27 enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
28 enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
29 enumerator->AddInt("minResolutionWidth", profile.min_resolution.width());
30 enumerator->AddInt("minResolutionHeight", profile.min_resolution.height());
dalecurtis4708098a2016-03-19 04:54:1131 enumerator->AddBool("encrypted_only", profile.encrypted_only);
henryhsud1185442015-04-10 06:39:1432 enumerator->EndVideoDecodeAcceleratorSupportedProfile();
33}
34
wuchengli79808322014-09-23 05:58:1435void EnumerateVideoEncodeAcceleratorSupportedProfile(
henryhsud1185442015-04-10 06:39:1436 const gpu::VideoEncodeAcceleratorSupportedProfile& profile,
37 gpu::GPUInfo::Enumerator* enumerator) {
wuchengli79808322014-09-23 05:58:1438 enumerator->BeginVideoEncodeAcceleratorSupportedProfile();
39 enumerator->AddInt("profile", profile.profile);
40 enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
41 enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
42 enumerator->AddInt("maxFramerateNumerator", profile.max_framerate_numerator);
43 enumerator->AddInt("maxFramerateDenominator",
44 profile.max_framerate_denominator);
45 enumerator->EndVideoEncodeAcceleratorSupportedProfile();
46}
47
[email protected]fd4dcc52013-08-15 11:37:4348} // namespace
49
[email protected]d7b5cc72013-05-23 20:05:0050namespace gpu {
[email protected]a80f5ece2011-10-20 23:56:5551
liberato575877902015-12-10 17:16:2652VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities()
53 : flags(0) {}
54
vmpstr3b7b8b22016-03-01 23:00:2055VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities(
56 const VideoDecodeAcceleratorCapabilities& other) = default;
57
liberato575877902015-12-10 17:16:2658VideoDecodeAcceleratorCapabilities::~VideoDecodeAcceleratorCapabilities() {}
59
[email protected]a094e2c2012-05-10 23:02:4260GPUInfo::GPUDevice::GPUDevice()
61 : vendor_id(0),
[email protected]20e7cfc2014-04-02 17:33:1362 device_id(0),
63 active(false) {
[email protected]a094e2c2012-05-10 23:02:4264}
65
66GPUInfo::GPUDevice::~GPUDevice() { }
67
[email protected]a80f5ece2011-10-20 23:56:5568GPUInfo::GPUInfo()
zmo84eae5e2014-09-05 01:36:2369 : optimus(false),
[email protected]c32b0c2c2012-04-07 01:34:3370 amd_switchable(false),
[email protected]68852bd2013-03-12 03:47:0871 lenovo_dcute(false),
[email protected]fd00eee52013-05-24 22:32:2872 adapter_luid(0),
[email protected]6c7784e2013-08-01 22:41:2873 gl_reset_notification_strategy(0),
[email protected]fad3ccf2012-09-11 22:36:0074 software_rendering(false),
[email protected]0e8cac72014-03-22 00:37:1875 direct_rendering(true),
[email protected]47752982014-07-29 08:01:4376 sandboxed(false),
zmo84eae5e2014-09-05 01:36:2377 process_crash_count(0),
bajonese3677b649ff2015-07-25 00:41:5678 in_process_gpu(true),
geofflang774e87a2016-12-05 16:29:0179 passthrough_cmd_decoder(false),
zmo84eae5e2014-09-05 01:36:2380 basic_info_state(kCollectInfoNone),
zmo84eae5e2014-09-05 01:36:2381 context_info_state(kCollectInfoNone),
henryhsu74f6ef12015-07-23 08:34:3782#if defined(OS_WIN)
83 dx_diagnostics_info_state(kCollectInfoNone),
zmo84eae5e2014-09-05 01:36:2384#endif
thomasanderson62ba78ff2016-10-01 02:03:4285 jpeg_decode_accelerator_supported(false)
86#if defined(USE_X11) && !defined(OS_CHROMEOS)
87 ,
88 system_visual(0),
89 rgba_visual(0)
90#endif
91{
[email protected]a80f5ece2011-10-20 23:56:5592}
93
vmpstr3b7b8b22016-03-01 23:00:2094GPUInfo::GPUInfo(const GPUInfo& other) = default;
95
[email protected]a80f5ece2011-10-20 23:56:5596GPUInfo::~GPUInfo() { }
97
[email protected]fd4dcc52013-08-15 11:37:4398void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
99 struct GPUInfoKnownFields {
[email protected]fd4dcc52013-08-15 11:37:43100 base::TimeDelta initialization_time;
101 bool optimus;
102 bool amd_switchable;
103 bool lenovo_dcute;
pwnall9484f3a02016-08-20 00:34:38104 base::Version display_link_version;
[email protected]fd4dcc52013-08-15 11:37:43105 GPUDevice gpu;
106 std::vector<GPUDevice> secondary_gpus;
avif15d60a2015-12-21 17:06:33107 uint64_t adapter_luid;
[email protected]fd4dcc52013-08-15 11:37:43108 std::string driver_vendor;
109 std::string driver_version;
110 std::string driver_date;
111 std::string pixel_shader_version;
112 std::string vertex_shader_version;
senorblancob7a64d572015-04-08 16:59:02113 std::string max_msaa_samples;
[email protected]2ac8e51c2014-04-21 20:54:13114 std::string machine_model_name;
115 std::string machine_model_version;
[email protected]fd4dcc52013-08-15 11:37:43116 std::string gl_version_string;
117 std::string gl_vendor;
118 std::string gl_renderer;
119 std::string gl_extensions;
120 std::string gl_ws_vendor;
121 std::string gl_ws_version;
122 std::string gl_ws_extensions;
avif15d60a2015-12-21 17:06:33123 uint32_t gl_reset_notification_strategy;
[email protected]fd4dcc52013-08-15 11:37:43124 bool software_rendering;
[email protected]0e8cac72014-03-22 00:37:18125 bool direct_rendering;
[email protected]fd4dcc52013-08-15 11:37:43126 bool sandboxed;
[email protected]47752982014-07-29 08:01:43127 int process_crash_count;
bajonese3677b649ff2015-07-25 00:41:56128 bool in_process_gpu;
geofflang774e87a2016-12-05 16:29:01129 bool passthrough_cmd_decoder;
zmo84eae5e2014-09-05 01:36:23130 CollectInfoResult basic_info_state;
131 CollectInfoResult context_info_state;
[email protected]fd4dcc52013-08-15 11:37:43132#if defined(OS_WIN)
zmo84eae5e2014-09-05 01:36:23133 CollectInfoResult dx_diagnostics_info_state;
[email protected]fd4dcc52013-08-15 11:37:43134 DxDiagNode dx_diagnostics;
135#endif
liberato575877902015-12-10 17:16:26136 VideoDecodeAcceleratorCapabilities video_decode_accelerator_capabilities;
henryhsud1185442015-04-10 06:39:14137 VideoEncodeAcceleratorSupportedProfiles
wuchengli79808322014-09-23 05:58:14138 video_encode_accelerator_supported_profiles;
henryhsu74f6ef12015-07-23 08:34:37139 bool jpeg_decode_accelerator_supported;
thomasanderson62ba78ff2016-10-01 02:03:42140#if defined(USE_X11) && !defined(OS_CHROMEOS)
141 VisualID system_visual;
142 VisualID rgba_visual;
143#endif
[email protected]fd4dcc52013-08-15 11:37:43144 };
145
146 // If this assert fails then most likely something below needs to be updated.
147 // Note that this assert is only approximate. If a new field is added to
148 // GPUInfo which fits within the current padding then it will not be caught.
mostynb7f032092014-12-20 00:36:44149 static_assert(
[email protected]fd4dcc52013-08-15 11:37:43150 sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
mostynb7f032092014-12-20 00:36:44151 "fields have changed in GPUInfo, GPUInfoKnownFields must be updated");
[email protected]fd4dcc52013-08-15 11:37:43152
153 // Required fields (according to DevTools protocol) first.
[email protected]2ac8e51c2014-04-21 20:54:13154 enumerator->AddString("machineModelName", machine_model_name);
155 enumerator->AddString("machineModelVersion", machine_model_version);
henryhsud1185442015-04-10 06:39:14156 EnumerateGPUDevice(gpu, enumerator);
157 for (const auto& secondary_gpu: secondary_gpus)
158 EnumerateGPUDevice(secondary_gpu, enumerator);
[email protected]fd4dcc52013-08-15 11:37:43159
160 enumerator->BeginAuxAttributes();
[email protected]fd4dcc52013-08-15 11:37:43161 enumerator->AddTimeDeltaInSecondsF("initializationTime",
162 initialization_time);
163 enumerator->AddBool("optimus", optimus);
164 enumerator->AddBool("amdSwitchable", amd_switchable);
165 enumerator->AddBool("lenovoDcute", lenovo_dcute);
166 if (display_link_version.IsValid()) {
167 enumerator->AddString("displayLinkVersion",
168 display_link_version.GetString());
169 }
170 enumerator->AddInt64("adapterLuid", adapter_luid);
171 enumerator->AddString("driverVendor", driver_vendor);
172 enumerator->AddString("driverVersion", driver_version);
173 enumerator->AddString("driverDate", driver_date);
174 enumerator->AddString("pixelShaderVersion", pixel_shader_version);
175 enumerator->AddString("vertexShaderVersion", vertex_shader_version);
senorblancob7a64d572015-04-08 16:59:02176 enumerator->AddString("maxMsaaSamples", max_msaa_samples);
[email protected]fd4dcc52013-08-15 11:37:43177 enumerator->AddString("glVersion", gl_version);
[email protected]fd4dcc52013-08-15 11:37:43178 enumerator->AddString("glVendor", gl_vendor);
179 enumerator->AddString("glRenderer", gl_renderer);
180 enumerator->AddString("glExtensions", gl_extensions);
181 enumerator->AddString("glWsVendor", gl_ws_vendor);
182 enumerator->AddString("glWsVersion", gl_ws_version);
183 enumerator->AddString("glWsExtensions", gl_ws_extensions);
184 enumerator->AddInt(
185 "glResetNotificationStrategy",
186 static_cast<int>(gl_reset_notification_strategy));
[email protected]fd4dcc52013-08-15 11:37:43187 // TODO(kbr): add performance_stats.
188 enumerator->AddBool("softwareRendering", software_rendering);
[email protected]0e8cac72014-03-22 00:37:18189 enumerator->AddBool("directRendering", direct_rendering);
[email protected]fd4dcc52013-08-15 11:37:43190 enumerator->AddBool("sandboxed", sandboxed);
[email protected]47752982014-07-29 08:01:43191 enumerator->AddInt("processCrashCount", process_crash_count);
bajonese3677b649ff2015-07-25 00:41:56192 enumerator->AddBool("inProcessGpu", in_process_gpu);
geofflang774e87a2016-12-05 16:29:01193 enumerator->AddBool("passthroughCmdDecoder", passthrough_cmd_decoder);
zmo84eae5e2014-09-05 01:36:23194 enumerator->AddInt("basicInfoState", basic_info_state);
195 enumerator->AddInt("contextInfoState", context_info_state);
196#if defined(OS_WIN)
197 enumerator->AddInt("DxDiagnosticsInfoState", dx_diagnostics_info_state);
198#endif
[email protected]fd4dcc52013-08-15 11:37:43199 // TODO(kbr): add dx_diagnostics on Windows.
liberato575877902015-12-10 17:16:26200 enumerator->AddInt("videoDecodeAcceleratorFlags",
201 video_decode_accelerator_capabilities.flags);
202 for (const auto& profile :
203 video_decode_accelerator_capabilities.supported_profiles)
henryhsud1185442015-04-10 06:39:14204 EnumerateVideoDecodeAcceleratorSupportedProfile(profile, enumerator);
205 for (const auto& profile : video_encode_accelerator_supported_profiles)
206 EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator);
henryhsu74f6ef12015-07-23 08:34:37207 enumerator->AddBool("jpegDecodeAcceleratorSupported",
208 jpeg_decode_accelerator_supported);
thomasanderson62ba78ff2016-10-01 02:03:42209#if defined(USE_X11) && !defined(OS_CHROMEOS)
210 enumerator->AddInt64("systemVisual", system_visual);
211 enumerator->AddInt64("rgbaVisual", rgba_visual);
212#endif
[email protected]fd4dcc52013-08-15 11:37:43213 enumerator->EndAuxAttributes();
214}
215
[email protected]d7b5cc72013-05-23 20:05:00216} // namespace gpu