Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / gpu / config / gpu_info.cc
blobfd3d8a3fe573f7b5198bab5ddd884d1581c5d5a1
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(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();
20 } // namespace
22 namespace gpu {
24 GPUInfo::GPUDevice::GPUDevice()
25 : vendor_id(0),
26 device_id(0),
27 active(false) {
30 GPUInfo::GPUDevice::~GPUDevice() { }
32 GPUInfo::GPUInfo()
33 : finalized(false),
34 optimus(false),
35 amd_switchable(false),
36 lenovo_dcute(false),
37 adapter_luid(0),
38 gl_reset_notification_strategy(0),
39 can_lose_context(false),
40 software_rendering(false),
41 direct_rendering(true),
42 sandboxed(false),
43 process_crash_count(0) {
46 GPUInfo::~GPUInfo() { }
48 void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
49 struct GPUInfoKnownFields {
50 bool finalized;
51 base::TimeDelta initialization_time;
52 bool optimus;
53 bool amd_switchable;
54 bool lenovo_dcute;
55 Version display_link_version;
56 GPUDevice gpu;
57 std::vector<GPUDevice> secondary_gpus;
58 uint64 adapter_luid;
59 std::string driver_vendor;
60 std::string driver_version;
61 std::string driver_date;
62 std::string pixel_shader_version;
63 std::string vertex_shader_version;
64 std::string machine_model_name;
65 std::string machine_model_version;
66 std::string gl_version_string;
67 std::string gl_vendor;
68 std::string gl_renderer;
69 std::string gl_extensions;
70 std::string gl_ws_vendor;
71 std::string gl_ws_version;
72 std::string gl_ws_extensions;
73 uint32 gl_reset_notification_strategy;
74 bool can_lose_context;
75 GpuPerformanceStats performance_stats;
76 bool software_rendering;
77 bool direct_rendering;
78 bool sandboxed;
79 int process_crash_count;
80 #if defined(OS_WIN)
81 DxDiagNode dx_diagnostics;
82 #endif
85 // If this assert fails then most likely something below needs to be updated.
86 // Note that this assert is only approximate. If a new field is added to
87 // GPUInfo which fits within the current padding then it will not be caught.
88 COMPILE_ASSERT(
89 sizeof(GPUInfo) == sizeof(GPUInfoKnownFields),
90 Fields_Have_Changed_In_GPUInfo_So_Update_Below);
92 // Required fields (according to DevTools protocol) first.
93 enumerator->AddString("machineModelName", machine_model_name);
94 enumerator->AddString("machineModelVersion", machine_model_version);
95 EnumerateGPUDevice(enumerator, gpu);
96 for (size_t ii = 0; ii < secondary_gpus.size(); ++ii) {
97 EnumerateGPUDevice(enumerator, secondary_gpus[ii]);
100 enumerator->BeginAuxAttributes();
101 enumerator->AddBool("finalized", finalized);
102 enumerator->AddTimeDeltaInSecondsF("initializationTime",
103 initialization_time);
104 enumerator->AddBool("optimus", optimus);
105 enumerator->AddBool("amdSwitchable", amd_switchable);
106 enumerator->AddBool("lenovoDcute", lenovo_dcute);
107 if (display_link_version.IsValid()) {
108 enumerator->AddString("displayLinkVersion",
109 display_link_version.GetString());
111 enumerator->AddInt64("adapterLuid", adapter_luid);
112 enumerator->AddString("driverVendor", driver_vendor);
113 enumerator->AddString("driverVersion", driver_version);
114 enumerator->AddString("driverDate", driver_date);
115 enumerator->AddString("pixelShaderVersion", pixel_shader_version);
116 enumerator->AddString("vertexShaderVersion", vertex_shader_version);
117 enumerator->AddString("glVersion", gl_version);
118 enumerator->AddString("glVendor", gl_vendor);
119 enumerator->AddString("glRenderer", gl_renderer);
120 enumerator->AddString("glExtensions", gl_extensions);
121 enumerator->AddString("glWsVendor", gl_ws_vendor);
122 enumerator->AddString("glWsVersion", gl_ws_version);
123 enumerator->AddString("glWsExtensions", gl_ws_extensions);
124 enumerator->AddInt(
125 "glResetNotificationStrategy",
126 static_cast<int>(gl_reset_notification_strategy));
127 enumerator->AddBool("can_lose_context", can_lose_context);
128 // TODO(kbr): add performance_stats.
129 enumerator->AddBool("softwareRendering", software_rendering);
130 enumerator->AddBool("directRendering", direct_rendering);
131 enumerator->AddBool("sandboxed", sandboxed);
132 enumerator->AddInt("processCrashCount", process_crash_count);
133 // TODO(kbr): add dx_diagnostics on Windows.
134 enumerator->EndAuxAttributes();
137 } // namespace gpu