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