Path: blob/main_old/src/gpu_info_util/SystemInfo.h
1693 views
//1// Copyright 2013 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56// SystemInfo.h: gathers information available without starting a GPU driver.78#ifndef GPU_INFO_UTIL_SYSTEM_INFO_H_9#define GPU_INFO_UTIL_SYSTEM_INFO_H_1011#include <cstdint>12#include <string>13#include <vector>1415namespace angle16{1718using VendorID = uint32_t;19using DeviceID = uint32_t;20using RevisionID = uint32_t;2122struct VersionInfo23{24uint32_t major = 0;25uint32_t minor = 0;26uint32_t subMinor = 0;27uint32_t patch = 0;28};2930struct GPUDeviceInfo31{32GPUDeviceInfo();33~GPUDeviceInfo();3435GPUDeviceInfo(const GPUDeviceInfo &other);3637VendorID vendorId = 0;38DeviceID deviceId = 0;39RevisionID revisionId = 0;4041std::string driverVendor;42std::string driverVersion;43std::string driverDate;4445// Only available via GetSystemInfoVulkan currently.46VersionInfo detailedDriverVersion;47};4849struct SystemInfo50{51SystemInfo();52~SystemInfo();5354SystemInfo(const SystemInfo &other);5556bool hasNVIDIAGPU() const;57bool hasIntelGPU() const;58bool hasAMDGPU() const;5960std::vector<GPUDeviceInfo> gpus;6162// Index of the GPU expected to be used for 3D graphics. Based on a best-guess heuristic on63// some platforms. On Windows, this is accurate. Note `gpus` must be checked for empty before64// indexing.65int activeGPUIndex = 0;6667bool isOptimus = false;68bool isAMDSwitchable = false;69// Only true on dual-GPU Mac laptops.70bool isMacSwitchable = false;71// Only true on Apple Silicon Macs when running in macCatalyst.72bool needsEAGLOnMac = false;7374// Only available on Android75std::string machineManufacturer;76int androidSdkLevel = 0;7778// Only available on macOS and Android79std::string machineModelName;8081// Only available on macOS82std::string machineModelVersion;83};8485// Gathers information about the system without starting a GPU driver and returns them in `info`.86// Returns true if all info was gathered, false otherwise. Even when false is returned, `info` will87// be filled with partial information.88bool GetSystemInfo(SystemInfo *info);8990// Vulkan-specific info collection.91bool GetSystemInfoVulkan(SystemInfo *info);9293// Known PCI vendor IDs94constexpr VendorID kVendorID_AMD = 0x1002;95constexpr VendorID kVendorID_ARM = 0x13B5;96constexpr VendorID kVendorID_Broadcom = 0x14E4;97constexpr VendorID kVendorID_GOOGLE = 0x1AE0;98constexpr VendorID kVendorID_ImgTec = 0x1010;99constexpr VendorID kVendorID_Intel = 0x8086;100constexpr VendorID kVendorID_NVIDIA = 0x10DE;101constexpr VendorID kVendorID_Qualcomm = 0x5143;102constexpr VendorID kVendorID_VMWare = 0x15ad;103constexpr VendorID kVendorID_Apple = 0x106B;104105// Known non-PCI (i.e. Khronos-registered) vendor IDs106constexpr VendorID kVendorID_Vivante = 0x10001;107constexpr VendorID kVendorID_VeriSilicon = 0x10002;108constexpr VendorID kVendorID_Kazan = 0x10003;109110// Known device IDs111constexpr DeviceID kDeviceID_Swiftshader = 0xC0DE;112constexpr DeviceID kDeviceID_Adreno540 = 0x5040001;113constexpr DeviceID kDeviceID_UHD630Mobile = 0x3E9B;114115// Predicates on vendor IDs116bool IsAMD(VendorID vendorId);117bool IsARM(VendorID vendorId);118bool IsBroadcom(VendorID vendorId);119bool IsImgTec(VendorID vendorId);120bool IsIntel(VendorID vendorId);121bool IsKazan(VendorID vendorId);122bool IsNVIDIA(VendorID vendorId);123bool IsQualcomm(VendorID vendorId);124bool IsGoogle(VendorID vendorId);125bool IsSwiftshader(VendorID vendorId);126bool IsVeriSilicon(VendorID vendorId);127bool IsVMWare(VendorID vendorId);128bool IsVivante(VendorID vendorId);129bool IsApple(VendorID vendorId);130131// Use a heuristic to attempt to find the GPU used for 3D graphics. Sets activeGPUIndex,132// isOptimus, and isAMDSwitchable.133// Always assumes the non-Intel GPU is active on dual-GPU machines.134void GetDualGPUInfo(SystemInfo *info);135136// Dumps the system info to stdout.137void PrintSystemInfo(const SystemInfo &info);138139VersionInfo ParseNvidiaDriverVersion(uint32_t version);140141#if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)142// Helper to get the active GPU ID from a given Core Graphics display ID.143uint64_t GetGpuIDFromDisplayID(uint32_t displayID);144145// Helper to get the active GPU ID from an OpenGL display mask.146uint64_t GetGpuIDFromOpenGLDisplayMask(uint32_t displayMask);147148// Get VendorID from metal device's registry ID149VendorID GetVendorIDFromMetalDeviceRegistryID(uint64_t registryID);150#endif151152} // namespace angle153154#endif // GPU_INFO_UTIL_SYSTEM_INFO_H_155156157