- add sources.
[platform/framework/web/crosswalk.git] / src / gpu / config / gpu_info.h
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.
4
5 #ifndef GPU_CONFIG_GPU_INFO_H_
6 #define GPU_CONFIG_GPU_INFO_H_
7
8 // Provides access to the GPU information for the system
9 // on which chrome is currently running.
10
11 #include <string>
12 #include <vector>
13
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"
21
22 namespace gpu {
23
24 struct GPU_EXPORT GPUInfo {
25   struct GPU_EXPORT GPUDevice {
26     GPUDevice();
27     ~GPUDevice();
28
29     // The DWORD (uint32) representing the graphics card vendor id.
30     uint32 vendor_id;
31
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;
35
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;
42   };
43
44   GPUInfo();
45   ~GPUInfo();
46
47   // Whether more GPUInfo fields might be collected in the future.
48   bool finalized;
49
50   // The amount of time taken to get from the process starting to the message
51   // loop being pumped.
52   base::TimeDelta initialization_time;
53
54   // Computer has NVIDIA Optimus
55   bool optimus;
56
57   // Computer has AMD Dynamic Switchable Graphics
58   bool amd_switchable;
59
60   // Lenovo dCute is installed. http://crbug.com/181665.
61   bool lenovo_dcute;
62
63   // Version of DisplayLink driver installed. Zero if not installed.
64   // http://crbug.com/177611.
65   Version display_link_version;
66
67   // Primary GPU, for exmaple, the discrete GPU in a dual GPU machine.
68   GPUDevice gpu;
69
70   // Secondary GPUs, for example, the integrated GPU in a dual GPU machine.
71   std::vector<GPUDevice> secondary_gpus;
72
73   // On Windows, the unique identifier of the adapter the GPU process uses.
74   // The default is zero, which makes the browser process create its D3D device
75   // on the primary adapter. Note that the primary adapter can change at any
76   // time so it is better to specify a particular LUID. Note that valid LUIDs
77   // are always non-zero.
78   uint64 adapter_luid;
79
80   // The vendor of the graphics driver currently installed.
81   std::string driver_vendor;
82
83   // The version of the graphics driver currently installed.
84   std::string driver_version;
85
86   // The date of the graphics driver currently installed.
87   std::string driver_date;
88
89   // The version of the pixel/fragment shader used by the gpu.
90   std::string pixel_shader_version;
91
92   // The version of the vertex shader used by the gpu.
93   std::string vertex_shader_version;
94
95   // The machine model identifier with format "name major.minor".
96   // Name should not contain any whitespaces.
97   std::string machine_model;
98
99   // The version of OpenGL we are using.
100   // TODO(zmo): should be able to tell if it's GL or GLES.
101   std::string gl_version;
102
103   // The GL_VERSION string.  "" if we are not using OpenGL.
104   std::string gl_version_string;
105
106   // The GL_VENDOR string.  "" if we are not using OpenGL.
107   std::string gl_vendor;
108
109   // The GL_RENDERER string.  "" if we are not using OpenGL.
110   std::string gl_renderer;
111
112   // The GL_EXTENSIONS string.  "" if we are not using OpenGL.
113   std::string gl_extensions;
114
115   // GL window system binding vendor.  "" if not available.
116   std::string gl_ws_vendor;
117
118   // GL window system binding version.  "" if not available.
119   std::string gl_ws_version;
120
121   // GL window system binding extensions.  "" if not available.
122   std::string gl_ws_extensions;
123
124   // GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU
125   // reset detection or notification not available.
126   uint32 gl_reset_notification_strategy;
127
128   // The device semantics, i.e. whether the Vista and Windows 7 specific
129   // semantics are available.
130   bool can_lose_context;
131
132   // By default all values are 0.
133   GpuPerformanceStats performance_stats;
134
135   bool software_rendering;
136
137   // Whether the gpu process is running in a sandbox.
138   bool sandboxed;
139
140 #if defined(OS_WIN)
141   // The information returned by the DirectX Diagnostics Tool.
142   DxDiagNode dx_diagnostics;
143 #endif
144   // Note: when adding new members, please remember to update EnumerateFields
145   // in gpu_info.cc.
146
147   // In conjunction with EnumerateFields, this allows the embedder to
148   // enumerate the values in this structure without having to embed
149   // references to its specific member variables. This simplifies the
150   // addition of new fields to this type.
151   class Enumerator {
152    public:
153     // The following methods apply to the "current" object. Initially this
154     // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
155     // BeginAuxAttributes/EndAuxAttributes change the object to which these
156     // calls should apply.
157     virtual void AddInt64(const char* name, int64 value) = 0;
158     virtual void AddInt(const char* name, int value) = 0;
159     virtual void AddString(const char* name, const std::string& value) = 0;
160     virtual void AddBool(const char* name, bool value) = 0;
161     virtual void AddTimeDeltaInSecondsF(const char* name,
162                                         const base::TimeDelta& value) = 0;
163
164     // Markers indicating that a GPUDevice is being described.
165     virtual void BeginGPUDevice() = 0;
166     virtual void EndGPUDevice() = 0;
167
168     // Markers indicating that "auxiliary" attributes of the GPUInfo
169     // (according to the DevTools protocol) are being described.
170     virtual void BeginAuxAttributes() = 0;
171     virtual void EndAuxAttributes() = 0;
172
173    protected:
174     virtual ~Enumerator() {}
175   };
176
177   // Outputs the fields in this structure to the provided enumerator.
178   void EnumerateFields(Enumerator* enumerator) const;
179 };
180
181 }  // namespace gpu
182
183 #endif  // GPU_CONFIG_GPU_INFO_H_