tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

driver_utils.h (6350B)


      1 //
      2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 // driver_utils.h : provides more information about current driver.
      8 
      9 #ifndef LIBANGLE_RENDERER_DRIVER_UTILS_H_
     10 #define LIBANGLE_RENDERER_DRIVER_UTILS_H_
     11 
     12 #include "common/platform.h"
     13 #include "libANGLE/angletypes.h"
     14 
     15 namespace rx
     16 {
     17 
     18 enum VendorID : uint32_t
     19 {
     20    VENDOR_ID_UNKNOWN = 0x0,
     21    VENDOR_ID_AMD     = 0x1002,
     22    VENDOR_ID_APPLE   = 0x106B,
     23    VENDOR_ID_ARM     = 0x13B5,
     24    // Broadcom devices won't use PCI, but this is their Vulkan vendor id.
     25    VENDOR_ID_BROADCOM  = 0x14E4,
     26    VENDOR_ID_GOOGLE    = 0x1AE0,
     27    VENDOR_ID_INTEL     = 0x8086,
     28    VENDOR_ID_MESA      = 0x10005,
     29    VENDOR_ID_MICROSOFT = 0x1414,
     30    VENDOR_ID_NVIDIA    = 0x10DE,
     31    VENDOR_ID_POWERVR   = 0x1010,
     32    // This is Qualcomm PCI Vendor ID.
     33    // Android doesn't have a PCI bus, but all we need is a unique id.
     34    VENDOR_ID_QUALCOMM = 0x5143,
     35    VENDOR_ID_SAMSUNG  = 0x144D,
     36    VENDOR_ID_VIVANTE  = 0x9999,
     37    VENDOR_ID_VMWARE   = 0x15AD,
     38 };
     39 
     40 enum AndroidDeviceID : uint32_t
     41 {
     42    ANDROID_DEVICE_ID_UNKNOWN     = 0x0,
     43    ANDROID_DEVICE_ID_NEXUS5X     = 0x4010800,
     44    ANDROID_DEVICE_ID_PIXEL2      = 0x5040001,
     45    ANDROID_DEVICE_ID_PIXEL1XL    = 0x5030004,
     46    ANDROID_DEVICE_ID_PIXEL4      = 0x6040001,
     47    ANDROID_DEVICE_ID_SWIFTSHADER = 0xC0DE,
     48 };
     49 
     50 inline bool IsAMD(uint32_t vendorId)
     51 {
     52    return vendorId == VENDOR_ID_AMD;
     53 }
     54 
     55 inline bool IsApple(uint32_t vendorId)
     56 {
     57    return vendorId == VENDOR_ID_APPLE;
     58 }
     59 
     60 inline bool IsARM(uint32_t vendorId)
     61 {
     62    return vendorId == VENDOR_ID_ARM;
     63 }
     64 
     65 inline bool IsBroadcom(uint32_t vendorId)
     66 {
     67    return vendorId == VENDOR_ID_BROADCOM;
     68 }
     69 
     70 inline bool IsIntel(uint32_t vendorId)
     71 {
     72    return vendorId == VENDOR_ID_INTEL;
     73 }
     74 
     75 inline bool IsGoogle(uint32_t vendorId)
     76 {
     77    return vendorId == VENDOR_ID_GOOGLE;
     78 }
     79 
     80 inline bool IsMicrosoft(uint32_t vendorId)
     81 {
     82    return vendorId == VENDOR_ID_MICROSOFT;
     83 }
     84 
     85 inline bool IsNvidia(uint32_t vendorId)
     86 {
     87    return vendorId == VENDOR_ID_NVIDIA;
     88 }
     89 
     90 inline bool IsPowerVR(uint32_t vendorId)
     91 {
     92    return vendorId == VENDOR_ID_POWERVR;
     93 }
     94 
     95 inline bool IsQualcomm(uint32_t vendorId)
     96 {
     97    return vendorId == VENDOR_ID_QUALCOMM;
     98 }
     99 
    100 inline bool IsSamsung(uint32_t vendorId)
    101 {
    102    return vendorId == VENDOR_ID_SAMSUNG;
    103 }
    104 
    105 inline bool IsVivante(uint32_t vendorId)
    106 {
    107    return vendorId == VENDOR_ID_VIVANTE;
    108 }
    109 
    110 inline bool IsVMWare(uint32_t vendorId)
    111 {
    112    return vendorId == VENDOR_ID_VMWARE;
    113 }
    114 
    115 inline bool IsNexus5X(uint32_t vendorId, uint32_t deviceId)
    116 {
    117    return IsQualcomm(vendorId) && deviceId == ANDROID_DEVICE_ID_NEXUS5X;
    118 }
    119 
    120 inline bool IsPixel1XL(uint32_t vendorId, uint32_t deviceId)
    121 {
    122    return IsQualcomm(vendorId) && deviceId == ANDROID_DEVICE_ID_PIXEL1XL;
    123 }
    124 
    125 inline bool IsPixel2(uint32_t vendorId, uint32_t deviceId)
    126 {
    127    return IsQualcomm(vendorId) && deviceId == ANDROID_DEVICE_ID_PIXEL2;
    128 }
    129 
    130 inline bool IsPixel4(uint32_t vendorId, uint32_t deviceId)
    131 {
    132    return IsQualcomm(vendorId) && deviceId == ANDROID_DEVICE_ID_PIXEL4;
    133 }
    134 
    135 inline bool IsSwiftshader(uint32_t vendorId, uint32_t deviceId)
    136 {
    137    return IsGoogle(vendorId) && deviceId == ANDROID_DEVICE_ID_SWIFTSHADER;
    138 }
    139 
    140 const char *GetVendorString(uint32_t vendorId);
    141 
    142 // For Linux, Intel graphics driver version is the Mesa version. The version number has three
    143 // fields: major revision, minor revision and release number.
    144 // For Windows, The version number includes 3rd and 4th fields. Please refer the details at
    145 // http://www.intel.com/content/www/us/en/support/graphics-drivers/000005654.html.
    146 // Current implementation only supports Windows.
    147 class IntelDriverVersion
    148 {
    149  public:
    150    IntelDriverVersion(uint32_t buildNumber);
    151    bool operator==(const IntelDriverVersion &);
    152    bool operator!=(const IntelDriverVersion &);
    153    bool operator<(const IntelDriverVersion &);
    154    bool operator>=(const IntelDriverVersion &);
    155 
    156  private:
    157    uint32_t mBuildNumber;
    158 };
    159 
    160 bool IsSandyBridge(uint32_t DeviceId);
    161 bool IsIvyBridge(uint32_t DeviceId);
    162 bool IsHaswell(uint32_t DeviceId);
    163 bool IsBroadwell(uint32_t DeviceId);
    164 bool IsCherryView(uint32_t DeviceId);
    165 bool IsSkylake(uint32_t DeviceId);
    166 bool IsBroxton(uint32_t DeviceId);
    167 bool IsKabyLake(uint32_t DeviceId);
    168 bool IsGeminiLake(uint32_t DeviceId);
    169 bool IsCoffeeLake(uint32_t DeviceId);
    170 bool Is9thGenIntel(uint32_t DeviceId);
    171 bool Is11thGenIntel(uint32_t DeviceId);
    172 bool Is12thGenIntel(uint32_t DeviceId);
    173 
    174 struct MajorMinorPatchVersion
    175 {
    176    MajorMinorPatchVersion();
    177    MajorMinorPatchVersion(int major, int minor, int patch);
    178 
    179    int majorVersion = 0;
    180    int minorVersion = 0;
    181    int patchVersion = 0;
    182 };
    183 bool operator==(const MajorMinorPatchVersion &a, const MajorMinorPatchVersion &b);
    184 bool operator!=(const MajorMinorPatchVersion &a, const MajorMinorPatchVersion &b);
    185 bool operator<(const MajorMinorPatchVersion &a, const MajorMinorPatchVersion &b);
    186 bool operator>=(const MajorMinorPatchVersion &a, const MajorMinorPatchVersion &b);
    187 
    188 using ARMDriverVersion = MajorMinorPatchVersion;
    189 ARMDriverVersion ParseARMDriverVersion(uint32_t driverVersion);
    190 
    191 // Platform helpers
    192 inline bool IsWindows()
    193 {
    194 #if defined(ANGLE_PLATFORM_WINDOWS)
    195    return true;
    196 #else
    197    return false;
    198 #endif
    199 }
    200 
    201 inline bool IsLinux()
    202 {
    203 #if defined(ANGLE_PLATFORM_LINUX)
    204    return true;
    205 #else
    206    return false;
    207 #endif
    208 }
    209 
    210 inline bool IsChromeOS()
    211 {
    212 #if defined(ANGLE_PLATFORM_CHROMEOS)
    213    return true;
    214 #else
    215    return false;
    216 #endif
    217 }
    218 
    219 inline bool IsApple()
    220 {
    221 #if defined(ANGLE_PLATFORM_APPLE)
    222    return true;
    223 #else
    224    return false;
    225 #endif
    226 }
    227 
    228 inline bool IsMac()
    229 {
    230 #if defined(ANGLE_PLATFORM_APPLE) && defined(ANGLE_PLATFORM_MACOS)
    231    return true;
    232 #else
    233    return false;
    234 #endif
    235 }
    236 
    237 inline bool IsFuchsia()
    238 {
    239 #if defined(ANGLE_PLATFORM_FUCHSIA)
    240    return true;
    241 #else
    242    return false;
    243 #endif
    244 }
    245 
    246 inline bool IsIOS()
    247 {
    248 #if defined(ANGLE_PLATFORM_IOS)
    249    return true;
    250 #else
    251    return false;
    252 #endif
    253 }
    254 
    255 bool IsWayland();
    256 bool IsWin10OrGreater();
    257 
    258 using OSVersion = MajorMinorPatchVersion;
    259 
    260 OSVersion GetMacOSVersion();
    261 
    262 OSVersion GetiOSVersion();
    263 
    264 OSVersion GetLinuxOSVersion();
    265 
    266 inline bool IsAndroid()
    267 {
    268 #if defined(ANGLE_PLATFORM_ANDROID)
    269    return true;
    270 #else
    271    return false;
    272 #endif
    273 }
    274 
    275 int GetAndroidSDKVersion();
    276 
    277 }  // namespace rx
    278 #endif  // LIBANGLE_RENDERER_DRIVER_UTILS_H_