blob: f5aab647b3fdfac61cedf3760b6015229baff435 [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"
Zhenyao Mo964f6832019-09-17 01:41:098#include "gpu/config/gpu_util.h"
[email protected]a80f5ece2011-10-20 23:56:559
[email protected]fd4dcc52013-08-15 11:37:4310namespace {
11
henryhsud1185442015-04-10 06:39:1412void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device,
13 gpu::GPUInfo::Enumerator* enumerator) {
[email protected]fd4dcc52013-08-15 11:37:4314 enumerator->BeginGPUDevice();
15 enumerator->AddInt("vendorId", device.vendor_id);
16 enumerator->AddInt("deviceId", device.device_id);
Zhenyao Mo1d8d106a2019-09-26 19:32:4117#if defined(OS_WIN)
18 enumerator->AddInt("subSysId", device.sub_sys_id);
19 enumerator->AddInt("revision", device.revision);
20#endif // OS_WIN
[email protected]20e7cfc2014-04-02 17:33:1321 enumerator->AddBool("active", device.active);
[email protected]fd4dcc52013-08-15 11:37:4322 enumerator->AddString("vendorString", device.vendor_string);
23 enumerator->AddString("deviceString", device.device_string);
Zhenyao Mofbea81d2018-06-01 17:29:2724 enumerator->AddString("driverVendor", device.driver_vendor);
25 enumerator->AddString("driverVersion", device.driver_version);
Olli Etuaho1241aea2018-08-09 07:49:1526 enumerator->AddInt("cudaComputeCapabilityMajor",
27 device.cuda_compute_capability_major);
[email protected]fd4dcc52013-08-15 11:37:4328 enumerator->EndGPUDevice();
29}
30
henryhsud1185442015-04-10 06:39:1431void EnumerateVideoDecodeAcceleratorSupportedProfile(
32 const gpu::VideoDecodeAcceleratorSupportedProfile& profile,
33 gpu::GPUInfo::Enumerator* enumerator) {
34 enumerator->BeginVideoDecodeAcceleratorSupportedProfile();
35 enumerator->AddInt("profile", profile.profile);
36 enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
37 enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
38 enumerator->AddInt("minResolutionWidth", profile.min_resolution.width());
39 enumerator->AddInt("minResolutionHeight", profile.min_resolution.height());
dalecurtis4708098a2016-03-19 04:54:1140 enumerator->AddBool("encrypted_only", profile.encrypted_only);
henryhsud1185442015-04-10 06:39:1441 enumerator->EndVideoDecodeAcceleratorSupportedProfile();
42}
43
wuchengli79808322014-09-23 05:58:1444void EnumerateVideoEncodeAcceleratorSupportedProfile(
henryhsud1185442015-04-10 06:39:1445 const gpu::VideoEncodeAcceleratorSupportedProfile& profile,
46 gpu::GPUInfo::Enumerator* enumerator) {
wuchengli79808322014-09-23 05:58:1447 enumerator->BeginVideoEncodeAcceleratorSupportedProfile();
48 enumerator->AddInt("profile", profile.profile);
Miguel Casas4f26c552019-10-09 01:11:3949 enumerator->AddInt("minResolutionWidth", profile.min_resolution.width());
50 enumerator->AddInt("minResolutionHeight", profile.min_resolution.height());
wuchengli79808322014-09-23 05:58:1451 enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
52 enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
53 enumerator->AddInt("maxFramerateNumerator", profile.max_framerate_numerator);
54 enumerator->AddInt("maxFramerateDenominator",
55 profile.max_framerate_denominator);
56 enumerator->EndVideoEncodeAcceleratorSupportedProfile();
57}
58
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:3359const char* ImageDecodeAcceleratorTypeToString(
60 gpu::ImageDecodeAcceleratorType type) {
61 switch (type) {
62 case gpu::ImageDecodeAcceleratorType::kJpeg:
63 return "JPEG";
Gil Dekele2f8e2522019-07-23 21:17:3564 case gpu::ImageDecodeAcceleratorType::kWebP:
65 return "WebP";
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:3366 case gpu::ImageDecodeAcceleratorType::kUnknown:
67 return "Unknown";
68 }
Gil Dekele2f8e2522019-07-23 21:17:3569 NOTREACHED() << "Invalid ImageDecodeAcceleratorType.";
70 return "";
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:3371}
72
73const char* ImageDecodeAcceleratorSubsamplingToString(
74 gpu::ImageDecodeAcceleratorSubsampling subsampling) {
75 switch (subsampling) {
76 case gpu::ImageDecodeAcceleratorSubsampling::k420:
77 return "4:2:0";
78 case gpu::ImageDecodeAcceleratorSubsampling::k422:
79 return "4:2:2";
Andres Calderon Jaramillo4fdf6c42019-03-21 15:45:0680 case gpu::ImageDecodeAcceleratorSubsampling::k444:
81 return "4:4:4";
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:3382 }
83}
84
85void EnumerateImageDecodeAcceleratorSupportedProfile(
86 const gpu::ImageDecodeAcceleratorSupportedProfile& profile,
87 gpu::GPUInfo::Enumerator* enumerator) {
88 enumerator->BeginImageDecodeAcceleratorSupportedProfile();
89 enumerator->AddString("imageType",
90 ImageDecodeAcceleratorTypeToString(profile.image_type));
91 enumerator->AddString("minEncodedDimensions",
92 profile.min_encoded_dimensions.ToString());
93 enumerator->AddString("maxEncodedDimensions",
94 profile.max_encoded_dimensions.ToString());
95 std::string subsamplings;
96 for (size_t i = 0; i < profile.subsamplings.size(); i++) {
97 if (i > 0)
98 subsamplings += ", ";
99 subsamplings +=
100 ImageDecodeAcceleratorSubsamplingToString(profile.subsamplings[i]);
101 }
102 enumerator->AddString("subsamplings", subsamplings);
103 enumerator->EndImageDecodeAcceleratorSupportedProfile();
104}
105
Sunny Sachanandanifc66e9a2018-07-10 18:08:29106#if defined(OS_WIN)
Zhenyao Moda88bdc2018-09-27 01:47:33107void EnumerateDx12VulkanVersionInfo(const gpu::Dx12VulkanVersionInfo& info,
108 gpu::GPUInfo::Enumerator* enumerator) {
109 enumerator->BeginDx12VulkanVersionInfo();
110 enumerator->AddBool("supportsDx12", info.supports_dx12);
111 enumerator->AddBool("supportsVulkan", info.supports_vulkan);
Zhenyao Mo964f6832019-09-17 01:41:09112 enumerator->AddString("dx12FeatureLevel",
113 gpu::D3DFeatureLevelToString(info.d3d12_feature_level));
114 enumerator->AddString("vulkanVersion",
115 gpu::VulkanVersionToString(info.vulkan_version));
Zhenyao Moda88bdc2018-09-27 01:47:33116 enumerator->EndDx12VulkanVersionInfo();
117}
Sunny Sachanandanifc66e9a2018-07-10 18:08:29118#endif
119
[email protected]fd4dcc52013-08-15 11:37:43120} // namespace
121
[email protected]d7b5cc72013-05-23 20:05:00122namespace gpu {
[email protected]a80f5ece2011-10-20 23:56:55123
Sunny Sachanandani3dcb5da2018-10-18 04:59:43124#if defined(OS_WIN)
Zhenyao Mo4178e192019-05-16 21:46:11125const char* OverlaySupportToString(gpu::OverlaySupport support) {
126 switch (support) {
127 case gpu::OverlaySupport::kNone:
128 return "NONE";
129 case gpu::OverlaySupport::kDirect:
130 return "DIRECT";
131 case gpu::OverlaySupport::kScaling:
132 return "SCALING";
Sunny Sachanandanifc66e9a2018-07-10 18:08:29133 }
Sunny Sachanandanifc66e9a2018-07-10 18:08:29134}
Zhenyao Mo4178e192019-05-16 21:46:11135#endif // OS_WIN
Sunny Sachanandanifc66e9a2018-07-10 18:08:29136
liberato575877902015-12-10 17:16:26137VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities()
138 : flags(0) {}
139
vmpstr3b7b8b22016-03-01 23:00:20140VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities(
141 const VideoDecodeAcceleratorCapabilities& other) = default;
142
Chris Watkins81030772017-12-07 01:20:56143VideoDecodeAcceleratorCapabilities::~VideoDecodeAcceleratorCapabilities() =
144 default;
liberato575877902015-12-10 17:16:26145
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:33146ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile()
147 : image_type(ImageDecodeAcceleratorType::kUnknown) {}
148
149ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile(
150 const ImageDecodeAcceleratorSupportedProfile& other) = default;
151
152ImageDecodeAcceleratorSupportedProfile::ImageDecodeAcceleratorSupportedProfile(
153 ImageDecodeAcceleratorSupportedProfile&& other) = default;
154
155ImageDecodeAcceleratorSupportedProfile::
156 ~ImageDecodeAcceleratorSupportedProfile() = default;
157
158ImageDecodeAcceleratorSupportedProfile& ImageDecodeAcceleratorSupportedProfile::
159operator=(const ImageDecodeAcceleratorSupportedProfile& other) = default;
160
161ImageDecodeAcceleratorSupportedProfile& ImageDecodeAcceleratorSupportedProfile::
162operator=(ImageDecodeAcceleratorSupportedProfile&& other) = default;
163
Zhenyao Mo1d8d106a2019-09-26 19:32:41164GPUInfo::GPUDevice::GPUDevice() = default;
[email protected]a094e2c2012-05-10 23:02:42165
Zhenyao Mofbea81d2018-06-01 17:29:27166GPUInfo::GPUDevice::GPUDevice(const GPUInfo::GPUDevice& other) = default;
167
168GPUInfo::GPUDevice::GPUDevice(GPUInfo::GPUDevice&& other) noexcept = default;
169
170GPUInfo::GPUDevice::~GPUDevice() noexcept = default;
171
172GPUInfo::GPUDevice& GPUInfo::GPUDevice::operator=(
173 const GPUInfo::GPUDevice& other) = default;
174
175GPUInfo::GPUDevice& GPUInfo::GPUDevice::operator=(
176 GPUInfo::GPUDevice&& other) noexcept = default;
[email protected]a094e2c2012-05-10 23:02:42177
[email protected]a80f5ece2011-10-20 23:56:55178GPUInfo::GPUInfo()
zmo84eae5e2014-09-05 01:36:23179 : optimus(false),
[email protected]c32b0c2c2012-04-07 01:34:33180 amd_switchable(false),
[email protected]6c7784e2013-08-01 22:41:28181 gl_reset_notification_strategy(0),
[email protected]fad3ccf2012-09-11 22:36:00182 software_rendering(false),
[email protected]47752982014-07-29 08:01:43183 sandboxed(false),
bajonese3677b649ff2015-07-25 00:41:56184 in_process_gpu(true),
geofflang774e87a2016-12-05 16:29:01185 passthrough_cmd_decoder(false),
Jonathan Backera57031b2018-06-04 15:44:32186 jpeg_decode_accelerator_supported(false),
Antonio Gomes5b4d98e2017-08-24 05:53:07187#if defined(USE_X11)
thomasanderson62ba78ff2016-10-01 02:03:42188 system_visual(0),
Jonathan Backera57031b2018-06-04 15:44:32189 rgba_visual(0),
thomasanderson62ba78ff2016-10-01 02:03:42190#endif
Mitsuru Oshima345e9b52019-10-19 00:07:36191 oop_rasterization_supported(false),
192 subpixel_font_rendering(true) {
[email protected]a80f5ece2011-10-20 23:56:55193}
194
vmpstr3b7b8b22016-03-01 23:00:20195GPUInfo::GPUInfo(const GPUInfo& other) = default;
196
Chris Watkins81030772017-12-07 01:20:56197GPUInfo::~GPUInfo() = default;
[email protected]a80f5ece2011-10-20 23:56:55198
Zhenyao Mofbea81d2018-06-01 17:29:27199GPUInfo::GPUDevice& GPUInfo::active_gpu() {
200 return const_cast<GPUInfo::GPUDevice&>(
201 const_cast<const GPUInfo&>(*this).active_gpu());
202}
203
ccameron8c3b0dd132017-05-16 19:30:50204const GPUInfo::GPUDevice& GPUInfo::active_gpu() const {
Zhenyao Moc4f79c32018-01-27 02:44:13205 if (gpu.active || secondary_gpus.empty())
ccameron8c3b0dd132017-05-16 19:30:50206 return gpu;
Zhenyao Mofbea81d2018-06-01 17:29:27207 for (const auto& secondary_gpu : secondary_gpus) {
ccameron8c3b0dd132017-05-16 19:30:50208 if (secondary_gpu.active)
209 return secondary_gpu;
210 }
Zhenyao Mofbea81d2018-06-01 17:29:27211 DVLOG(2) << "No active GPU found, returning primary GPU.";
ccameron8c3b0dd132017-05-16 19:30:50212 return gpu;
213}
214
Zhenyao Mo68ef56d2018-04-21 01:05:10215bool GPUInfo::IsInitialized() const {
216 return gpu.vendor_id != 0 || !gl_vendor.empty();
217}
218
[email protected]fd4dcc52013-08-15 11:37:43219void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
220 struct GPUInfoKnownFields {
[email protected]fd4dcc52013-08-15 11:37:43221 base::TimeDelta initialization_time;
222 bool optimus;
223 bool amd_switchable;
[email protected]fd4dcc52013-08-15 11:37:43224 GPUDevice gpu;
225 std::vector<GPUDevice> secondary_gpus;
[email protected]fd4dcc52013-08-15 11:37:43226 std::string pixel_shader_version;
227 std::string vertex_shader_version;
senorblancob7a64d572015-04-08 16:59:02228 std::string max_msaa_samples;
[email protected]2ac8e51c2014-04-21 20:54:13229 std::string machine_model_name;
230 std::string machine_model_version;
[email protected]fd4dcc52013-08-15 11:37:43231 std::string gl_version_string;
232 std::string gl_vendor;
233 std::string gl_renderer;
234 std::string gl_extensions;
235 std::string gl_ws_vendor;
236 std::string gl_ws_version;
237 std::string gl_ws_extensions;
avif15d60a2015-12-21 17:06:33238 uint32_t gl_reset_notification_strategy;
[email protected]fd4dcc52013-08-15 11:37:43239 bool software_rendering;
Jonathan Backer01293832019-03-20 20:27:10240 std::string direct_rendering_version;
[email protected]fd4dcc52013-08-15 11:37:43241 bool sandboxed;
bajonese3677b649ff2015-07-25 00:41:56242 bool in_process_gpu;
geofflang774e87a2016-12-05 16:29:01243 bool passthrough_cmd_decoder;
Bo Liu9cad099c2017-07-06 14:45:27244 bool can_support_threaded_texture_mailbox;
[email protected]fd4dcc52013-08-15 11:37:43245#if defined(OS_WIN)
Sunny Sachanandani6e844c42018-11-09 20:27:12246 bool direct_composition;
247 bool supports_overlays;
Zhenyao Mo4178e192019-05-16 21:46:11248 OverlaySupport yuy2_overlay_support;
249 OverlaySupport nv12_overlay_support;
[email protected]fd4dcc52013-08-15 11:37:43250 DxDiagNode dx_diagnostics;
Zhenyao Moda88bdc2018-09-27 01:47:33251 Dx12VulkanVersionInfo dx12_vulkan_version_info;
[email protected]fd4dcc52013-08-15 11:37:43252#endif
Maggie Chen35d65e4a2018-04-12 21:15:25253
liberato575877902015-12-10 17:16:26254 VideoDecodeAcceleratorCapabilities video_decode_accelerator_capabilities;
henryhsud1185442015-04-10 06:39:14255 VideoEncodeAcceleratorSupportedProfiles
wuchengli79808322014-09-23 05:58:14256 video_encode_accelerator_supported_profiles;
henryhsu74f6ef12015-07-23 08:34:37257 bool jpeg_decode_accelerator_supported;
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:33258
259 ImageDecodeAcceleratorSupportedProfiles
260 image_decode_accelerator_supported_profiles;
261
Antonio Gomes5b4d98e2017-08-24 05:53:07262#if defined(USE_X11)
thomasanderson62ba78ff2016-10-01 02:03:42263 VisualID system_visual;
264 VisualID rgba_visual;
265#endif
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:33266
Jonathan Backera57031b2018-06-04 15:44:32267 bool oop_rasterization_supported;
Mitsuru Oshima345e9b52019-10-19 00:07:36268 bool subpixel_font_rendering;
[email protected]fd4dcc52013-08-15 11:37:43269 };
270
271 // If this assert fails then most likely something below needs to be updated.
272 // Note that this assert is only approximate. If a new field is added to
273 // GPUInfo which fits within the current padding then it will not be caught.
mostynb7f032092014-12-20 00:36:44274 static_assert(
[email protected]fd4dcc52013-08-15 11:37:43275 sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
mostynb7f032092014-12-20 00:36:44276 "fields have changed in GPUInfo, GPUInfoKnownFields must be updated");
[email protected]fd4dcc52013-08-15 11:37:43277
278 // Required fields (according to DevTools protocol) first.
[email protected]2ac8e51c2014-04-21 20:54:13279 enumerator->AddString("machineModelName", machine_model_name);
280 enumerator->AddString("machineModelVersion", machine_model_version);
henryhsud1185442015-04-10 06:39:14281 EnumerateGPUDevice(gpu, enumerator);
Jonathan Backera57031b2018-06-04 15:44:32282 for (const auto& secondary_gpu : secondary_gpus)
henryhsud1185442015-04-10 06:39:14283 EnumerateGPUDevice(secondary_gpu, enumerator);
[email protected]fd4dcc52013-08-15 11:37:43284
285 enumerator->BeginAuxAttributes();
Miguel Casas28ee90f2019-05-28 19:12:26286 enumerator->AddTimeDeltaInSecondsF("initializationTime", initialization_time);
[email protected]fd4dcc52013-08-15 11:37:43287 enumerator->AddBool("optimus", optimus);
288 enumerator->AddBool("amdSwitchable", amd_switchable);
[email protected]fd4dcc52013-08-15 11:37:43289 enumerator->AddString("pixelShaderVersion", pixel_shader_version);
290 enumerator->AddString("vertexShaderVersion", vertex_shader_version);
senorblancob7a64d572015-04-08 16:59:02291 enumerator->AddString("maxMsaaSamples", max_msaa_samples);
[email protected]fd4dcc52013-08-15 11:37:43292 enumerator->AddString("glVersion", gl_version);
[email protected]fd4dcc52013-08-15 11:37:43293 enumerator->AddString("glVendor", gl_vendor);
294 enumerator->AddString("glRenderer", gl_renderer);
295 enumerator->AddString("glExtensions", gl_extensions);
296 enumerator->AddString("glWsVendor", gl_ws_vendor);
297 enumerator->AddString("glWsVersion", gl_ws_version);
298 enumerator->AddString("glWsExtensions", gl_ws_extensions);
299 enumerator->AddInt(
300 "glResetNotificationStrategy",
301 static_cast<int>(gl_reset_notification_strategy));
[email protected]fd4dcc52013-08-15 11:37:43302 // TODO(kbr): add performance_stats.
303 enumerator->AddBool("softwareRendering", software_rendering);
Jonathan Backer01293832019-03-20 20:27:10304 enumerator->AddString("directRenderingVersion", direct_rendering_version);
[email protected]fd4dcc52013-08-15 11:37:43305 enumerator->AddBool("sandboxed", sandboxed);
bajonese3677b649ff2015-07-25 00:41:56306 enumerator->AddBool("inProcessGpu", in_process_gpu);
geofflang774e87a2016-12-05 16:29:01307 enumerator->AddBool("passthroughCmdDecoder", passthrough_cmd_decoder);
Bo Liu9cad099c2017-07-06 14:45:27308 enumerator->AddBool("canSupportThreadedTextureMailbox",
309 can_support_threaded_texture_mailbox);
[email protected]fd4dcc52013-08-15 11:37:43310 // TODO(kbr): add dx_diagnostics on Windows.
Maggie Chen35d65e4a2018-04-12 21:15:25311#if defined(OS_WIN)
Sunny Sachanandani6e844c42018-11-09 20:27:12312 enumerator->AddBool("directComposition", direct_composition);
313 enumerator->AddBool("supportsOverlays", supports_overlays);
Zhenyao Mo4178e192019-05-16 21:46:11314 enumerator->AddString("yuy2OverlaySupport",
315 OverlaySupportToString(yuy2_overlay_support));
316 enumerator->AddString("nv12OverlaySupport",
317 OverlaySupportToString(nv12_overlay_support));
Zhenyao Moda88bdc2018-09-27 01:47:33318 EnumerateDx12VulkanVersionInfo(dx12_vulkan_version_info, enumerator);
Maggie Chen35d65e4a2018-04-12 21:15:25319#endif
liberato575877902015-12-10 17:16:26320 enumerator->AddInt("videoDecodeAcceleratorFlags",
321 video_decode_accelerator_capabilities.flags);
Miguel Casas28ee90f2019-05-28 19:12:26322
323 // TODO(crbug.com/966839): Fix the two supported profile dumping below.
liberato575877902015-12-10 17:16:26324 for (const auto& profile :
325 video_decode_accelerator_capabilities.supported_profiles)
henryhsud1185442015-04-10 06:39:14326 EnumerateVideoDecodeAcceleratorSupportedProfile(profile, enumerator);
327 for (const auto& profile : video_encode_accelerator_supported_profiles)
328 EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator);
henryhsu74f6ef12015-07-23 08:34:37329 enumerator->AddBool("jpegDecodeAcceleratorSupported",
330 jpeg_decode_accelerator_supported);
Andres Calderon Jaramilloc68cd9142019-02-16 00:43:33331 for (const auto& profile : image_decode_accelerator_supported_profiles)
332 EnumerateImageDecodeAcceleratorSupportedProfile(profile, enumerator);
Antonio Gomes5b4d98e2017-08-24 05:53:07333#if defined(USE_X11)
thomasanderson62ba78ff2016-10-01 02:03:42334 enumerator->AddInt64("systemVisual", system_visual);
335 enumerator->AddInt64("rgbaVisual", rgba_visual);
336#endif
Jonathan Backera57031b2018-06-04 15:44:32337 enumerator->AddBool("oopRasterizationSupported", oop_rasterization_supported);
Mitsuru Oshima345e9b52019-10-19 00:07:36338 enumerator->AddBool("subpixelFontRendering", subpixel_font_rendering);
Samuel Attard9cb0f77a2019-07-02 23:31:31339 enumerator->EndAuxAttributes();
[email protected]fd4dcc52013-08-15 11:37:43340}
341
[email protected]d7b5cc72013-05-23 20:05:00342} // namespace gpu