зеркало из https://github.com/AvaloniaUI/angle.git
Use common SystemInfo in tests.
We were using a static SystemInfo in two places. Consolidate the SystemInfo collection to a single location. Also renames Nvidia to NVIDIA to be consistent with the company naming. And adds a few helpers to SystemInfo for GPU detection. Will lead to test changes to reduce flakiness on Intel Windows. Bug: angleproject:3261 Change-Id: I4e0addf19d6fe26b4d31a1289efce72092a0a1dd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1531533 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
This commit is contained in:
Родитель
a11db2ac7c
Коммит
a683628b6a
|
@ -29,6 +29,42 @@ 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;
|
||||
}
|
||||
|
||||
bool IsAMD(VendorID vendorId)
|
||||
{
|
||||
return vendorId == kVendorID_AMD;
|
||||
|
@ -54,9 +90,9 @@ bool IsIntel(VendorID vendorId)
|
|||
return vendorId == kVendorID_Intel;
|
||||
}
|
||||
|
||||
bool IsNvidia(VendorID vendorId)
|
||||
bool IsNVIDIA(VendorID vendorId)
|
||||
{
|
||||
return vendorId == kVendorID_Nvidia;
|
||||
return vendorId == kVendorID_NVIDIA;
|
||||
}
|
||||
|
||||
bool IsQualcomm(VendorID vendorId)
|
||||
|
@ -187,9 +223,9 @@ void FindPrimaryGPU(SystemInfo *info)
|
|||
}
|
||||
}
|
||||
|
||||
// Assume that a combination of AMD or Nvidia with Intel means Optimus or AMD Switchable
|
||||
// Assume that a combination of NVIDIA or AMD with Intel means Optimus or AMD Switchable
|
||||
info->primaryGPUIndex = primary;
|
||||
info->isOptimus = hasIntel && IsNvidia(info->gpus[primary].vendorId);
|
||||
info->isOptimus = hasIntel && IsNVIDIA(info->gpus[primary].vendorId);
|
||||
info->isAMDSwitchable = hasIntel && IsAMD(info->gpus[primary].vendorId);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ struct SystemInfo
|
|||
|
||||
SystemInfo(const SystemInfo &other);
|
||||
|
||||
bool hasNVIDIAGPU() const;
|
||||
bool hasIntelGPU() const;
|
||||
bool hasAMDGPU() const;
|
||||
|
||||
std::vector<GPUDeviceInfo> gpus;
|
||||
|
||||
// Index of the primary GPU (the discrete one on dual GPU systems) in `gpus`.
|
||||
|
@ -87,7 +91,7 @@ constexpr VendorID kVendorID_AMD = 0x1002;
|
|||
constexpr VendorID kVendorID_ARM = 0x13B5;
|
||||
constexpr VendorID kVendorID_ImgTec = 0x1010;
|
||||
constexpr VendorID kVendorID_Intel = 0x8086;
|
||||
constexpr VendorID kVendorID_Nvidia = 0x10DE;
|
||||
constexpr VendorID kVendorID_NVIDIA = 0x10DE;
|
||||
constexpr VendorID kVendorID_Qualcomm = 0x5143;
|
||||
|
||||
// Known non-PCI (i.e. Khronos-registered) vendor IDs
|
||||
|
@ -101,7 +105,7 @@ bool IsARM(VendorID vendorId);
|
|||
bool IsImgTec(VendorID vendorId);
|
||||
bool IsIntel(VendorID vendorId);
|
||||
bool IsKazan(VendorID vendorId);
|
||||
bool IsNvidia(VendorID vendorId);
|
||||
bool IsNVIDIA(VendorID vendorId);
|
||||
bool IsQualcomm(VendorID vendorId);
|
||||
bool IsVeriSilicon(VendorID vendorId);
|
||||
bool IsVivante(VendorID vendorId);
|
||||
|
|
|
@ -201,7 +201,7 @@ bool GetSystemInfo(SystemInfo *info)
|
|||
gpu.driverVersion = FormatString("0x%x", properties.driverVersion);
|
||||
gpu.detailedDriverVersion.major = properties.driverVersion;
|
||||
break;
|
||||
case kVendorID_Nvidia:
|
||||
case kVendorID_NVIDIA:
|
||||
gpu.driverVendor = "NVIDIA Corporation";
|
||||
gpu.driverVersion = FormatString("%d.%d.%d.%d", properties.driverVersion >> 22,
|
||||
(properties.driverVersion >> 14) & 0XFF,
|
||||
|
|
|
@ -108,7 +108,7 @@ bool GetSystemInfo(SystemInfo *info)
|
|||
}
|
||||
}
|
||||
|
||||
if (IsNvidia(gpu->vendorId))
|
||||
if (IsNVIDIA(gpu->vendorId))
|
||||
{
|
||||
std::string version;
|
||||
if (GetNvidiaDriverVersionWithXNVCtrl(&version))
|
||||
|
@ -127,7 +127,7 @@ bool GetSystemInfo(SystemInfo *info)
|
|||
if (GetNvidiaDriverVersionWithXNVCtrl(&version))
|
||||
{
|
||||
GPUDeviceInfo nvidiaInfo;
|
||||
nvidiaInfo.vendorId = kVendorID_Nvidia;
|
||||
nvidiaInfo.vendorId = kVendorID_NVIDIA;
|
||||
nvidiaInfo.deviceId = 0;
|
||||
gpu->driverVendor = "Nvidia";
|
||||
gpu->driverVersion = std::move(version);
|
||||
|
|
|
@ -325,7 +325,7 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters ¶ms)
|
|||
// Workaround if any of the GPUs is Nvidia, since we can't detect current GPU.
|
||||
EGLint renderer = params.getRenderer();
|
||||
bool needsWindowSwap =
|
||||
hasNvidiaGPU() && mLastRendererType.valid() &&
|
||||
hasNVIDIAGPU() && mLastRendererType.valid() &&
|
||||
((renderer != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) !=
|
||||
(mLastRendererType.value() != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE));
|
||||
|
||||
|
@ -928,16 +928,10 @@ void ANGLETestBase::checkD3D11SDKLayersMessages()
|
|||
#endif // defined(ANGLE_PLATFORM_WINDOWS)
|
||||
}
|
||||
|
||||
bool ANGLETestBase::hasNvidiaGPU()
|
||||
bool ANGLETestBase::hasNVIDIAGPU() const
|
||||
{
|
||||
for (const angle::GPUDeviceInfo &gpu : ANGLETestEnvironment::GetSystemInfo()->gpus)
|
||||
{
|
||||
if (angle::IsNvidia(gpu.vendorId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
angle::SystemInfo *systemInfo = angle::GetTestSystemInfo();
|
||||
return systemInfo && systemInfo->hasNVIDIAGPU();
|
||||
}
|
||||
|
||||
bool ANGLETestBase::extensionEnabled(const std::string &extName)
|
||||
|
@ -1291,7 +1285,6 @@ Optional<EGLint> ANGLETestBase::mLastRendererType;
|
|||
|
||||
std::unique_ptr<angle::Library> ANGLETestEnvironment::gEGLLibrary;
|
||||
std::unique_ptr<angle::Library> ANGLETestEnvironment::gWGLLibrary;
|
||||
std::unique_ptr<angle::SystemInfo> ANGLETestEnvironment::gSystemInfo;
|
||||
|
||||
void ANGLETestEnvironment::SetUp()
|
||||
{
|
||||
|
@ -1328,19 +1321,6 @@ angle::Library *ANGLETestEnvironment::GetWGLLibrary()
|
|||
return gWGLLibrary.get();
|
||||
}
|
||||
|
||||
angle::SystemInfo *ANGLETestEnvironment::GetSystemInfo()
|
||||
{
|
||||
if (!gSystemInfo)
|
||||
{
|
||||
gSystemInfo = std::make_unique<angle::SystemInfo>();
|
||||
if (!angle::GetSystemInfo(gSystemInfo.get()))
|
||||
{
|
||||
std::cerr << "Failed to get system info." << std::endl;
|
||||
}
|
||||
}
|
||||
return gSystemInfo.get();
|
||||
}
|
||||
|
||||
void ANGLEProcessTestArgs(int *argc, char *argv[])
|
||||
{
|
||||
testing::AddGlobalTestEnvironment(new ANGLETestEnvironment());
|
||||
|
|
|
@ -399,7 +399,7 @@ class ANGLETestBase
|
|||
|
||||
private:
|
||||
void checkD3D11SDKLayersMessages();
|
||||
bool hasNvidiaGPU();
|
||||
bool hasNVIDIAGPU() const;
|
||||
|
||||
void drawQuad(GLuint program,
|
||||
const std::string &positionAttribName,
|
||||
|
@ -469,14 +469,10 @@ class ANGLETestEnvironment : public testing::Environment
|
|||
static angle::Library *GetEGLLibrary();
|
||||
static angle::Library *GetWGLLibrary();
|
||||
|
||||
static angle::SystemInfo *GetSystemInfo();
|
||||
|
||||
private:
|
||||
// For loading entry points.
|
||||
static std::unique_ptr<angle::Library> gEGLLibrary;
|
||||
static std::unique_ptr<angle::Library> gWGLLibrary;
|
||||
|
||||
static std::unique_ptr<angle::SystemInfo> gSystemInfo;
|
||||
};
|
||||
|
||||
// This base fixture loads the EGL entry points.
|
||||
|
|
|
@ -28,17 +28,6 @@ namespace angle
|
|||
{
|
||||
namespace
|
||||
{
|
||||
SystemInfo *GetTestSystemInfo()
|
||||
{
|
||||
static SystemInfo *sSystemInfo = nullptr;
|
||||
if (sSystemInfo == nullptr)
|
||||
{
|
||||
sSystemInfo = new SystemInfo;
|
||||
GetSystemInfo(sSystemInfo);
|
||||
}
|
||||
return sSystemInfo;
|
||||
}
|
||||
|
||||
bool IsANGLEConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
|
||||
{
|
||||
std::unique_ptr<angle::Library> eglLibrary;
|
||||
|
@ -77,6 +66,20 @@ bool IsNativeConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow
|
|||
}
|
||||
} // namespace
|
||||
|
||||
SystemInfo *GetTestSystemInfo()
|
||||
{
|
||||
static SystemInfo *sSystemInfo = nullptr;
|
||||
if (sSystemInfo == nullptr)
|
||||
{
|
||||
sSystemInfo = new SystemInfo;
|
||||
if (!GetSystemInfo(sSystemInfo))
|
||||
{
|
||||
std::cerr << "Warning: incomplete system info collection.\n";
|
||||
}
|
||||
}
|
||||
return sSystemInfo;
|
||||
}
|
||||
|
||||
bool IsAndroid()
|
||||
{
|
||||
#if defined(ANGLE_PLATFORM_ANDROID)
|
||||
|
@ -202,13 +205,13 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
|||
}
|
||||
|
||||
// Win ES emulation is currently only supported on NVIDIA.
|
||||
return vendorID == kVendorID_Nvidia;
|
||||
return IsNVIDIA(vendorID);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case GLESDriverType::SystemWGL:
|
||||
// AMD does not support the ES compatibility extensions.
|
||||
return vendorID != kVendorID_AMD;
|
||||
return IsAMD(vendorID);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -216,7 +219,7 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
|||
|
||||
if (IsOSX())
|
||||
{
|
||||
// Currently we only support the OpenGL back-end on OSX.
|
||||
// We do not support non-ANGLE bindings on OSX.
|
||||
if (param.driver != GLESDriverType::AngleEGL)
|
||||
{
|
||||
return false;
|
||||
|
@ -228,23 +231,25 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
|||
return false;
|
||||
}
|
||||
|
||||
// Currently we only support the OpenGL back-end on OSX.
|
||||
return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE);
|
||||
}
|
||||
|
||||
if (IsFuchsia())
|
||||
{
|
||||
// Currently we only support the Vulkan back-end on Fuchsia.
|
||||
// We do not support non-ANGLE bindings on Fuchsia.
|
||||
if (param.driver != GLESDriverType::AngleEGL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Currently we only support the Vulkan back-end on Fuchsia.
|
||||
return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE);
|
||||
}
|
||||
|
||||
if (IsOzone())
|
||||
{
|
||||
// Currently we only support the GLES back-end on Ozone.
|
||||
// We do not support non-ANGLE bindings on Ozone.
|
||||
if (param.driver != GLESDriverType::AngleEGL)
|
||||
return false;
|
||||
|
||||
|
@ -252,17 +257,19 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
|||
if (param.majorVersion > 2)
|
||||
return false;
|
||||
|
||||
// Currently we only support the GLES back-end on Ozone.
|
||||
return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE);
|
||||
}
|
||||
|
||||
if (IsLinux())
|
||||
{
|
||||
// Currently we support the OpenGL and Vulkan back-ends on Linux.
|
||||
// We do not support non-ANGLE bindings on Linux.
|
||||
if (param.driver != GLESDriverType::AngleEGL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Currently we support the OpenGL and Vulkan back-ends on Linux.
|
||||
switch (param.getRenderer())
|
||||
{
|
||||
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
|
||||
|
@ -276,7 +283,7 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
|||
|
||||
if (IsAndroid())
|
||||
{
|
||||
// Currently we support the GLES and Vulkan back-ends on Linux.
|
||||
// We do not support non-ANGLE bindings on Android.
|
||||
if (param.driver != GLESDriverType::AngleEGL)
|
||||
{
|
||||
return false;
|
||||
|
@ -289,6 +296,7 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
|||
return false;
|
||||
}
|
||||
|
||||
// Currently we support the GLES and Vulkan back-ends on Android.
|
||||
switch (param.getRenderer())
|
||||
{
|
||||
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
|
||||
|
|
|
@ -110,6 +110,8 @@ bool IsConfigWhitelisted(const SystemInfo &systemInfo, const PlatformParameters
|
|||
// Determines if a config is supported by trying to initialize it. Does not require SystemInfo.
|
||||
bool IsConfigSupported(const PlatformParameters ¶m);
|
||||
|
||||
// Returns shared test system information. Can be used globally in the tests.
|
||||
SystemInfo *GetTestSystemInfo();
|
||||
} // namespace angle
|
||||
|
||||
#endif // ANGLE_TEST_INSTANTIATE_H_
|
||||
|
|
|
@ -34,7 +34,7 @@ std::string VendorName(VendorID vendor)
|
|||
return "AMD";
|
||||
case kVendorID_Intel:
|
||||
return "Intel";
|
||||
case kVendorID_Nvidia:
|
||||
case kVendorID_NVIDIA:
|
||||
return "Nvidia";
|
||||
case kVendorID_Qualcomm:
|
||||
return "Qualcomm";
|
||||
|
|
Загрузка…
Ссылка в новой задаче