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