1 // 2 // Copyright 2013 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 // SystemInfo.h: gathers information available without starting a GPU driver. 8 9 #ifndef GPU_INFO_UTIL_SYSTEM_INFO_H_ 10 #define GPU_INFO_UTIL_SYSTEM_INFO_H_ 11 12 #include <cstdint> 13 #include <string> 14 #include <vector> 15 16 namespace angle 17 { 18 19 using VendorID = uint32_t; 20 using DeviceID = uint32_t; 21 22 struct VersionInfo 23 { 24 uint32_t major = 0; 25 uint32_t minor = 0; 26 uint32_t subMinor = 0; 27 uint32_t patch = 0; 28 }; 29 30 struct GPUDeviceInfo 31 { 32 GPUDeviceInfo(); 33 ~GPUDeviceInfo(); 34 35 GPUDeviceInfo(const GPUDeviceInfo &other); 36 37 VendorID vendorId = 0; 38 DeviceID deviceId = 0; 39 40 std::string driverVendor; 41 std::string driverVersion; 42 std::string driverDate; 43 44 // Only available on Android 45 VersionInfo detailedDriverVersion; 46 }; 47 48 struct SystemInfo 49 { 50 SystemInfo(); 51 ~SystemInfo(); 52 53 SystemInfo(const SystemInfo &other); 54 55 bool hasNVIDIAGPU() const; 56 bool hasIntelGPU() const; 57 bool hasAMDGPU() const; 58 59 std::vector<GPUDeviceInfo> gpus; 60 61 // Index of the GPU expected to be used for 3D graphics. Based on a best-guess heuristic on 62 // some platforms. On windows, this is accurate. 63 int activeGPUIndex = -1; 64 65 bool isOptimus = false; 66 bool isAMDSwitchable = false; 67 // Only true on dual-GPU Mac laptops. 68 bool isMacSwitchable = false; 69 70 // Only available on Android 71 std::string machineManufacturer; 72 73 // Only available on macOS and Android 74 std::string machineModelName; 75 76 // Only available on macOS 77 std::string machineModelVersion; 78 }; 79 80 // Gathers information about the system without starting a GPU driver and returns them in `info`. 81 // Returns true if all info was gathered, false otherwise. Even when false is returned, `info` will 82 // be filled with partial information. 83 bool GetSystemInfo(SystemInfo *info); 84 85 // Known PCI vendor IDs 86 constexpr VendorID kVendorID_AMD = 0x1002; 87 constexpr VendorID kVendorID_ARM = 0x13B5; 88 constexpr VendorID kVendorID_ImgTec = 0x1010; 89 constexpr VendorID kVendorID_Intel = 0x8086; 90 constexpr VendorID kVendorID_NVIDIA = 0x10DE; 91 constexpr VendorID kVendorID_Qualcomm = 0x5143; 92 constexpr VendorID kVendorID_VMWare = 0x15ad; 93 94 // Known non-PCI (i.e. Khronos-registered) vendor IDs 95 constexpr VendorID kVendorID_Vivante = 0x10001; 96 constexpr VendorID kVendorID_VeriSilicon = 0x10002; 97 constexpr VendorID kVendorID_Kazan = 0x10003; 98 99 // Predicates on vendor IDs 100 bool IsAMD(VendorID vendorId); 101 bool IsARM(VendorID vendorId); 102 bool IsImgTec(VendorID vendorId); 103 bool IsIntel(VendorID vendorId); 104 bool IsKazan(VendorID vendorId); 105 bool IsNVIDIA(VendorID vendorId); 106 bool IsQualcomm(VendorID vendorId); 107 bool IsVeriSilicon(VendorID vendorId); 108 bool IsVMWare(VendorID vendorId); 109 bool IsVivante(VendorID vendorId); 110 111 // Dumps the system info to stdout. 112 void PrintSystemInfo(const SystemInfo &info); 113 } // namespace angle 114 115 #endif // GPU_INFO_UTIL_SYSTEM_INFO_H_ 116