Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / gpu / config / gpu_info.h
blob7c92d3ae7d702cf73410787b4f77a95e4ede9cf2
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"
21 #include "ui/gfx/geometry/size.h"
23 namespace gpu {
25 // Result for the various Collect*Info* functions below.
26 // Fatal failures are for cases where we can't create a context at all or
27 // something, making the use of the GPU impossible.
28 // Non-fatal failures are for cases where we could gather most info, but maybe
29 // some is missing (e.g. unable to parse a version string or to detect the exact
30 // model).
31 enum CollectInfoResult {
32 kCollectInfoNone = 0,
33 kCollectInfoSuccess = 1,
34 kCollectInfoNonFatalFailure = 2,
35 kCollectInfoFatalFailure = 3
38 // Video profile. This *must* match media::VideoCodecProfile.
39 enum VideoCodecProfile {
40 VIDEO_CODEC_PROFILE_UNKNOWN = -1,
41 VIDEO_CODEC_PROFILE_MIN = VIDEO_CODEC_PROFILE_UNKNOWN,
42 H264PROFILE_BASELINE = 0,
43 H264PROFILE_MAIN = 1,
44 H264PROFILE_EXTENDED = 2,
45 H264PROFILE_HIGH = 3,
46 H264PROFILE_HIGH10PROFILE = 4,
47 H264PROFILE_HIGH422PROFILE = 5,
48 H264PROFILE_HIGH444PREDICTIVEPROFILE = 6,
49 H264PROFILE_SCALABLEBASELINE = 7,
50 H264PROFILE_SCALABLEHIGH = 8,
51 H264PROFILE_STEREOHIGH = 9,
52 H264PROFILE_MULTIVIEWHIGH = 10,
53 VP8PROFILE_ANY = 11,
54 VP9PROFILE_ANY = 12,
55 VIDEO_CODEC_PROFILE_MAX = VP9PROFILE_ANY,
58 // Specification of an encoding profile supported by a hardware encoder.
59 struct GPU_EXPORT VideoEncodeAcceleratorSupportedProfile {
60 VideoCodecProfile profile;
61 gfx::Size max_resolution;
62 uint32 max_framerate_numerator;
63 uint32 max_framerate_denominator;
66 struct GPU_EXPORT GPUInfo {
67 struct GPU_EXPORT GPUDevice {
68 GPUDevice();
69 ~GPUDevice();
71 // The DWORD (uint32) representing the graphics card vendor id.
72 uint32 vendor_id;
74 // The DWORD (uint32) representing the graphics card device id.
75 // Device ids are unique to vendor, not to one another.
76 uint32 device_id;
78 // Whether this GPU is the currently used one.
79 // Currently this field is only supported and meaningful on OS X.
80 bool active;
82 // The strings that describe the GPU.
83 // In Linux these strings are obtained through libpci.
84 // In Win/MacOSX, these two strings are not filled at the moment.
85 // In Android, these are respectively GL_VENDOR and GL_RENDERER.
86 std::string vendor_string;
87 std::string device_string;
90 GPUInfo();
91 ~GPUInfo();
93 bool SupportsAccelerated2dCanvas() const {
94 return !can_lose_context && !software_rendering;
97 // The amount of time taken to get from the process starting to the message
98 // loop being pumped.
99 base::TimeDelta initialization_time;
101 // Computer has NVIDIA Optimus
102 bool optimus;
104 // Computer has AMD Dynamic Switchable Graphics
105 bool amd_switchable;
107 // Lenovo dCute is installed. http://crbug.com/181665.
108 bool lenovo_dcute;
110 // Version of DisplayLink driver installed. Zero if not installed.
111 // http://crbug.com/177611.
112 Version display_link_version;
114 // Primary GPU, for exmaple, the discrete GPU in a dual GPU machine.
115 GPUDevice gpu;
117 // Secondary GPUs, for example, the integrated GPU in a dual GPU machine.
118 std::vector<GPUDevice> secondary_gpus;
120 // On Windows, the unique identifier of the adapter the GPU process uses.
121 // The default is zero, which makes the browser process create its D3D device
122 // on the primary adapter. Note that the primary adapter can change at any
123 // time so it is better to specify a particular LUID. Note that valid LUIDs
124 // are always non-zero.
125 uint64 adapter_luid;
127 // The vendor of the graphics driver currently installed.
128 std::string driver_vendor;
130 // The version of the graphics driver currently installed.
131 std::string driver_version;
133 // The date of the graphics driver currently installed.
134 std::string driver_date;
136 // The version of the pixel/fragment shader used by the gpu.
137 std::string pixel_shader_version;
139 // The version of the vertex shader used by the gpu.
140 std::string vertex_shader_version;
142 // The machine model identifier. They can contain any character, including
143 // whitespaces. Currently it is supported on MacOSX and Android.
144 // Android examples: "Naxus 5", "XT1032".
145 // On MacOSX, the version is stripped out of the model identifier, for
146 // example, the original identifier is "MacBookPro7,2", and we put
147 // "MacBookPro" as machine_model_name, and "7.2" as machine_model_version.
148 std::string machine_model_name;
150 // The version of the machine model. Currently it is supported on MacOSX.
151 // See machine_model_name's comment.
152 std::string machine_model_version;
154 // The GL_VERSION string.
155 std::string gl_version;
157 // The GL_VENDOR string.
158 std::string gl_vendor;
160 // The GL_RENDERER string.
161 std::string gl_renderer;
163 // The GL_EXTENSIONS string.
164 std::string gl_extensions;
166 // GL window system binding vendor. "" if not available.
167 std::string gl_ws_vendor;
169 // GL window system binding version. "" if not available.
170 std::string gl_ws_version;
172 // GL window system binding extensions. "" if not available.
173 std::string gl_ws_extensions;
175 // GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU
176 // reset detection or notification not available.
177 uint32 gl_reset_notification_strategy;
179 // The device semantics, i.e. whether the Vista and Windows 7 specific
180 // semantics are available.
181 bool can_lose_context;
183 // By default all values are 0.
184 GpuPerformanceStats performance_stats;
186 bool software_rendering;
188 // Whether the driver uses direct rendering. True on most platforms, false on
189 // X11 when using remote X.
190 bool direct_rendering;
192 // Whether the gpu process is running in a sandbox.
193 bool sandboxed;
195 // Number of GPU process crashes recorded.
196 int process_crash_count;
198 // The state of whether the basic/context/DxDiagnostics info is collected and
199 // if the collection fails or not.
200 CollectInfoResult basic_info_state;
201 CollectInfoResult context_info_state;
202 #if defined(OS_WIN)
203 CollectInfoResult dx_diagnostics_info_state;
205 // The information returned by the DirectX Diagnostics Tool.
206 DxDiagNode dx_diagnostics;
207 #endif
209 std::vector<VideoEncodeAcceleratorSupportedProfile>
210 video_encode_accelerator_supported_profiles;
211 // Note: when adding new members, please remember to update EnumerateFields
212 // in gpu_info.cc.
214 // In conjunction with EnumerateFields, this allows the embedder to
215 // enumerate the values in this structure without having to embed
216 // references to its specific member variables. This simplifies the
217 // addition of new fields to this type.
218 class Enumerator {
219 public:
220 // The following methods apply to the "current" object. Initially this
221 // is the root object, but calls to BeginGPUDevice/EndGPUDevice and
222 // BeginAuxAttributes/EndAuxAttributes change the object to which these
223 // calls should apply.
224 virtual void AddInt64(const char* name, int64 value) = 0;
225 virtual void AddInt(const char* name, int value) = 0;
226 virtual void AddString(const char* name, const std::string& value) = 0;
227 virtual void AddBool(const char* name, bool value) = 0;
228 virtual void AddTimeDeltaInSecondsF(const char* name,
229 const base::TimeDelta& value) = 0;
231 // Markers indicating that a GPUDevice is being described.
232 virtual void BeginGPUDevice() = 0;
233 virtual void EndGPUDevice() = 0;
235 // Markers indicating that a VideoEncodeAcceleratorSupportedProfile is
236 // being described.
237 virtual void BeginVideoEncodeAcceleratorSupportedProfile() = 0;
238 virtual void EndVideoEncodeAcceleratorSupportedProfile() = 0;
240 // Markers indicating that "auxiliary" attributes of the GPUInfo
241 // (according to the DevTools protocol) are being described.
242 virtual void BeginAuxAttributes() = 0;
243 virtual void EndAuxAttributes() = 0;
245 protected:
246 virtual ~Enumerator() {}
249 // Outputs the fields in this structure to the provided enumerator.
250 void EnumerateFields(Enumerator* enumerator) const;
253 } // namespace gpu
255 #endif // GPU_CONFIG_GPU_INFO_H_