chromium/third_party/angle/src/gpu_info_util/SystemInfo.h

//
// Copyright 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// SystemInfo.h: gathers information available without starting a GPU driver.

#ifndef GPU_INFO_UTIL_SYSTEM_INFO_H_
#define GPU_INFO_UTIL_SYSTEM_INFO_H_

#include <cstdint>
#include <optional>
#include <string>
#include <vector>

namespace angle
{

VendorID;
DeviceID;
RevisionID;
SystemDeviceID;
DriverID;

struct VersionInfo
{};

struct GPUDeviceInfo
{};

struct SystemInfo
{};

// Gathers information about the system without starting a GPU driver and returns them in `info`.
// Returns true if all info was gathered, false otherwise. Even when false is returned, `info` will
// be filled with partial information.
bool GetSystemInfo(SystemInfo *info);

// Vulkan-specific info collection.
bool GetSystemInfoVulkan(SystemInfo *info);

// Known PCI vendor IDs
constexpr VendorID kVendorID_AMD       =;
constexpr VendorID kVendorID_ARM       =;
constexpr VendorID kVendorID_Broadcom  =;
constexpr VendorID kVendorID_GOOGLE    =;
constexpr VendorID kVendorID_ImgTec    =;
constexpr VendorID kVendorID_Intel     =;
constexpr VendorID kVendorID_NVIDIA    =;
constexpr VendorID kVendorID_Qualcomm  =;
constexpr VendorID kVendorID_Samsung   =;
constexpr VendorID kVendorID_VMWare    =;
constexpr VendorID kVendorID_Apple     =;
constexpr VendorID kVendorID_Microsoft =;
constexpr VendorID kVendorID_VirtIO    =;

// Known non-PCI (i.e. Khronos-registered) vendor IDs
constexpr VendorID kVendorID_Vivante     =;
constexpr VendorID kVendorID_VeriSilicon =;
constexpr VendorID kVendorID_Kazan       =;
constexpr VendorID kVendorID_CodePlay    =;
constexpr VendorID kVendorID_Mesa        =;
constexpr VendorID kVendorID_PoCL        =;

// Known device IDs
constexpr DeviceID kDeviceID_Swiftshader  =;
constexpr DeviceID kDeviceID_Adreno540    =;
constexpr DeviceID kDeviceID_Adreno750    =;
constexpr DeviceID kDeviceID_UHD630Mobile =;

// Predicates on vendor IDs
bool IsAMD(VendorID vendorId);
bool IsARM(VendorID vendorId);
bool IsBroadcom(VendorID vendorId);
bool IsImgTec(VendorID vendorId);
bool IsIntel(VendorID vendorId);
bool IsKazan(VendorID vendorId);
bool IsNVIDIA(VendorID vendorId);
bool IsQualcomm(VendorID vendorId);
bool IsSamsung(VendorID vendorId);
bool IsGoogle(VendorID vendorId);
bool IsSwiftshader(VendorID vendorId);
bool IsVeriSilicon(VendorID vendorId);
bool IsVMWare(VendorID vendorId);
bool IsVirtIO(VendorID vendorId);
bool IsVivante(VendorID vendorId);
bool IsAppleGPU(VendorID vendorId);
bool IsMicrosoft(VendorID vendorId);

// Returns a readable vendor name given the VendorID
std::string VendorName(VendorID vendor);

// Use a heuristic to attempt to find the GPU used for 3D graphics. Sets activeGPUIndex,
// isOptimus, and isAMDSwitchable.
// Always assumes the non-Intel GPU is active on dual-GPU machines.
void GetDualGPUInfo(SystemInfo *info);

// Dumps the system info to stdout.
void PrintSystemInfo(const SystemInfo &info);

VersionInfo ParseNvidiaDriverVersion(uint32_t version);
VersionInfo ParseMesaDriverVersion(uint32_t version);

uint64_t GetSystemDeviceIdFromParts(uint32_t highPart, uint32_t lowPart);
uint32_t GetSystemDeviceIdHighPart(uint64_t systemDeviceId);
uint32_t GetSystemDeviceIdLowPart(uint64_t systemDeviceId);

// Returns lower-case of ANGLE_PREFERRED_DEVICE environment variable contents.
std::string GetPreferredDeviceString();

}  // namespace angle

#endif  // GPU_INFO_UTIL_SYSTEM_INFO_H_