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