Elim cr-checkbox
[chromium-blink-merge.git] / gpu / config / gpu_info.cc
blob23d52169f127989aacef7c42bbae744f3f5c560f
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"
7 namespace {
9 void EnumerateGPUDevice(const gpu::GPUInfo::GPUDevice& device,
10 gpu::GPUInfo::Enumerator* enumerator) {
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 EnumerateVideoDecodeAcceleratorSupportedProfile(
21 const gpu::VideoDecodeAcceleratorSupportedProfile& profile,
22 gpu::GPUInfo::Enumerator* enumerator) {
23 enumerator->BeginVideoDecodeAcceleratorSupportedProfile();
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("minResolutionWidth", profile.min_resolution.width());
28 enumerator->AddInt("minResolutionHeight", profile.min_resolution.height());
29 enumerator->EndVideoDecodeAcceleratorSupportedProfile();
32 void EnumerateVideoEncodeAcceleratorSupportedProfile(
33 const gpu::VideoEncodeAcceleratorSupportedProfile& profile,
34 gpu::GPUInfo::Enumerator* enumerator) {
35 enumerator->BeginVideoEncodeAcceleratorSupportedProfile();
36 enumerator->AddInt("profile", profile.profile);
37 enumerator->AddInt("maxResolutionWidth", profile.max_resolution.width());
38 enumerator->AddInt("maxResolutionHeight", profile.max_resolution.height());
39 enumerator->AddInt("maxFramerateNumerator", profile.max_framerate_numerator);
40 enumerator->AddInt("maxFramerateDenominator",
41 profile.max_framerate_denominator);
42 enumerator->EndVideoEncodeAcceleratorSupportedProfile();
45 } // namespace
47 namespace gpu {
49 GPUInfo::GPUDevice::GPUDevice()
50 : vendor_id(0),
51 device_id(0),
52 active(false) {
55 GPUInfo::GPUDevice::~GPUDevice() { }
57 GPUInfo::GPUInfo()
58 : optimus(false),
59 amd_switchable(false),
60 lenovo_dcute(false),
61 adapter_luid(0),
62 gl_reset_notification_strategy(0),
63 can_lose_context(false),
64 software_rendering(false),
65 direct_rendering(true),
66 sandboxed(false),
67 process_crash_count(0),
68 in_process_gpu(true),
69 basic_info_state(kCollectInfoNone),
70 context_info_state(kCollectInfoNone),
71 #if defined(OS_WIN)
72 dx_diagnostics_info_state(kCollectInfoNone),
73 #endif
74 jpeg_decode_accelerator_supported(false) {
77 GPUInfo::~GPUInfo() { }
79 void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
80 struct GPUInfoKnownFields {
81 base::TimeDelta initialization_time;
82 bool optimus;
83 bool amd_switchable;
84 bool lenovo_dcute;
85 Version display_link_version;
86 GPUDevice gpu;
87 std::vector<GPUDevice> secondary_gpus;
88 uint64 adapter_luid;
89 std::string driver_vendor;
90 std::string driver_version;
91 std::string driver_date;
92 std::string pixel_shader_version;
93 std::string vertex_shader_version;
94 std::string max_msaa_samples;
95 std::string machine_model_name;
96 std::string machine_model_version;
97 std::string gl_version_string;
98 std::string gl_vendor;
99 std::string gl_renderer;
100 std::string gl_extensions;
101 std::string gl_ws_vendor;
102 std::string gl_ws_version;
103 std::string gl_ws_extensions;
104 uint32 gl_reset_notification_strategy;
105 bool can_lose_context;
106 bool software_rendering;
107 bool direct_rendering;
108 bool sandboxed;
109 int process_crash_count;
110 bool in_process_gpu;
111 CollectInfoResult basic_info_state;
112 CollectInfoResult context_info_state;
113 #if defined(OS_WIN)
114 CollectInfoResult dx_diagnostics_info_state;
115 DxDiagNode dx_diagnostics;
116 #endif
117 VideoDecodeAcceleratorSupportedProfiles
118 video_decode_accelerator_supported_profiles;
119 VideoEncodeAcceleratorSupportedProfiles
120 video_encode_accelerator_supported_profiles;
121 bool jpeg_decode_accelerator_supported;
124 // If this assert fails then most likely something below needs to be updated.
125 // Note that this assert is only approximate. If a new field is added to
126 // GPUInfo which fits within the current padding then it will not be caught.
127 static_assert(
128 sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
129 "fields have changed in GPUInfo, GPUInfoKnownFields must be updated");
131 // Required fields (according to DevTools protocol) first.
132 enumerator->AddString("machineModelName", machine_model_name);
133 enumerator->AddString("machineModelVersion", machine_model_version);
134 EnumerateGPUDevice(gpu, enumerator);
135 for (const auto& secondary_gpu: secondary_gpus)
136 EnumerateGPUDevice(secondary_gpu, enumerator);
138 enumerator->BeginAuxAttributes();
139 enumerator->AddTimeDeltaInSecondsF("initializationTime",
140 initialization_time);
141 enumerator->AddBool("optimus", optimus);
142 enumerator->AddBool("amdSwitchable", amd_switchable);
143 enumerator->AddBool("lenovoDcute", lenovo_dcute);
144 if (display_link_version.IsValid()) {
145 enumerator->AddString("displayLinkVersion",
146 display_link_version.GetString());
148 enumerator->AddInt64("adapterLuid", adapter_luid);
149 enumerator->AddString("driverVendor", driver_vendor);
150 enumerator->AddString("driverVersion", driver_version);
151 enumerator->AddString("driverDate", driver_date);
152 enumerator->AddString("pixelShaderVersion", pixel_shader_version);
153 enumerator->AddString("vertexShaderVersion", vertex_shader_version);
154 enumerator->AddString("maxMsaaSamples", max_msaa_samples);
155 enumerator->AddString("glVersion", gl_version);
156 enumerator->AddString("glVendor", gl_vendor);
157 enumerator->AddString("glRenderer", gl_renderer);
158 enumerator->AddString("glExtensions", gl_extensions);
159 enumerator->AddString("glWsVendor", gl_ws_vendor);
160 enumerator->AddString("glWsVersion", gl_ws_version);
161 enumerator->AddString("glWsExtensions", gl_ws_extensions);
162 enumerator->AddInt(
163 "glResetNotificationStrategy",
164 static_cast<int>(gl_reset_notification_strategy));
165 enumerator->AddBool("can_lose_context", can_lose_context);
166 // TODO(kbr): add performance_stats.
167 enumerator->AddBool("softwareRendering", software_rendering);
168 enumerator->AddBool("directRendering", direct_rendering);
169 enumerator->AddBool("sandboxed", sandboxed);
170 enumerator->AddInt("processCrashCount", process_crash_count);
171 enumerator->AddBool("inProcessGpu", in_process_gpu);
172 enumerator->AddInt("basicInfoState", basic_info_state);
173 enumerator->AddInt("contextInfoState", context_info_state);
174 #if defined(OS_WIN)
175 enumerator->AddInt("DxDiagnosticsInfoState", dx_diagnostics_info_state);
176 #endif
177 // TODO(kbr): add dx_diagnostics on Windows.
178 for (const auto& profile : video_decode_accelerator_supported_profiles)
179 EnumerateVideoDecodeAcceleratorSupportedProfile(profile, enumerator);
180 for (const auto& profile : video_encode_accelerator_supported_profiles)
181 EnumerateVideoEncodeAcceleratorSupportedProfile(profile, enumerator);
182 enumerator->AddBool("jpegDecodeAcceleratorSupported",
183 jpeg_decode_accelerator_supported);
184 enumerator->EndAuxAttributes();
187 } // namespace gpu