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 #include "media/video/video_encode_accelerator.h" 22 23 namespace gpu { 24 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 36 }; 37 38 struct GPU_EXPORT GPUInfo { 39 struct GPU_EXPORT GPUDevice { 40 GPUDevice(); 41 ~GPUDevice(); 42 43 // The DWORD (uint32) representing the graphics card vendor id. 44 uint32 vendor_id; 45 46 // The DWORD (uint32) representing the graphics card device id. 47 // Device ids are unique to vendor, not to one another. 48 uint32 device_id; 49 50 // Whether this GPU is the currently used one. 51 // Currently this field is only supported and meaningful on OS X. 52 bool active; 53 54 // The strings that describe the GPU. 55 // In Linux these strings are obtained through libpci. 56 // In Win/MacOSX, these two strings are not filled at the moment. 57 // In Android, these are respectively GL_VENDOR and GL_RENDERER. 58 std::string vendor_string; 59 std::string device_string; 60 }; 61 62 GPUInfo(); 63 ~GPUInfo(); 64 SupportsAccelerated2dCanvasGPUInfo65 bool SupportsAccelerated2dCanvas() const { 66 return !can_lose_context && !software_rendering; 67 } 68 69 // The amount of time taken to get from the process starting to the message 70 // loop being pumped. 71 base::TimeDelta initialization_time; 72 73 // Computer has NVIDIA Optimus 74 bool optimus; 75 76 // Computer has AMD Dynamic Switchable Graphics 77 bool amd_switchable; 78 79 // Lenovo dCute is installed. http://crbug.com/181665. 80 bool lenovo_dcute; 81 82 // Version of DisplayLink driver installed. Zero if not installed. 83 // http://crbug.com/177611. 84 Version display_link_version; 85 86 // Primary GPU, for exmaple, the discrete GPU in a dual GPU machine. 87 GPUDevice gpu; 88 89 // Secondary GPUs, for example, the integrated GPU in a dual GPU machine. 90 std::vector<GPUDevice> secondary_gpus; 91 92 // On Windows, the unique identifier of the adapter the GPU process uses. 93 // The default is zero, which makes the browser process create its D3D device 94 // on the primary adapter. Note that the primary adapter can change at any 95 // time so it is better to specify a particular LUID. Note that valid LUIDs 96 // are always non-zero. 97 uint64 adapter_luid; 98 99 // The vendor of the graphics driver currently installed. 100 std::string driver_vendor; 101 102 // The version of the graphics driver currently installed. 103 std::string driver_version; 104 105 // The date of the graphics driver currently installed. 106 std::string driver_date; 107 108 // The version of the pixel/fragment shader used by the gpu. 109 std::string pixel_shader_version; 110 111 // The version of the vertex shader used by the gpu. 112 std::string vertex_shader_version; 113 114 // The machine model identifier. They can contain any character, including 115 // whitespaces. Currently it is supported on MacOSX and Android. 116 // Android examples: "Naxus 5", "XT1032". 117 // On MacOSX, the version is stripped out of the model identifier, for 118 // example, the original identifier is "MacBookPro7,2", and we put 119 // "MacBookPro" as machine_model_name, and "7.2" as machine_model_version. 120 std::string machine_model_name; 121 122 // The version of the machine model. Currently it is supported on MacOSX. 123 // See machine_model_name's comment. 124 std::string machine_model_version; 125 126 // The GL_VERSION string. 127 std::string gl_version; 128 129 // The GL_VENDOR string. 130 std::string gl_vendor; 131 132 // The GL_RENDERER string. 133 std::string gl_renderer; 134 135 // The GL_EXTENSIONS string. 136 std::string gl_extensions; 137 138 // GL window system binding vendor. "" if not available. 139 std::string gl_ws_vendor; 140 141 // GL window system binding version. "" if not available. 142 std::string gl_ws_version; 143 144 // GL window system binding extensions. "" if not available. 145 std::string gl_ws_extensions; 146 147 // GL reset notification strategy as defined by GL_ARB_robustness. 0 if GPU 148 // reset detection or notification not available. 149 uint32 gl_reset_notification_strategy; 150 151 // The device semantics, i.e. whether the Vista and Windows 7 specific 152 // semantics are available. 153 bool can_lose_context; 154 155 // By default all values are 0. 156 GpuPerformanceStats performance_stats; 157 158 bool software_rendering; 159 160 // Whether the driver uses direct rendering. True on most platforms, false on 161 // X11 when using remote X. 162 bool direct_rendering; 163 164 // Whether the gpu process is running in a sandbox. 165 bool sandboxed; 166 167 // Number of GPU process crashes recorded. 168 int process_crash_count; 169 170 // The state of whether the basic/context/DxDiagnostics info is collected and 171 // if the collection fails or not. 172 CollectInfoResult basic_info_state; 173 CollectInfoResult context_info_state; 174 #if defined(OS_WIN) 175 CollectInfoResult dx_diagnostics_info_state; 176 177 // The information returned by the DirectX Diagnostics Tool. 178 DxDiagNode dx_diagnostics; 179 #endif 180 181 std::vector<media::VideoEncodeAccelerator::SupportedProfile> 182 video_encode_accelerator_supported_profiles; 183 // Note: when adding new members, please remember to update EnumerateFields 184 // in gpu_info.cc. 185 186 // In conjunction with EnumerateFields, this allows the embedder to 187 // enumerate the values in this structure without having to embed 188 // references to its specific member variables. This simplifies the 189 // addition of new fields to this type. 190 class Enumerator { 191 public: 192 // The following methods apply to the "current" object. Initially this 193 // is the root object, but calls to BeginGPUDevice/EndGPUDevice and 194 // BeginAuxAttributes/EndAuxAttributes change the object to which these 195 // calls should apply. 196 virtual void AddInt64(const char* name, int64 value) = 0; 197 virtual void AddInt(const char* name, int value) = 0; 198 virtual void AddString(const char* name, const std::string& value) = 0; 199 virtual void AddBool(const char* name, bool value) = 0; 200 virtual void AddTimeDeltaInSecondsF(const char* name, 201 const base::TimeDelta& value) = 0; 202 203 // Markers indicating that a GPUDevice is being described. 204 virtual void BeginGPUDevice() = 0; 205 virtual void EndGPUDevice() = 0; 206 207 // Markers indicating that a VideoEncodeAccelerator::SupportedProfile is 208 // being described. 209 virtual void BeginVideoEncodeAcceleratorSupportedProfile() = 0; 210 virtual void EndVideoEncodeAcceleratorSupportedProfile() = 0; 211 212 // Markers indicating that "auxiliary" attributes of the GPUInfo 213 // (according to the DevTools protocol) are being described. 214 virtual void BeginAuxAttributes() = 0; 215 virtual void EndAuxAttributes() = 0; 216 217 protected: ~EnumeratorGPUInfo218 virtual ~Enumerator() {} 219 }; 220 221 // Outputs the fields in this structure to the provided enumerator. 222 void EnumerateFields(Enumerator* enumerator) const; 223 }; 224 225 } // namespace gpu 226 227 #endif // GPU_CONFIG_GPU_INFO_H_ 228