Hash :
fb26ba6a
Author :
Date :
2021-07-06T14:24:29
Extend Intel graphics driver version to 2 fields The 4th field of Intel new graphics driver will overflow soon. For example, the lastest driver version is 27.20.100.9466 and the 4th field, 9466, will meet the maximum 9999 soon. Future driver will bump the 3rd field from 100 to 101. This CL extends driver version check from 4th field to both 3rd and 4th fields. Check below 2 documents for more details. https://www.intel.com/content/www/us/en/support/articles/000005654/graphics.html https://docs.google.com/document/d/1Xm4afyGR3Ow3W2G-uig9fLQR01XzmSXeanM9OXDVhlg/edit#heading=h.k8onwbxk2ig Bug: angleproject:6138 Change-Id: Iefb1d56b48d0f08e79c329c422a6ef142b33553d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3007570 Commit-Queue: Yang Gu <yang.gu@intel.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
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
//
// Copyright 2016 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.
//
// driver_utils.h : provides more information about current driver.
#include <algorithm>
#include "libANGLE/renderer/driver_utils.h"
#include "common/platform.h"
#include "common/system_utils.h"
#if defined(ANGLE_PLATFORM_ANDROID)
# include <sys/system_properties.h>
#endif
#if defined(ANGLE_PLATFORM_LINUX)
# include <sys/utsname.h>
#endif
#if defined(ANGLE_PLATFORM_WINDOWS)
# include <versionhelpers.h>
#endif
namespace rx
{
// Intel
// Referenced from https://cgit.freedesktop.org/vaapi/intel-driver/tree/src/i965_pciids.h
namespace
{
// gen6
const uint32_t SandyBridge[] = {0x0102, 0x0106, 0x010A, 0x0112, 0x0122, 0x0116, 0x0126};
// gen7
const uint32_t IvyBridge[] = {0x0152, 0x0156, 0x015A, 0x0162, 0x0166, 0x016A};
const uint32_t Haswell[] = {
0x0402, 0x0406, 0x040A, 0x040B, 0x040E, 0x0C02, 0x0C06, 0x0C0A, 0x0C0B, 0x0C0E,
0x0A02, 0x0A06, 0x0A0A, 0x0A0B, 0x0A0E, 0x0D02, 0x0D06, 0x0D0A, 0x0D0B, 0x0D0E, // hsw_gt1
0x0412, 0x0416, 0x041A, 0x041B, 0x041E, 0x0C12, 0x0C16, 0x0C1A, 0x0C1B, 0x0C1E,
0x0A12, 0x0A16, 0x0A1A, 0x0A1B, 0x0A1E, 0x0D12, 0x0D16, 0x0D1A, 0x0D1B, 0x0D1E, // hsw_gt2
0x0422, 0x0426, 0x042A, 0x042B, 0x042E, 0x0C22, 0x0C26, 0x0C2A, 0x0C2B, 0x0C2E,
0x0A22, 0x0A26, 0x0A2A, 0x0A2B, 0x0A2E, 0x0D22, 0x0D26, 0x0D2A, 0x0D2B, 0x0D2E // hsw_gt3
};
// gen8
const uint32_t Broadwell[] = {0x1602, 0x1606, 0x160A, 0x160B, 0x160D, 0x160E,
0x1612, 0x1616, 0x161A, 0x161B, 0x161D, 0x161E,
0x1622, 0x1626, 0x162A, 0x162B, 0x162D, 0x162E};
const uint32_t CherryView[] = {0x22B0, 0x22B1, 0x22B2, 0x22B3};
// gen9
const uint32_t Skylake[] = {0x1902, 0x1906, 0x190A, 0x190B, 0x190E, 0x1912, 0x1913, 0x1915, 0x1916,
0x1917, 0x191A, 0x191B, 0x191D, 0x191E, 0x1921, 0x1923, 0x1926, 0x1927,
0x192A, 0x192B, 0x192D, 0x1932, 0x193A, 0x193B, 0x193D};
const uint32_t Broxton[] = {0x0A84, 0x1A84, 0x1A85, 0x5A84, 0x5A85};
// gen9p5
const uint32_t Kabylake[] = {0x5916, 0x5913, 0x5906, 0x5926, 0x5921, 0x5915, 0x590E,
0x591E, 0x5912, 0x5917, 0x5902, 0x591B, 0x593B, 0x590B,
0x591A, 0x590A, 0x591D, 0x5908, 0x5923, 0x5927};
} // anonymous namespace
IntelDriverVersion::IntelDriverVersion(uint32_t buildNumber) : mBuildNumber(buildNumber) {}
bool IntelDriverVersion::operator==(const IntelDriverVersion &version)
{
return mBuildNumber == version.mBuildNumber;
}
bool IntelDriverVersion::operator!=(const IntelDriverVersion &version)
{
return !(*this == version);
}
bool IntelDriverVersion::operator<(const IntelDriverVersion &version)
{
return mBuildNumber < version.mBuildNumber;
}
bool IntelDriverVersion::operator>=(const IntelDriverVersion &version)
{
return !(*this < version);
}
bool IsSandyBridge(uint32_t DeviceId)
{
return std::find(std::begin(SandyBridge), std::end(SandyBridge), DeviceId) !=
std::end(SandyBridge);
}
bool IsIvyBridge(uint32_t DeviceId)
{
return std::find(std::begin(IvyBridge), std::end(IvyBridge), DeviceId) != std::end(IvyBridge);
}
bool IsHaswell(uint32_t DeviceId)
{
return std::find(std::begin(Haswell), std::end(Haswell), DeviceId) != std::end(Haswell);
}
bool IsBroadwell(uint32_t DeviceId)
{
return std::find(std::begin(Broadwell), std::end(Broadwell), DeviceId) != std::end(Broadwell);
}
bool IsCherryView(uint32_t DeviceId)
{
return std::find(std::begin(CherryView), std::end(CherryView), DeviceId) !=
std::end(CherryView);
}
bool IsSkylake(uint32_t DeviceId)
{
return std::find(std::begin(Skylake), std::end(Skylake), DeviceId) != std::end(Skylake);
}
bool IsBroxton(uint32_t DeviceId)
{
return std::find(std::begin(Broxton), std::end(Broxton), DeviceId) != std::end(Broxton);
}
bool IsKabylake(uint32_t DeviceId)
{
return std::find(std::begin(Kabylake), std::end(Kabylake), DeviceId) != std::end(Kabylake);
}
bool Is9thGenIntel(uint32_t DeviceId)
{
return IsSkylake(DeviceId) || IsBroxton(DeviceId) || IsKabylake(DeviceId);
}
const char *GetVendorString(uint32_t vendorId)
{
switch (vendorId)
{
case VENDOR_ID_AMD:
return "AMD";
case VENDOR_ID_ARM:
return "ARM";
case VENDOR_ID_APPLE:
return "Apple";
case VENDOR_ID_BROADCOM:
return "Broadcom";
case VENDOR_ID_GOOGLE:
return "Google";
case VENDOR_ID_INTEL:
return "Intel";
case VENDOR_ID_MESA:
return "Mesa";
case VENDOR_ID_NVIDIA:
return "NVIDIA";
case VENDOR_ID_POWERVR:
return "Imagination Technologies";
case VENDOR_ID_QUALCOMM:
return "Qualcomm";
case 0xba5eba11: // Mock vendor ID used for tests.
return "Test";
case 0:
return "NULL";
default:
// TODO(jmadill): More vendor IDs.
UNIMPLEMENTED();
return "Unknown";
}
}
int GetAndroidSDKVersion()
{
#if defined(ANGLE_PLATFORM_ANDROID)
char apiVersion[PROP_VALUE_MAX];
int length = __system_property_get("ro.build.version.sdk", apiVersion);
if (length == 0)
{
return 0;
}
return atoi(apiVersion);
#else
return 0;
#endif
}
OSVersion::OSVersion() {}
OSVersion::OSVersion(int major, int minor, int patch)
: majorVersion(major), minorVersion(minor), patchVersion(patch)
{}
bool operator==(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) ==
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
bool operator!=(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) !=
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
bool operator<(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) <
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
bool operator>=(const OSVersion &a, const OSVersion &b)
{
return std::tie(a.majorVersion, a.minorVersion, a.patchVersion) >=
std::tie(b.majorVersion, b.minorVersion, b.patchVersion);
}
#if !defined(ANGLE_PLATFORM_MACOS)
OSVersion GetMacOSVersion()
{
// Return a default version
return OSVersion(0, 0, 0);
}
#endif
#if !defined(ANGLE_PLATFORM_IOS)
OSVersion GetiOSVersion()
{
// Return a default version
return OSVersion(0, 0, 0);
}
#endif
#if defined(ANGLE_PLATFORM_LINUX)
bool ParseLinuxOSVersion(const char *version, int *major, int *minor, int *patch)
{
errno = 0; // reset global error flag.
char *next;
*major = static_cast<int>(strtol(version, &next, 10));
if (next == nullptr || *next != '.' || errno != 0)
{
return false;
}
*minor = static_cast<int>(strtol(next + 1, &next, 10));
if (next == nullptr || *next != '.' || errno != 0)
{
return false;
}
*patch = static_cast<int>(strtol(next + 1, &next, 10));
if (errno != 0)
{
return false;
}
return true;
}
#endif
OSVersion GetLinuxOSVersion()
{
#if defined(ANGLE_PLATFORM_LINUX)
struct utsname uname_info;
if (uname(&uname_info) != 0)
{
return OSVersion(0, 0, 0);
}
int majorVersion = 0, minorVersion = 0, patchVersion = 0;
if (ParseLinuxOSVersion(uname_info.release, &majorVersion, &minorVersion, &patchVersion))
{
return OSVersion(majorVersion, minorVersion, patchVersion);
}
#endif
return OSVersion(0, 0, 0);
}
// There are multiple environment variables that may or may not be set during Wayland
// sessions, including WAYLAND_DISPLAY, XDG_SESSION_TYPE, and DESKTOP_SESSION
bool IsWayland()
{
static bool checked = false;
static bool isWayland = false;
if (!checked)
{
if (IsLinux())
{
if (!angle::GetEnvironmentVar("WAYLAND_DISPLAY").empty())
{
isWayland = true;
}
else if (angle::GetEnvironmentVar("XDG_SESSION_TYPE") == "wayland")
{
isWayland = true;
}
else if (angle::GetEnvironmentVar("DESKTOP_SESSION").find("wayland") !=
std::string::npos)
{
isWayland = true;
}
}
checked = true;
}
return isWayland;
}
bool IsWin10OrGreater()
{
#if defined(ANGLE_ENABLE_WINDOWS_UWP)
return true;
#elif defined(ANGLE_PLATFORM_WINDOWS)
return IsWindows10OrGreater();
#else
return false;
#endif
}
} // namespace rx