Hash :
a878e814
Author :
Date :
2021-04-11T15:04:19
Metal: Distinguish Metal backend from OpenGL's Metal driver On macOS 11+ OpenGL is implemented on top of Metal internally. This CL changes ANGLE's Metal backend's renderer string to better differentiate it from the above OpenGL renderer. Bug: angleproject:5841 Change-Id: I0d5466594e385cb663d537db034c82b006b6e907 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2820179 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@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
//
// Copyright 2020 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.
#include "angle_test_platform.h"
#include "common/platform.h"
#include "gpu_info_util/SystemInfo.h"
#if defined(ANGLE_PLATFORM_WINDOWS)
# include <VersionHelpers.h>
#endif // defined(ANGLE_PLATFORM_WINDOWS)
using namespace angle;
bool IsAdreno()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Adreno") != std::string::npos);
}
bool IsD3D11()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D11 vs_5_0") != std::string::npos);
}
bool IsD3D11_FL93()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D11 vs_4_0_") != std::string::npos);
}
bool IsD3D9()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("Direct3D9") != std::string::npos);
}
bool IsD3DSM3()
{
return IsD3D9() || IsD3D11_FL93();
}
bool IsDesktopOpenGL()
{
return IsOpenGL() && !IsOpenGLES();
}
bool IsOpenGLES()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("OpenGL ES") != std::string::npos);
}
bool IsOpenGL()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("OpenGL") != std::string::npos);
}
bool IsNULL()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
return (rendererString.find("NULL") != std::string::npos);
}
bool IsVulkan()
{
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
std::string rendererString(renderer);
return (rendererString.find("Vulkan") != std::string::npos);
}
bool IsMetal()
{
const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
std::string rendererString(renderer);
return (rendererString.find("ANGLE Metal") != std::string::npos);
}
bool IsD3D()
{
return IsD3D9() || IsD3D11();
}
bool IsDebug()
{
#if !defined(NDEBUG)
return true;
#else
return false;
#endif
}
bool IsRelease()
{
return !IsDebug();
}
bool EnsureGLExtensionEnabled(const std::string &extName)
{
if (IsGLExtensionEnabled("GL_ANGLE_request_extension") && IsGLExtensionRequestable(extName))
{
glRequestExtensionANGLE(extName.c_str());
}
return IsGLExtensionEnabled(extName);
}
bool IsEGLClientExtensionEnabled(const std::string &extName)
{
return CheckExtensionExists(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS), extName);
}
bool IsEGLDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName)
{
return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName);
}
bool IsEGLDisplayExtensionEnabled(EGLDisplay display, const std::string &extName)
{
return CheckExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName);
}
bool IsGLExtensionEnabled(const std::string &extName)
{
return CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),
extName);
}
bool IsGLExtensionRequestable(const std::string &extName)
{
return CheckExtensionExists(
reinterpret_cast<const char *>(glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE)), extName);
}