Hash :
5c58505b
Author :
Date :
2025-10-02T16:22:19
Tests: Update expectations for GalaxyS24Exynos Test: angle_end2end_tests Bug: b/410630704 Change-Id: I18c1a9d9c5dfbb4b9238ecac5a081bde5c070540 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/7007381 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
//
// 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.cpp: implementation of the system-agnostic parts of SystemInfo.h
#include "gpu_info_util/SystemInfo.h"
#include <cstring>
#include <iostream>
#include <sstream>
#include "anglebase/no_destructor.h"
#include "common/debug.h"
#include "common/string_utils.h"
#include "common/system_utils.h"
namespace angle
{
namespace
{
constexpr char kANGLEPreferredDeviceEnv[] = "ANGLE_PREFERRED_DEVICE";
}
std::string VendorName(VendorID vendor)
{
switch (vendor)
{
case kVendorID_AMD:
return "AMD";
case kVendorID_ARM:
return "ARM";
case kVendorID_Broadcom:
return "Broadcom";
case kVendorID_GOOGLE:
return "Google";
case kVendorID_ImgTec:
return "ImgTec";
case kVendorID_Intel:
return "Intel";
case kVendorID_Kazan:
return "Kazan";
case kVendorID_NVIDIA:
return "NVIDIA";
case kVendorID_Qualcomm:
case kVendorID_Qualcomm_DXGI:
return "Qualcomm";
case kVendorID_VeriSilicon:
return "VeriSilicon";
case kVendorID_Vivante:
return "Vivante";
case kVendorID_VMWare:
return "VMWare";
case kVendorID_VirtIO:
return "VirtIO";
case kVendorID_Apple:
return "Apple";
case kVendorID_Microsoft:
return "Microsoft";
default:
return "Unknown (" + std::to_string(vendor) + ")";
}
}
GPUDeviceInfo::GPUDeviceInfo() = default;
GPUDeviceInfo::~GPUDeviceInfo() = default;
GPUDeviceInfo::GPUDeviceInfo(const GPUDeviceInfo &other) = default;
SystemInfo::SystemInfo() = default;
SystemInfo::~SystemInfo() = default;
SystemInfo::SystemInfo(const SystemInfo &other) = default;
bool SystemInfo::hasNVIDIAGPU() const
{
for (const GPUDeviceInfo &gpu : gpus)
{
if (IsNVIDIA(gpu.vendorId))
{
return true;
}
}
return false;
}
bool SystemInfo::hasIntelGPU() const
{
for (const GPUDeviceInfo &gpu : gpus)
{
if (IsIntel(gpu.vendorId))
{
return true;
}
}
return false;
}
bool SystemInfo::hasAMDGPU() const
{
for (const GPUDeviceInfo &gpu : gpus)
{
if (IsAMD(gpu.vendorId))
{
return true;
}
}
return false;
}
std::optional<size_t> SystemInfo::getPreferredGPUIndex() const
{
std::string device = GetPreferredDeviceString();
if (!device.empty())
{
for (size_t i = 0; i < gpus.size(); ++i)
{
std::string vendor = VendorName(gpus[i].vendorId);
ToLower(&vendor);
if (vendor == device)
return i;
}
}
return std::nullopt;
}
bool IsAMD(VendorID vendorId)
{
return vendorId == kVendorID_AMD;
}
bool IsARM(VendorID vendorId)
{
return vendorId == kVendorID_ARM;
}
bool IsBroadcom(VendorID vendorId)
{
return vendorId == kVendorID_Broadcom;
}
bool IsImgTec(VendorID vendorId)
{
return vendorId == kVendorID_ImgTec;
}
bool IsKazan(VendorID vendorId)
{
return vendorId == kVendorID_Kazan;
}
bool IsIntel(VendorID vendorId)
{
return vendorId == kVendorID_Intel;
}
bool IsNVIDIA(VendorID vendorId)
{
return vendorId == kVendorID_NVIDIA;
}
bool IsQualcomm(VendorID vendorId)
{
return vendorId == kVendorID_Qualcomm;
}
bool IsSamsung(VendorID vendorId)
{
return vendorId == kVendorID_Samsung;
}
bool IsGoogle(VendorID vendorId)
{
return vendorId == kVendorID_GOOGLE;
}
bool IsVeriSilicon(VendorID vendorId)
{
return vendorId == kVendorID_VeriSilicon;
}
bool IsVMWare(VendorID vendorId)
{
return vendorId == kVendorID_VMWare;
}
bool IsVirtIO(VendorID vendorId)
{
return vendorId == kVendorID_VirtIO;
}
bool IsVivante(VendorID vendorId)
{
return vendorId == kVendorID_Vivante;
}
bool IsAppleGPU(VendorID vendorId)
{
return vendorId == kVendorID_Apple;
}
bool IsMicrosoft(VendorID vendorId)
{
return vendorId == kVendorID_Microsoft;
}
bool ParseAMDBrahmaDriverVersion(const std::string &content, std::string *version)
{
const size_t begin = content.find_first_of("0123456789");
if (begin == std::string::npos)
{
return false;
}
const size_t end = content.find_first_not_of("0123456789.", begin);
if (end == std::string::npos)
{
*version = content.substr(begin);
}
else
{
*version = content.substr(begin, end - begin);
}
return true;
}
bool ParseAMDCatalystDriverVersion(const std::string &content, std::string *version)
{
std::istringstream stream(content);
std::string line;
while (std::getline(stream, line))
{
static const char kReleaseVersion[] = "ReleaseVersion=";
if (line.compare(0, std::strlen(kReleaseVersion), kReleaseVersion) != 0)
{
continue;
}
if (ParseAMDBrahmaDriverVersion(line, version))
{
return true;
}
}
return false;
}
bool CMDeviceIDToDeviceAndVendorID(const std::string &id, uint32_t *vendorId, uint32_t *deviceId)
{
unsigned int vendor = 0;
unsigned int device = 0;
bool success = id.length() >= 21 && HexStringToUInt(id.substr(8, 4), &vendor) &&
HexStringToUInt(id.substr(17, 4), &device);
*vendorId = vendor;
*deviceId = device;
return success;
}
void GetDualGPUInfo(SystemInfo *info)
{
ASSERT(!info->gpus.empty());
// On dual-GPU systems we assume the non-Intel GPU is the graphics one.
// TODO: this is incorrect and problematic. activeGPUIndex must be removed if it cannot be
// determined correctly. A potential solution is to create an OpenGL context and parse
// GL_VENDOR. Currently, our test infrastructure is relying on this information and incorrectly
// applies test expectations on dual-GPU systems when the Intel GPU is active.
// http://anglebug.com/40644803.
int active = 0;
bool hasIntel = false;
for (size_t i = 0; i < info->gpus.size(); ++i)
{
if (IsIntel(info->gpus[i].vendorId))
{
hasIntel = true;
}
if (IsIntel(info->gpus[active].vendorId))
{
active = static_cast<int>(i);
}
}
// Assume that a combination of NVIDIA or AMD with Intel means Optimus or AMD Switchable
info->activeGPUIndex = active;
info->isOptimus = hasIntel && IsNVIDIA(info->gpus[active].vendorId);
info->isAMDSwitchable = hasIntel && IsAMD(info->gpus[active].vendorId);
}
void PrintSystemInfo(const SystemInfo &info)
{
std::cout << info.gpus.size() << " GPUs:\n";
for (size_t i = 0; i < info.gpus.size(); i++)
{
const auto &gpu = info.gpus[i];
std::cout << " " << i << " - " << VendorName(gpu.vendorId) << " device id: 0x" << std::hex
<< std::uppercase << gpu.deviceId << std::dec << ", revision id: 0x" << std::hex
<< std::uppercase << gpu.revisionId << std::dec << ", system device id: 0x"
<< std::hex << std::uppercase << gpu.systemDeviceId << std::dec << "\n";
if (!gpu.driverVendor.empty())
{
std::cout << " Driver Vendor: " << gpu.driverVendor << "\n";
}
if (!gpu.driverVersion.empty())
{
std::cout << " Driver Version: " << gpu.driverVersion << "\n";
}
if (!gpu.driverDate.empty())
{
std::cout << " Driver Date: " << gpu.driverDate << "\n";
}
if (gpu.detailedDriverVersion.major != 0 || gpu.detailedDriverVersion.minor != 0 ||
gpu.detailedDriverVersion.subMinor != 0 || gpu.detailedDriverVersion.patch != 0)
{
std::cout << " Detailed Driver Version:\n"
<< " major: " << gpu.detailedDriverVersion.major
<< " minor: " << gpu.detailedDriverVersion.minor
<< " subMinor: " << gpu.detailedDriverVersion.subMinor
<< " patch: " << gpu.detailedDriverVersion.patch << "\n";
}
}
std::cout << "\n";
std::cout << "Active GPU: " << info.activeGPUIndex << "\n";
std::cout << "\n";
std::cout << "Optimus: " << (info.isOptimus ? "true" : "false") << "\n";
std::cout << "AMD Switchable: " << (info.isAMDSwitchable ? "true" : "false") << "\n";
std::cout << "Mac Switchable: " << (info.isMacSwitchable ? "true" : "false") << "\n";
std::cout << "\n";
if (!info.machineManufacturer.empty())
{
std::cout << "Machine Manufacturer: " << info.machineManufacturer << "\n";
}
if (info.androidSdkLevel != 0)
{
std::cout << "Android SDK Level: " << info.androidSdkLevel << "\n";
}
if (!info.machineModelName.empty())
{
std::cout << "Machine Model: " << info.machineModelName << "\n";
}
if (!info.machineModelVersion.empty())
{
std::cout << "Machine Model Version: " << info.machineModelVersion << "\n";
}
std::cout << std::endl;
}
uint64_t GetSystemDeviceIdFromParts(uint32_t highPart, uint32_t lowPart)
{
return (static_cast<uint64_t>(highPart) << 32) | lowPart;
}
uint32_t GetSystemDeviceIdHighPart(uint64_t systemDeviceId)
{
return (systemDeviceId >> 32) & 0xffffffff;
}
uint32_t GetSystemDeviceIdLowPart(uint64_t systemDeviceId)
{
return systemDeviceId & 0xffffffff;
}
std::string GetPreferredDeviceString()
{
std::string device = angle::GetEnvironmentVar(kANGLEPreferredDeviceEnv);
ToLower(&device);
return device;
}
} // namespace angle