Hash :
25390156
Author :
Date :
2025-08-21T00:13:19
Suppress unsafe buffers on a file-by-file basis in src/ [1 of N] In this CL, we suppress many files but stop short of actually enabling the warning by not removing the line from the unsafe_buffers_paths.txt file. That will happen in a follow-on CL, along with resolving any stragglers missed here. This is mostly a manual change so as to familiarize myself with the kinds of issues faced by the Angle codebase when applying buffer safety warnings. -- Re-generate affected hashes. -- Clang-format applied to all changed files. -- Add a few missing .reserve() calls to vectors as noticed. -- Fix some mismatches between file names and header comments. -- Be more consistent with header comment format (blank lines and trailing //-only lines when a filename comment adjoins license boilerplate). Bug: b/436880895 Change-Id: I3bde5cc2059acbe8345057289214f1a26f1c34aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6869022 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@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 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 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862
//
// Copyright 2014 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.
//
// angle_test_instantiate.cpp: Adds support for filtering parameterized
// tests by platform, so we skip unsupported configs.
#ifdef UNSAFE_BUFFERS_BUILD
# pragma allow_unsafe_libc_calls
#endif
#include "test_utils/angle_test_instantiate.h"
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include "angle_gl.h"
#include "common/base/anglebase/no_destructor.h"
#include "common/debug.h"
#include "common/platform.h"
#include "common/system_utils.h"
#include "gpu_info_util/SystemInfo.h"
#include "test_utils/angle_test_configs.h"
#include "util/EGLWindow.h"
#include "util/OSWindow.h"
#include "util/test_utils.h"
#if defined(ANGLE_PLATFORM_WINDOWS)
# include <VersionHelpers.h>
# include "util/windows/WGLWindow.h"
#endif // defined(ANGLE_PLATFORM_WINDOWS)
#if defined(ANGLE_PLATFORM_APPLE)
# include "test_utils/angle_test_instantiate_apple.h"
#endif
namespace angle
{
namespace
{
bool IsEGLConfigSupported(const PlatformParameters ¶m,
OSWindow *osWindow,
const char *eglLibraryName)
{
std::unique_ptr<angle::Library> eglLibrary;
#if defined(ANGLE_USE_UTIL_LOADER)
eglLibrary.reset(
angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ModuleDir));
#endif
EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams;
bool result =
eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::AngleEGL,
param.eglParameters, configParams);
eglWindow->destroyGL();
EGLWindow::Delete(&eglWindow);
return result;
}
bool IsAngleEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
{
return IsEGLConfigSupported(param, osWindow, ANGLE_EGL_LIBRARY_NAME);
}
bool IsAngleVulkanSecondariesEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
{
return IsEGLConfigSupported(param, osWindow, ANGLE_VULKAN_SECONDARIES_EGL_LIBRARY_NAME);
}
bool IsSystemWGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
{
#if defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER)
std::unique_ptr<angle::Library> openglLibrary(
angle::OpenSharedLibrary("opengl32", angle::SearchType::SystemDir));
WGLWindow *wglWindow = WGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams;
bool result =
wglWindow->initializeGL(osWindow, openglLibrary.get(), angle::GLESDriverType::SystemWGL,
param.eglParameters, configParams);
wglWindow->destroyGL();
WGLWindow::Delete(&wglWindow);
return result;
#else
return false;
#endif // defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER)
}
bool IsSystemEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
{
#if defined(ANGLE_USE_UTIL_LOADER)
std::unique_ptr<angle::Library> eglLibrary;
eglLibrary.reset(OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension(),
SearchType::SystemDir));
EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams;
bool result =
eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::SystemEGL,
param.eglParameters, configParams);
eglWindow->destroyGL();
EGLWindow::Delete(&eglWindow);
return result;
#else
return false;
#endif
}
bool IsZinkEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
{
return IsEGLConfigSupported(param, osWindow, ANGLE_MESA_EGL_LIBRARY_NAME);
}
bool IsAndroidDevice(const std::string &deviceName)
{
if (!IsAndroid())
{
return false;
}
SystemInfo *systemInfo = GetTestSystemInfo();
if (systemInfo->machineModelName == deviceName)
{
return true;
}
return false;
}
bool IsAndroidSdkLevelOrNewer(int level)
{
if (!IsAndroid())
{
return false;
}
SystemInfo *systemInfo = GetTestSystemInfo();
if (systemInfo->androidSdkLevel >= level)
{
return true;
}
return false;
}
bool IsAndroid9OrNewer()
{
return IsAndroidSdkLevelOrNewer(28);
}
GPUDeviceInfo *GetActiveGPUDeviceInfo()
{
SystemInfo *systemInfo = GetTestSystemInfo();
// Unfortunately sometimes GPU info collection can fail.
if (systemInfo->gpus.empty())
{
return nullptr;
}
return &systemInfo->gpus[systemInfo->activeGPUIndex];
}
bool HasSystemVendorID(VendorID vendorID)
{
GPUDeviceInfo *gpuInfo = GetActiveGPUDeviceInfo();
return gpuInfo && gpuInfo->vendorId == vendorID;
}
bool HasSystemDeviceID(VendorID vendorID, DeviceID deviceID)
{
GPUDeviceInfo *gpuInfo = GetActiveGPUDeviceInfo();
return gpuInfo && gpuInfo->vendorId == vendorID && gpuInfo->deviceId == deviceID;
}
using ParamAvailabilityCache = std::map<PlatformParameters, bool>;
ParamAvailabilityCache &GetAvailabilityCache()
{
static angle::base::NoDestructor<std::unique_ptr<ParamAvailabilityCache>>
sParamAvailabilityCache(new ParamAvailabilityCache());
return **sParamAvailabilityCache;
}
constexpr size_t kMaxConfigNameLen = 100;
std::array<char, kMaxConfigNameLen> gSelectedConfig;
} // namespace
bool gEnableANGLEPerTestCaptureLabel = false;
#if defined(ANGLE_TEST_ENABLE_RENDERDOC_CAPTURE)
bool gEnableRenderDocCapture = true;
#else
bool gEnableRenderDocCapture = false;
#endif
bool IsConfigSelected()
{
return gSelectedConfig[0] != 0;
}
#if !defined(ANGLE_PLATFORM_APPLE)
// For Apple platform, see angle_test_instantiate_apple.mm
bool IsMetalTextureSwizzleAvailable()
{
return false;
}
#endif
SystemInfo *GetTestSystemInfo()
{
static SystemInfo *sSystemInfo = nullptr;
if (sSystemInfo == nullptr)
{
sSystemInfo = new SystemInfo;
if (!GetSystemInfo(sSystemInfo))
{
std::cerr << "Warning: incomplete system info collection.\n";
}
// On dual-GPU Macs we want the active GPU to always appear to be the
// high-performance GPU for tests.
// We can call the generic GPU info collector which selects the
// non-Intel GPU as the active one on dual-GPU machines.
if (IsMac())
{
GetDualGPUInfo(sSystemInfo);
}
// Print complete system info when available.
// Seems to trip up Android test expectation parsing.
// Also don't print info when a config is selected to prevent test spam.
if (!IsAndroid() && !IsConfigSelected())
{
PrintSystemInfo(*sSystemInfo);
}
}
return sSystemInfo;
}
bool IsARM64()
{
// _M_ARM64 is Windows-specific, while __aarch64__ is for other platforms.
#if defined(_M_ARM64) || defined(__aarch64__)
return true;
#else
return false;
#endif
}
bool IsOzone()
{
#if defined(USE_OZONE) && (defined(USE_X11) || defined(ANGLE_USE_VULKAN_DISPLAY))
// We do not have a proper support for Ozone/Linux yet. Still, we need to figure out how to
// properly initialize tests and differentiate between X11 and Wayland. Probably, passing a
// command line argument could be sufficient. At the moment, run tests only for X11 backend
// as we don't have Wayland support in Angle. Yes, this is a bit weird to return false, but
// it makes it possible to continue angle tests with X11 regardless of the Chromium config
// for linux, which is use_x11 && use_ozone. Also, IsOzone is a bit vague now. It was only
// expected that angle could run with ozone/drm backend for ChromeOS. And returning true
// for desktop Linux when USE_OZONE && USE_X11 are both defined results in incorrect tests'
// expectations. We should also rework them and make IsOzone less vague.
//
// TODO(crbug.com/angleproject/4977): make it possible to switch between X11 and Wayland on
// Ozone/Linux builds. Probably, it's possible to identify the WAYLAND backend by checking
// the WAYLAND_DISPLAY or XDG_SESSION_TYPE env vars. And also make the IsOzone method less
// vague (read the comment above).
return false;
#elif defined(USE_OZONE)
return true;
#else
return false;
#endif
}
bool IsNexus5X()
{
return IsAndroidDevice("Nexus 5X");
}
bool IsNexus9()
{
return IsAndroidDevice("Nexus 9");
}
bool IsPixelXL()
{
return IsAndroidDevice("Pixel XL");
}
bool IsPixel2()
{
return IsAndroidDevice("Pixel 2");
}
bool IsPixel2XL()
{
return IsAndroidDevice("Pixel 2 XL");
}
bool IsPixel4()
{
return IsAndroidDevice("Pixel 4");
}
bool IsPixel4XL()
{
return IsAndroidDevice("Pixel 4 XL");
}
bool IsPixel6()
{
return IsAndroidDevice("Pixel 6");
}
bool IsGalaxyS22()
{
return IsAndroidDevice("SM-S901B");
}
bool IsNVIDIAShield()
{
return IsAndroidDevice("SHIELD Android TV");
}
bool IsAndroid14OrNewer()
{
return IsAndroidSdkLevelOrNewer(34);
}
bool IsIntel()
{
return HasSystemVendorID(kVendorID_Intel);
}
bool IsIntelUHD630Mobile()
{
return HasSystemDeviceID(kVendorID_Intel, kDeviceID_UHD630Mobile);
}
bool IsAMD()
{
return HasSystemVendorID(kVendorID_AMD);
}
bool IsAppleGPU()
{
return HasSystemVendorID(kVendorID_Apple);
}
bool IsARM()
{
return HasSystemVendorID(kVendorID_ARM);
}
bool IsSwiftshaderDevice()
{
return HasSystemDeviceID(kVendorID_GOOGLE, kDeviceID_Swiftshader);
}
bool IsLavapipeDevice()
{
return HasSystemDeviceID(kVendorID_Mesa, kDeviceID_Lavapipe);
}
bool SwiftshaderTestsEnabled()
{
#if defined(ANGLE_ENABLE_SWIFTSHADER)
return true;
#else
return false;
#endif
}
bool IsNVIDIA()
{
#if defined(ANGLE_PLATFORM_ANDROID)
// NVIDIA Shield cannot detect vendor ID (http://anglebug.com/42262205)
if (IsNVIDIAShield())
{
return true;
}
#endif
return HasSystemVendorID(kVendorID_NVIDIA);
}
bool IsQualcomm()
{
return HasSystemVendorID(kVendorID_Qualcomm) || HasSystemVendorID(kVendorID_Qualcomm_DXGI) ||
IsNexus5X() || IsNexus9() || IsPixelXL() || IsPixel2() || IsPixel2XL() || IsPixel4() ||
IsPixel4XL();
}
bool HasMesa()
{
#if defined(ANGLE_HAS_MESA)
return true;
#else
return false;
#endif // defined(ANGLE_HAS_MESA)
}
bool IsConfigAllowlisted(const SystemInfo &systemInfo, const PlatformParameters ¶m)
{
VendorID vendorID =
systemInfo.gpus.empty() ? 0 : systemInfo.gpus[systemInfo.activeGPUIndex].vendorId;
// We support the default and null back-ends on every platform.
if (param.driver == GLESDriverType::AngleEGL)
{
if (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE)
return true;
if (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)
return true;
}
if (param.isSwiftshader() && !SwiftshaderTestsEnabled())
{
return false;
}
if (param.isSwiftshader() || IsSwiftshaderDevice())
{
// TODO: http://crbug.com/swiftshader/145
// Swiftshader does not currently have all the robustness features
// we need for ANGLE. In particular, it is unable to detect and recover
// from infinitely looping shaders. That bug is the tracker for fixing
// that and when resolved we can remove the following code.
// This test will disable tests marked with the config WithRobustness
// when run with the swiftshader Vulkan driver and on Android.
if (param.eglParameters.robustness == EGL_TRUE)
{
return false;
}
}
if (param.driver == GLESDriverType::AngleVulkanSecondariesEGL)
{
if (param.getRenderer() != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
{
return false;
}
if (IsAndroid() &&
param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE)
{
return false;
}
return true;
}
if (IsWindows())
{
switch (param.driver)
{
case GLESDriverType::AngleEGL:
switch (param.getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
return true;
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
// Note we disable AMD OpenGL testing on Windows due to using a very old and
// outdated card with many driver bugs. See http://anglebug.com/42263687
return !IsAMD();
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
if (IsARM64())
{
return param.getDeviceType() ==
EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE;
}
return true;
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
// ES 3.1+ back-end is not supported properly.
if (param.eglParameters.majorVersion == 3 &&
param.eglParameters.minorVersion > 0)
{
return false;
}
// Win ES emulation is currently only supported on NVIDIA.
return IsNVIDIA(vendorID);
case EGL_PLATFORM_ANGLE_TYPE_WEBGPU_ANGLE:
return true;
default:
return false;
}
case GLESDriverType::SystemWGL:
// AMD does not support the ES compatibility extensions.
return !IsAMD(vendorID);
default:
return false;
}
}
#if defined(ANGLE_PLATFORM_APPLE)
if (IsMac() || IsIOS())
{
// We do not support non-ANGLE bindings on OSX.
if (param.driver != GLESDriverType::AngleEGL)
{
return false;
}
switch (param.getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
if (IsIOS())
{
// OpenGL backend has been deprecated on iOS.
return false;
}
// ES 3.1+ back-end is not supported properly.
if (param.majorVersion == 3 && param.minorVersion > 0)
{
return false;
}
return true;
case EGL_PLATFORM_ANGLE_TYPE_WEBGPU_ANGLE:
return true;
case EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE:
if (!IsMetalRendererAvailable())
{
return false;
}
return true;
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
// OSX does not support native vulkan
return param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE;
default:
return false;
}
}
#endif // #if defined(ANGLE_PLATFORM_APPLE)
if (IsFuchsia())
{
// We do not support non-ANGLE bindings on Fuchsia.
if (param.driver != GLESDriverType::AngleEGL)
{
return false;
}
// ES 3 configs do not work properly on Fuchsia ARM.
// TODO(anglebug.com/42262979): Investigate missing features.
if (param.majorVersion > 2 && IsARM())
return false;
// Loading swiftshader is not brought up on Fuchsia.
// TODO(anglebug.com/42262980): Support loading swiftshader vulkan ICD.
if (param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE)
return false;
// Currently we only support the Vulkan back-end on Fuchsia.
return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE);
}
if (IsOzone())
{
// We do not support non-ANGLE bindings on Ozone.
if (param.driver != GLESDriverType::AngleEGL)
return false;
// ES 3 configs do not work properly on Ozone.
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() || IsAndroid())
{
// We do not support WGL bindings on Linux/Android.
switch (param.driver)
{
case GLESDriverType::SystemWGL:
return false;
case GLESDriverType::ZinkEGL:
return HasMesa();
default:
break;
}
}
if (IsLinux())
{
ASSERT(param.driver == GLESDriverType::AngleEGL ||
param.driver == GLESDriverType::SystemEGL);
// Currently we support the OpenGL, Vulkan and WebGPU back-ends on Linux.
switch (param.getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_WEBGPU_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
return true;
default:
return false;
}
}
if (IsAndroid())
{
ASSERT(param.driver == GLESDriverType::AngleEGL ||
param.driver == GLESDriverType::SystemEGL);
// Nexus Android devices don't support backing 3.2 contexts
if (param.eglParameters.majorVersion == 3 && param.eglParameters.minorVersion == 2)
{
if (IsNexus5X())
{
return false;
}
}
// Currently we support the GLES and Vulkan back-ends on Android.
switch (param.getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
return true;
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
// Swiftshader's vulkan frontend doesn't build on Android.
if (param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE)
{
return false;
}
if (!IsAndroid9OrNewer())
{
return false;
}
return true;
default:
return false;
}
}
// Unknown platform.
return false;
}
bool IsConfigSupported(const PlatformParameters ¶m)
{
OSWindow *osWindow = OSWindow::New();
bool result = false;
if (osWindow->initialize("CONFIG_TESTER", 1, 1))
{
switch (param.driver)
{
case GLESDriverType::AngleEGL:
result = IsAngleEGLConfigSupported(param, osWindow);
break;
case GLESDriverType::AngleVulkanSecondariesEGL:
result = IsAngleVulkanSecondariesEGLConfigSupported(param, osWindow);
break;
case GLESDriverType::SystemEGL:
result = IsSystemEGLConfigSupported(param, osWindow);
break;
case GLESDriverType::SystemWGL:
result = IsSystemWGLConfigSupported(param, osWindow);
break;
case GLESDriverType::ZinkEGL:
result = IsZinkEGLConfigSupported(param, osWindow);
break;
}
osWindow->destroy();
}
OSWindow::Delete(&osWindow);
return result;
}
bool IsPlatformAvailable(const PlatformParameters ¶m)
{
// Disable "null" device when not on ANGLE or in D3D9.
if (param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE)
{
if (!IsANGLE(param.driver))
return false;
if (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
return false;
}
switch (param.getRenderer())
{
case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
break;
case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
#if !defined(ANGLE_ENABLE_D3D9)
return false;
#else
break;
#endif
case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
#if !defined(ANGLE_ENABLE_D3D11)
return false;
#else
break;
#endif
case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
#if !defined(ANGLE_ENABLE_OPENGL)
return false;
#else
break;
#endif
case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
#if !defined(ANGLE_ENABLE_VULKAN)
return false;
#else
break;
#endif
case EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE:
#if !defined(ANGLE_ENABLE_METAL)
return false;
#else
break;
#endif
case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE:
#if !defined(ANGLE_ENABLE_NULL)
return false;
#else
break;
#endif
case EGL_PLATFORM_ANGLE_TYPE_WEBGPU_ANGLE:
#if !defined(ANGLE_ENABLE_WGPU)
return false;
#else
break;
#endif
default:
std::cout << "Unknown test platform: " << param << std::endl;
return false;
}
bool result = false;
auto iter = GetAvailabilityCache().find(param);
if (iter != GetAvailabilityCache().end())
{
result = iter->second;
}
else
{
if (IsConfigSelected())
{
std::stringstream strstr;
strstr << param;
if (strstr.str() == std::string(gSelectedConfig.data()))
{
result = true;
}
}
else
{
const SystemInfo *systemInfo = GetTestSystemInfo();
if (systemInfo)
{
result = IsConfigAllowlisted(*systemInfo, param);
}
else
{
result = IsConfigSupported(param);
}
}
GetAvailabilityCache()[param] = result;
// Enable this unconditionally to print available platforms.
if (IsConfigSelected())
{
if (result)
{
std::cout << "Test Config: " << param << "\n";
}
}
else if (!result)
{
std::cout << "Skipping tests using configuration " << param
<< " because it is not available.\n";
}
}
return result;
}
std::vector<std::string> GetAvailableTestPlatformNames()
{
std::vector<std::string> platformNames;
for (const auto &iter : GetAvailabilityCache())
{
if (iter.second)
{
std::stringstream strstr;
strstr << iter.first;
platformNames.push_back(strstr.str());
}
}
// Keep the list sorted.
std::sort(platformNames.begin(), platformNames.end());
return platformNames;
}
void SetSelectedConfig(const char *selectedConfig)
{
gSelectedConfig.fill(0);
strncpy(gSelectedConfig.data(), selectedConfig, kMaxConfigNameLen - 1);
}
GLESDriverType GetDriverTypeFromString(const char *driverName, GLESDriverType defaultDriverType)
{
if (!driverName)
{
return defaultDriverType;
}
if (strcmp(driverName, "angle") == 0)
{
return GLESDriverType::AngleEGL;
}
if (strcmp(driverName, "angle-vulkan-secondaries") == 0)
{
return GLESDriverType::AngleVulkanSecondariesEGL;
}
if (strcmp(driverName, "zink") == 0)
{
return GLESDriverType::ZinkEGL;
}
if (strcmp(driverName, "native") == 0 || strcmp(driverName, "system") == 0)
{
if (IsWindows())
{
return GLESDriverType::SystemWGL;
}
else
{
return GLESDriverType::SystemEGL;
}
}
printf("Unknown driver type: %s\n", driverName);
exit(EXIT_FAILURE);
}
} // namespace angle