Path: blob/main_old/src/tests/test_utils/angle_test_platform.cpp
1693 views
//1// Copyright 2020 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.45#include "angle_test_platform.h"67#include "common/platform.h"8#include "gpu_info_util/SystemInfo.h"910#if defined(ANGLE_PLATFORM_WINDOWS)11# include <VersionHelpers.h>12#endif // defined(ANGLE_PLATFORM_WINDOWS)1314using namespace angle;1516bool IsAdreno()17{18std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));19return (rendererString.find("Adreno") != std::string::npos);20}2122bool IsD3D11()23{24std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));25return (rendererString.find("Direct3D11 vs_5_0") != std::string::npos);26}2728bool IsD3D11_FL93()29{30std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));31return (rendererString.find("Direct3D11 vs_4_0_") != std::string::npos);32}3334bool IsD3D9()35{36std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));37return (rendererString.find("Direct3D9") != std::string::npos);38}3940bool IsD3DSM3()41{42return IsD3D9() || IsD3D11_FL93();43}4445bool IsDesktopOpenGL()46{47return IsOpenGL() && !IsOpenGLES();48}4950bool IsOpenGLES()51{52std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));53return (rendererString.find("OpenGL ES") != std::string::npos);54}5556bool IsOpenGL()57{58std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));59return (rendererString.find("OpenGL") != std::string::npos);60}6162bool IsNULL()63{64std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));65return (rendererString.find("NULL") != std::string::npos);66}6768bool IsVulkan()69{70const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));71std::string rendererString(renderer);72return (rendererString.find("Vulkan") != std::string::npos);73}7475bool IsMetal()76{77const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));78std::string rendererString(renderer);79return (rendererString.find("ANGLE Metal") != std::string::npos);80}8182bool IsD3D()83{84return IsD3D9() || IsD3D11();85}8687bool IsDebug()88{89#if !defined(NDEBUG)90return true;91#else92return false;93#endif94}9596bool IsRelease()97{98return !IsDebug();99}100101bool EnsureGLExtensionEnabled(const std::string &extName)102{103if (IsGLExtensionEnabled("GL_ANGLE_request_extension") && IsGLExtensionRequestable(extName))104{105glRequestExtensionANGLE(extName.c_str());106}107108return IsGLExtensionEnabled(extName);109}110111bool IsEGLClientExtensionEnabled(const std::string &extName)112{113return CheckExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName);114}115116bool IsEGLDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName)117{118return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName);119}120121bool IsEGLDisplayExtensionEnabled(EGLDisplay display, const std::string &extName)122{123return CheckExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName);124}125126bool IsGLExtensionEnabled(const std::string &extName)127{128return CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),129extName);130}131132bool IsGLExtensionRequestable(const std::string &extName)133{134return CheckExtensionExists(135reinterpret_cast<const char *>(glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE)), extName);136}137138139