[email protected] | 84ad3a7 | 2012-02-07 00:29:45 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | a80f5ece | 2011-10-20 23:56:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
avi | f15d60a | 2015-12-21 17:06:33 | [diff] [blame] | 5 | #include <stdint.h> |
| 6 | |
[email protected] | d7b5cc7 | 2013-05-23 20:05:00 | [diff] [blame] | 7 | #include "gpu/config/gpu_info.h" |
[email protected] | a80f5ece | 2011-10-20 23:56:55 | [diff] [blame] | 8 | |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 9 | namespace { |
| 10 | |
henryhsu | d118544 | 2015-04-10 06:39:14 | [diff] [blame] | 11 | void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device, |
| 12 | gpu::GPUInfo::Enumerator* enumerator) { |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 13 | enumerator->BeginGPUDevice(); |
| 14 | enumerator->AddInt("vendorId", device.vendor_id); |
| 15 | enumerator->AddInt("deviceId", device.device_id); |
[email protected] | 20e7cfc | 2014-04-02 17:33:13 | [diff] [blame] | 16 | enumerator->AddBool("active", device.active); |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 17 | enumerator->AddString("vendorString", device.vendor_string); |
| 18 | enumerator->AddString("deviceString", device.device_string); |
| 19 | enumerator->EndGPUDevice(); |
| 20 | } |
| 21 | |
henryhsu | d118544 | 2015-04-10 06:39:14 | [diff] [blame] | 22 | void 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()); |
dalecurtis | 4708098a | 2016-03-19 04:54:11 | [diff] [blame] | 31 | enumerator->AddBool("encrypted_only", profile.encrypted_only); |
henryhsu | d118544 | 2015-04-10 06:39:14 | [diff] [blame] | 32 | enumerator->EndVideoDecodeAcceleratorSupportedProfile(); |
| 33 | } |
| 34 | |
wuchengli | 7980832 | 2014-09-23 05:58:14 | [diff] [blame] | 35 | void EnumerateVideoEncodeAcceleratorSupportedProfile( |
henryhsu | d118544 | 2015-04-10 06:39:14 | [diff] [blame] | 36 | const gpu::VideoEncodeAcceleratorSupportedProfile& profile, |
| 37 | gpu::GPUInfo::Enumerator* enumerator) { |
wuchengli | 7980832 | 2014-09-23 05:58:14 | [diff] [blame] | 38 | 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] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 48 | } // namespace |
| 49 | |
[email protected] | d7b5cc7 | 2013-05-23 20:05:00 | [diff] [blame] | 50 | namespace gpu { |
[email protected] | a80f5ece | 2011-10-20 23:56:55 | [diff] [blame] | 51 | |
liberato | 57587790 | 2015-12-10 17:16:26 | [diff] [blame] | 52 | VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities() |
| 53 | : flags(0) {} |
| 54 | |
vmpstr | 3b7b8b2 | 2016-03-01 23:00:20 | [diff] [blame] | 55 | VideoDecodeAcceleratorCapabilities::VideoDecodeAcceleratorCapabilities( |
| 56 | const VideoDecodeAcceleratorCapabilities& other) = default; |
| 57 | |
liberato | 57587790 | 2015-12-10 17:16:26 | [diff] [blame] | 58 | VideoDecodeAcceleratorCapabilities::~VideoDecodeAcceleratorCapabilities() {} |
| 59 | |
[email protected] | a094e2c | 2012-05-10 23:02:42 | [diff] [blame] | 60 | GPUInfo::GPUDevice::GPUDevice() |
| 61 | : vendor_id(0), |
[email protected] | 20e7cfc | 2014-04-02 17:33:13 | [diff] [blame] | 62 | device_id(0), |
| 63 | active(false) { |
[email protected] | a094e2c | 2012-05-10 23:02:42 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | GPUInfo::GPUDevice::~GPUDevice() { } |
| 67 | |
[email protected] | a80f5ece | 2011-10-20 23:56:55 | [diff] [blame] | 68 | GPUInfo::GPUInfo() |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 69 | : optimus(false), |
[email protected] | c32b0c2c | 2012-04-07 01:34:33 | [diff] [blame] | 70 | amd_switchable(false), |
[email protected] | 68852bd | 2013-03-12 03:47:08 | [diff] [blame] | 71 | lenovo_dcute(false), |
[email protected] | fd00eee5 | 2013-05-24 22:32:28 | [diff] [blame] | 72 | adapter_luid(0), |
[email protected] | 6c7784e | 2013-08-01 22:41:28 | [diff] [blame] | 73 | gl_reset_notification_strategy(0), |
[email protected] | fad3ccf | 2012-09-11 22:36:00 | [diff] [blame] | 74 | software_rendering(false), |
[email protected] | 0e8cac7 | 2014-03-22 00:37:18 | [diff] [blame] | 75 | direct_rendering(true), |
[email protected] | 4775298 | 2014-07-29 08:01:43 | [diff] [blame] | 76 | sandboxed(false), |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 77 | process_crash_count(0), |
bajones | e3677b649ff | 2015-07-25 00:41:56 | [diff] [blame] | 78 | in_process_gpu(true), |
geofflang | 774e87a | 2016-12-05 16:29:01 | [diff] [blame^] | 79 | passthrough_cmd_decoder(false), |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 80 | basic_info_state(kCollectInfoNone), |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 81 | context_info_state(kCollectInfoNone), |
henryhsu | 74f6ef1 | 2015-07-23 08:34:37 | [diff] [blame] | 82 | #if defined(OS_WIN) |
| 83 | dx_diagnostics_info_state(kCollectInfoNone), |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 84 | #endif |
thomasanderson | 62ba78ff | 2016-10-01 02:03:42 | [diff] [blame] | 85 | 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] | a80f5ece | 2011-10-20 23:56:55 | [diff] [blame] | 92 | } |
| 93 | |
vmpstr | 3b7b8b2 | 2016-03-01 23:00:20 | [diff] [blame] | 94 | GPUInfo::GPUInfo(const GPUInfo& other) = default; |
| 95 | |
[email protected] | a80f5ece | 2011-10-20 23:56:55 | [diff] [blame] | 96 | GPUInfo::~GPUInfo() { } |
| 97 | |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 98 | void GPUInfo::EnumerateFields(Enumerator* enumerator) const { |
| 99 | struct GPUInfoKnownFields { |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 100 | base::TimeDelta initialization_time; |
| 101 | bool optimus; |
| 102 | bool amd_switchable; |
| 103 | bool lenovo_dcute; |
pwnall | 9484f3a0 | 2016-08-20 00:34:38 | [diff] [blame] | 104 | base::Version display_link_version; |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 105 | GPUDevice gpu; |
| 106 | std::vector<GPUDevice> secondary_gpus; |
avi | f15d60a | 2015-12-21 17:06:33 | [diff] [blame] | 107 | uint64_t adapter_luid; |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 108 | 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; |
senorblanco | b7a64d57 | 2015-04-08 16:59:02 | [diff] [blame] | 113 | std::string max_msaa_samples; |
[email protected] | 2ac8e51c | 2014-04-21 20:54:13 | [diff] [blame] | 114 | std::string machine_model_name; |
| 115 | std::string machine_model_version; |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 116 | 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; |
avi | f15d60a | 2015-12-21 17:06:33 | [diff] [blame] | 123 | uint32_t gl_reset_notification_strategy; |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 124 | bool software_rendering; |
[email protected] | 0e8cac7 | 2014-03-22 00:37:18 | [diff] [blame] | 125 | bool direct_rendering; |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 126 | bool sandboxed; |
[email protected] | 4775298 | 2014-07-29 08:01:43 | [diff] [blame] | 127 | int process_crash_count; |
bajones | e3677b649ff | 2015-07-25 00:41:56 | [diff] [blame] | 128 | bool in_process_gpu; |
geofflang | 774e87a | 2016-12-05 16:29:01 | [diff] [blame^] | 129 | bool passthrough_cmd_decoder; |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 130 | CollectInfoResult basic_info_state; |
| 131 | CollectInfoResult context_info_state; |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 132 | #if defined(OS_WIN) |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 133 | CollectInfoResult dx_diagnostics_info_state; |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 134 | DxDiagNode dx_diagnostics; |
| 135 | #endif |
liberato | 57587790 | 2015-12-10 17:16:26 | [diff] [blame] | 136 | VideoDecodeAcceleratorCapabilities video_decode_accelerator_capabilities; |
henryhsu | d118544 | 2015-04-10 06:39:14 | [diff] [blame] | 137 | VideoEncodeAcceleratorSupportedProfiles |
wuchengli | 7980832 | 2014-09-23 05:58:14 | [diff] [blame] | 138 | video_encode_accelerator_supported_profiles; |
henryhsu | 74f6ef1 | 2015-07-23 08:34:37 | [diff] [blame] | 139 | bool jpeg_decode_accelerator_supported; |
thomasanderson | 62ba78ff | 2016-10-01 02:03:42 | [diff] [blame] | 140 | #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 141 | VisualID system_visual; |
| 142 | VisualID rgba_visual; |
| 143 | #endif |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 144 | }; |
| 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. |
mostynb | 7f03209 | 2014-12-20 00:36:44 | [diff] [blame] | 149 | static_assert( |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 150 | sizeof(GPUInfo) == sizeof(GPUInfoKnownFields), |
mostynb | 7f03209 | 2014-12-20 00:36:44 | [diff] [blame] | 151 | "fields have changed in GPUInfo, GPUInfoKnownFields must be updated"); |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 152 | |
| 153 | // Required fields (according to DevTools protocol) first. |
[email protected] | 2ac8e51c | 2014-04-21 20:54:13 | [diff] [blame] | 154 | enumerator->AddString("machineModelName", machine_model_name); |
| 155 | enumerator->AddString("machineModelVersion", machine_model_version); |
henryhsu | d118544 | 2015-04-10 06:39:14 | [diff] [blame] | 156 | EnumerateGPUDevice(gpu, enumerator); |
| 157 | for (const auto& secondary_gpu: secondary_gpus) |
| 158 | EnumerateGPUDevice(secondary_gpu, enumerator); |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 159 | |
| 160 | enumerator->BeginAuxAttributes(); |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 161 | 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); |
senorblanco | b7a64d57 | 2015-04-08 16:59:02 | [diff] [blame] | 176 | enumerator->AddString("maxMsaaSamples", max_msaa_samples); |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 177 | enumerator->AddString("glVersion", gl_version); |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 178 | 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] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 187 | // TODO(kbr): add performance_stats. |
| 188 | enumerator->AddBool("softwareRendering", software_rendering); |
[email protected] | 0e8cac7 | 2014-03-22 00:37:18 | [diff] [blame] | 189 | enumerator->AddBool("directRendering", direct_rendering); |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 190 | enumerator->AddBool("sandboxed", sandboxed); |
[email protected] | 4775298 | 2014-07-29 08:01:43 | [diff] [blame] | 191 | enumerator->AddInt("processCrashCount", process_crash_count); |
bajones | e3677b649ff | 2015-07-25 00:41:56 | [diff] [blame] | 192 | enumerator->AddBool("inProcessGpu", in_process_gpu); |
geofflang | 774e87a | 2016-12-05 16:29:01 | [diff] [blame^] | 193 | enumerator->AddBool("passthroughCmdDecoder", passthrough_cmd_decoder); |
zmo | 84eae5e | 2014-09-05 01:36:23 | [diff] [blame] | 194 | 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] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 199 | // TODO(kbr): add dx_diagnostics on Windows. |
liberato | 57587790 | 2015-12-10 17:16:26 | [diff] [blame] | 200 | enumerator->AddInt("videoDecodeAcceleratorFlags", |
| 201 | video_decode_accelerator_capabilities.flags); |
| 202 | for (const auto& profile : |
| 203 | video_decode_accelerator_capabilities.supported_profiles) |
henryhsu | d118544 | 2015-04-10 06:39:14 | [diff] [blame] | 204 | EnumerateVideoDecodeAcceleratorSupportedProfile(profile, enumerator); |
| 205 | for (const auto& profile : video_encode_accelerator_supported_profiles) |
| 206 | EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator); |
henryhsu | 74f6ef1 | 2015-07-23 08:34:37 | [diff] [blame] | 207 | enumerator->AddBool("jpegDecodeAcceleratorSupported", |
| 208 | jpeg_decode_accelerator_supported); |
thomasanderson | 62ba78ff | 2016-10-01 02:03:42 | [diff] [blame] | 209 | #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 210 | enumerator->AddInt64("systemVisual", system_visual); |
| 211 | enumerator->AddInt64("rgbaVisual", rgba_visual); |
| 212 | #endif |
[email protected] | fd4dcc5 | 2013-08-15 11:37:43 | [diff] [blame] | 213 | enumerator->EndAuxAttributes(); |
| 214 | } |
| 215 | |
[email protected] | d7b5cc7 | 2013-05-23 20:05:00 | [diff] [blame] | 216 | } // namespace gpu |