Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / gpu / config / gpu_info.h
blobd092c3a335c320af4b3430cb97d345fd5e75fb3a
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 #ifndef GPU_CONFIG_GPU_INFO_H_
6 #define GPU_CONFIG_GPU_INFO_H_
8 // Provides access to the GPU information for the system
9 // on which chrome is currently running.
11 #include <string>
12 #include <vector>
14 #include "base/basictypes.h"
15 #include "base/time/time.h"
16 #include "base/version.h"
17 #include "build/build_config.h"
18 #include "gpu/config/dx_diag_node.h"
19 #include "gpu/config/gpu_performance_stats.h"
20 #include "gpu/gpu_export.h"
22 namespace gpu {
24 struct GPU_EXPORT GPUInfo {
25 struct GPU_EXPORT GPUDevice {
26 GPUDevice();
27 ~GPUDevice();
29 // The DWORD (uint32) representing the graphics card vendor id.
30 uint32 vendor_id;
32 // The DWORD (uint32) representing the graphics card device id.
33 // Device ids are unique to vendor, not to one another.
34 uint32 device_id;
36 // Whether this GPU is the currently used one.
37 // Currently this field is only supported and meaningful on OS X.
38 bool active;
40 // The strings that describe the GPU.
41 // In Linux these strings are obtained through libpci.
42 // In Win/MacOSX, these two strings are not filled at the moment.
43 // In Android, these are respectively GL_VENDOR and GL_RENDERER.
44 std::string vendor_string;
45 std::string device_string;
48 GPUInfo();
49 ~GPUInfo();
51 bool SupportsAccelerated2dCanvas() const {
52 return !can_lose_context && !software_rendering;
55 // Whether more GPUInfo fields might be collected in the future.
56 bool finalized;
58 // The amount of time taken to get from the process starting to the message
59 // loop being pumped.
60 base::TimeDelta initialization_time;
62 // Computer has NVIDIA Optimus
63 bool optimus;
65 // Computer has AMD Dynamic Switchable Graphics
66 bool amd_switchable;
68 // Lenovo dCute is installed. http://crbug.com/181665.
69 bool lenovo_dcute;
71 // Version of DisplayLink driver installed. Zero if not installed.
72 // http://crbug.com/177611.
73 Version display_link_version;
75 // Primary GPU, for exmaple, the discrete GPU in a dual GPU machine.
76 GPUDevice gpu;
78 // Secondary GPUs, for example, the integrated GPU in a dual GPU machine.
79 std::vector<GPUDevice> secondary_gpus;
81 // On Windows, the unique identifier of the adapter the GPU process uses.
82 // The default is zero, which makes the browser process create its D3D device
83 // on the primary adapter. Note that the primary adapter can change at any
84 // time so it is better to specify a particular LUID. Note that valid LUIDs
85 // are always non-zero.
86 uint64 adapter_luid;
88 // The vendor of the graphics driver currently installed.
89 std::string driver_vendor;
91 // The version of the graphics driver currently installed.
92 std::string driver_version;
94 // The date of the graphics driver currently installed.
95 std::string driver_date;
97 // The version of the pixel/fragment shader used by the gpu.
98 std::string pixel_shader_version;
100 // The version of the vertex shader used by the gpu.
101 std::string vertex_shader_version;
103 // The machine model identifier. They can contain any character, including
104 // whitespaces. Currently it is supported on MacOSX and Android.
105 // Android examples: "Naxus 5", "XT1032".
106 // On MacOSX, the version is stripped out of the model identifier, for
107 // example, the original identifier is "MacBookPro7,2", and we put
108 // "MacBookPro" as machine_model_name, and "7.2" as machine_model_version.
109 std::string machine_model_name;
111 // The version of the machine model. Currently it is supported on MacOSX.
112 // See machine_model_name's comment.
113 std::string machine_model_version;
115 // The GL_VERSION string.
116 std::string gl_version;
118 // The GL_VENDOR string.
119 std::string gl_vendor;
121 // The GL_RENDERER string.
122 std::string gl_renderer;
124 // The GL_EXTENSIONS string.
125 std::string gl_extensions;
127 // GL window system binding vendor. "" if not available.
128 std::string gl_ws_vendor;
130 // GL window system binding version. "" if not available.
131 std::string gl_ws_version;
133 // GL window system binding extensions. "" if not available.
134 std::string gl_ws_extensions;
136 // GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU
137 // reset detection or notification not available.
138 uint32 gl_reset_notification_strategy;
140 // The device semantics, i.e. whether the Vista and Windows 7 specific
141 // semantics are available.
142 bool can_lose_context;
144 // By default all values are 0.
145 GpuPerformanceStats performance_stats;
147 bool software_rendering;
149 // Whether the driver uses direct rendering. True on most platforms, false on
150 // X11 when using remote X.
151 bool direct_rendering;
153 // Whether the gpu process is running in a sandbox.
154 bool sandboxed;
156 // Number of GPU process crashes recorded.
157 int process_crash_count;
159 #if defined(OS_WIN)
160 // The information returned by the DirectX Diagnostics Tool.
161 DxDiagNode dx_diagnostics;
162 #endif
163 // Note: when adding new members, please remember to update EnumerateFields
164 // in gpu_info.cc.
166 // In conjunction with EnumerateFields, this allows the embedder to
167 // enumerate the values in this structure without having to embed
168 // references to its specific member variables. This simplifies the
169 // addition of new fields to this type.
170 class Enumerator {
171 public:
172 // The following methods apply to the "current" object. Initially this
173 // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
174 // BeginAuxAttributes/EndAuxAttributes change the object to which these
175 // calls should apply.
176 virtual void AddInt64(const char* name, int64 value) = 0;
177 virtual void AddInt(const char* name, int value) = 0;
178 virtual void AddString(const char* name, const std::string& value) = 0;
179 virtual void AddBool(const char* name, bool value) = 0;
180 virtual void AddTimeDeltaInSecondsF(const char* name,
181 const base::TimeDelta& value) = 0;
183 // Markers indicating that a GPUDevice is being described.
184 virtual void BeginGPUDevice() = 0;
185 virtual void EndGPUDevice() = 0;
187 // Markers indicating that "auxiliary" attributes of the GPUInfo
188 // (according to the DevTools protocol) are being described.
189 virtual void BeginAuxAttributes() = 0;
190 virtual void EndAuxAttributes() = 0;
192 protected:
193 virtual ~Enumerator() {}
196 // Outputs the fields in this structure to the provided enumerator.
197 void EnumerateFields(Enumerator* enumerator) const;
200 } // namespace gpu
202 #endif // GPU_CONFIG_GPU_INFO_H_