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 // The strings that describe the GPU.
37 // In Linux these strings are obtained through libpci.
38 // In Win/MacOSX, these two strings are not filled at the moment.
39 // In Android, these are respectively GL_VENDOR and GL_RENDERER.
40 std::string vendor_string
;
41 std::string device_string
;
47 bool SupportsAccelerated2dCanvas() const {
48 return !can_lose_context
&& !software_rendering
;
51 // Whether more GPUInfo fields might be collected in the future.
54 // The amount of time taken to get from the process starting to the message
56 base::TimeDelta initialization_time
;
58 // Computer has NVIDIA Optimus
61 // Computer has AMD Dynamic Switchable Graphics
64 // Lenovo dCute is installed. http://crbug.com/181665.
67 // Version of DisplayLink driver installed. Zero if not installed.
68 // http://crbug.com/177611.
69 Version display_link_version
;
71 // Primary GPU, for exmaple, the discrete GPU in a dual GPU machine.
74 // Secondary GPUs, for example, the integrated GPU in a dual GPU machine.
75 std::vector
<GPUDevice
> secondary_gpus
;
77 // On Windows, the unique identifier of the adapter the GPU process uses.
78 // The default is zero, which makes the browser process create its D3D device
79 // on the primary adapter. Note that the primary adapter can change at any
80 // time so it is better to specify a particular LUID. Note that valid LUIDs
81 // are always non-zero.
84 // The vendor of the graphics driver currently installed.
85 std::string driver_vendor
;
87 // The version of the graphics driver currently installed.
88 std::string driver_version
;
90 // The date of the graphics driver currently installed.
91 std::string driver_date
;
93 // The version of the pixel/fragment shader used by the gpu.
94 std::string pixel_shader_version
;
96 // The version of the vertex shader used by the gpu.
97 std::string vertex_shader_version
;
99 // The machine model identifier with format "name major.minor".
100 // Name should not contain any whitespaces.
101 std::string machine_model
;
103 // The version of OpenGL we are using.
104 // TODO(zmo): should be able to tell if it's GL or GLES.
105 std::string gl_version
;
107 // The GL_VERSION string. "" if we are not using OpenGL.
108 std::string gl_version_string
;
110 // The GL_VENDOR string. "" if we are not using OpenGL.
111 std::string gl_vendor
;
113 // The GL_RENDERER string. "" if we are not using OpenGL.
114 std::string gl_renderer
;
116 // The GL_EXTENSIONS string. "" if we are not using OpenGL.
117 std::string gl_extensions
;
119 // GL window system binding vendor. "" if not available.
120 std::string gl_ws_vendor
;
122 // GL window system binding version. "" if not available.
123 std::string gl_ws_version
;
125 // GL window system binding extensions. "" if not available.
126 std::string gl_ws_extensions
;
128 // GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU
129 // reset detection or notification not available.
130 uint32 gl_reset_notification_strategy
;
132 // The device semantics, i.e. whether the Vista and Windows 7 specific
133 // semantics are available.
134 bool can_lose_context
;
136 // By default all values are 0.
137 GpuPerformanceStats performance_stats
;
139 bool software_rendering
;
141 // Whether the gpu process is running in a sandbox.
145 // The information returned by the DirectX Diagnostics Tool.
146 DxDiagNode dx_diagnostics
;
148 // Note: when adding new members, please remember to update EnumerateFields
151 // In conjunction with EnumerateFields, this allows the embedder to
152 // enumerate the values in this structure without having to embed
153 // references to its specific member variables. This simplifies the
154 // addition of new fields to this type.
157 // The following methods apply to the "current" object. Initially this
158 // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
159 // BeginAuxAttributes/EndAuxAttributes change the object to which these
160 // calls should apply.
161 virtual void AddInt64(const char* name
, int64 value
) = 0;
162 virtual void AddInt(const char* name
, int value
) = 0;
163 virtual void AddString(const char* name
, const std::string
& value
) = 0;
164 virtual void AddBool(const char* name
, bool value
) = 0;
165 virtual void AddTimeDeltaInSecondsF(const char* name
,
166 const base::TimeDelta
& value
) = 0;
168 // Markers indicating that a GPUDevice is being described.
169 virtual void BeginGPUDevice() = 0;
170 virtual void EndGPUDevice() = 0;
172 // Markers indicating that "auxiliary" attributes of the GPUInfo
173 // (according to the DevTools protocol) are being described.
174 virtual void BeginAuxAttributes() = 0;
175 virtual void EndAuxAttributes() = 0;
178 virtual ~Enumerator() {}
181 // Outputs the fields in this structure to the provided enumerator.
182 void EnumerateFields(Enumerator
* enumerator
) const;
187 #endif // GPU_CONFIG_GPU_INFO_H_