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.
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"
24 struct GPU_EXPORT GPUInfo
{
25 struct GPU_EXPORT GPUDevice
{
29 // The DWORD (uint32) representing the graphics card vendor id.
32 // The DWORD (uint32) representing the graphics card device id.
33 // Device ids are unique to vendor, not to one another.
36 // Whether this GPU is the currently used one.
37 // Currently this field is only supported and meaningful on OS X.
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
;
51 bool SupportsAccelerated2dCanvas() const {
52 return !can_lose_context
&& !software_rendering
;
55 // Whether more GPUInfo fields might be collected in the future.
58 // The amount of time taken to get from the process starting to the message
60 base::TimeDelta initialization_time
;
62 // Computer has NVIDIA Optimus
65 // Computer has AMD Dynamic Switchable Graphics
68 // Lenovo dCute is installed. http://crbug.com/181665.
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.
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.
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.
157 // The information returned by the DirectX Diagnostics Tool.
158 DxDiagNode dx_diagnostics
;
160 // Note: when adding new members, please remember to update EnumerateFields
163 // In conjunction with EnumerateFields, this allows the embedder to
164 // enumerate the values in this structure without having to embed
165 // references to its specific member variables. This simplifies the
166 // addition of new fields to this type.
169 // The following methods apply to the "current" object. Initially this
170 // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
171 // BeginAuxAttributes/EndAuxAttributes change the object to which these
172 // calls should apply.
173 virtual void AddInt64(const char* name
, int64 value
) = 0;
174 virtual void AddInt(const char* name
, int value
) = 0;
175 virtual void AddString(const char* name
, const std::string
& value
) = 0;
176 virtual void AddBool(const char* name
, bool value
) = 0;
177 virtual void AddTimeDeltaInSecondsF(const char* name
,
178 const base::TimeDelta
& value
) = 0;
180 // Markers indicating that a GPUDevice is being described.
181 virtual void BeginGPUDevice() = 0;
182 virtual void EndGPUDevice() = 0;
184 // Markers indicating that "auxiliary" attributes of the GPUInfo
185 // (according to the DevTools protocol) are being described.
186 virtual void BeginAuxAttributes() = 0;
187 virtual void EndAuxAttributes() = 0;
190 virtual ~Enumerator() {}
193 // Outputs the fields in this structure to the provided enumerator.
194 void EnumerateFields(Enumerator
* enumerator
) const;
199 #endif // GPU_CONFIG_GPU_INFO_H_