James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 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. |
| 4 | |
| 5 | #include "gpu/config/gpu_info.h" |
| 6 | |
| 7 | namespace { |
| 8 | |
| 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(); |
| 18 | } |
| 19 | |
James Robinson | 6165015 | 2014-10-26 23:24:55 -0700 | [diff] [blame] | 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(); |
| 31 | } |
| 32 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 33 | } // namespace |
| 34 | |
| 35 | namespace gpu { |
| 36 | |
| 37 | GPUInfo::GPUDevice::GPUDevice() |
| 38 | : vendor_id(0), |
| 39 | device_id(0), |
| 40 | active(false) { |
| 41 | } |
| 42 | |
| 43 | GPUInfo::GPUDevice::~GPUDevice() { } |
| 44 | |
| 45 | GPUInfo::GPUInfo() |
| 46 | : optimus(false), |
| 47 | amd_switchable(false), |
| 48 | lenovo_dcute(false), |
| 49 | adapter_luid(0), |
| 50 | gl_reset_notification_strategy(0), |
| 51 | can_lose_context(false), |
| 52 | software_rendering(false), |
| 53 | direct_rendering(true), |
| 54 | sandboxed(false), |
| 55 | process_crash_count(0), |
| 56 | basic_info_state(kCollectInfoNone), |
| 57 | #if defined(OS_WIN) |
| 58 | context_info_state(kCollectInfoNone), |
| 59 | dx_diagnostics_info_state(kCollectInfoNone) { |
| 60 | #else |
| 61 | context_info_state(kCollectInfoNone) { |
| 62 | #endif |
| 63 | } |
| 64 | |
| 65 | GPUInfo::~GPUInfo() { } |
| 66 | |
| 67 | void GPUInfo::EnumerateFields(Enumerator* enumerator) const { |
| 68 | struct GPUInfoKnownFields { |
| 69 | base::TimeDelta initialization_time; |
| 70 | bool optimus; |
| 71 | bool amd_switchable; |
| 72 | bool lenovo_dcute; |
| 73 | Version display_link_version; |
| 74 | GPUDevice gpu; |
| 75 | std::vector<GPUDevice> secondary_gpus; |
| 76 | uint64 adapter_luid; |
| 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; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 93 | bool software_rendering; |
| 94 | bool direct_rendering; |
| 95 | bool sandboxed; |
| 96 | int process_crash_count; |
| 97 | CollectInfoResult basic_info_state; |
| 98 | CollectInfoResult context_info_state; |
| 99 | #if defined(OS_WIN) |
| 100 | CollectInfoResult dx_diagnostics_info_state; |
| 101 | DxDiagNode dx_diagnostics; |
| 102 | #endif |
James Robinson | 6165015 | 2014-10-26 23:24:55 -0700 | [diff] [blame] | 103 | std::vector<VideoEncodeAcceleratorSupportedProfile> |
| 104 | video_encode_accelerator_supported_profiles; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 105 | }; |
| 106 | |
| 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. |
Benjamin Lerman | 0461682 | 2014-12-22 13:08:16 +0100 | [diff] [blame] | 110 | static_assert( |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 111 | sizeof(GPUInfo) == sizeof(GPUInfoKnownFields), |
Benjamin Lerman | 0461682 | 2014-12-22 13:08:16 +0100 | [diff] [blame] | 112 | "fields have changed in GPUInfo, GPUInfoKnownFields must be updated"); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 113 | |
| 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]); |
| 120 | } |
| 121 | |
| 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()); |
| 131 | } |
| 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); |
| 145 | enumerator->AddInt( |
| 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); |
| 156 | #if defined(OS_WIN) |
| 157 | enumerator->AddInt("DxDiagnosticsInfoState", dx_diagnostics_info_state); |
| 158 | #endif |
James Robinson | 6165015 | 2014-10-26 23:24:55 -0700 | [diff] [blame] | 159 | // TODO(kbr): add dx_diagnostics on Windows. |
| 160 | for (size_t ii = 0; ii < video_encode_accelerator_supported_profiles.size(); |
| 161 | ++ii) { |
| 162 | EnumerateVideoEncodeAcceleratorSupportedProfile( |
| 163 | enumerator, video_encode_accelerator_supported_profiles[ii]); |
| 164 | } |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 165 | enumerator->EndAuxAttributes(); |
| 166 | } |
| 167 | |
| 168 | } // namespace gpu |