Metal: Support compiling on iOS without EAGL

Makes EAGL and CGL compilation exclusive to each other. Catalyst would
compile with both on ARM64, but only use EAGL.

Remove use of GLSL generation in MSL. Generating GLSL for MSL
compute and geometry shaders do not make sense.

Remove compilation of RewriteRowMajorMatrices for Metal.
It was removed from Metal in:
  b23bf47c9e
  Reland "Metal: rewrite default uniforms and uniform blocks"

Remove use of ANGLE_ENABLE_APPLE_WORKAROUNDS and gn variable
angle_enable_apple_translator_workarounds. The workarounds are just
unconditional business-as-usual implementation of ANGLE when ANGLE is
compile for PLATFORM_APPLE.

Fixed: angleproject:8129
Change-Id: I3af249708803fba816e2a7c92c35dddb84ce6946
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4428875
Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Reviewed-by: Kyle Piddington <kpiddington@apple.com>
Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Reviewed-by: Dan Glastonbury <djg@apple.com>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
This commit is contained in:
Kimmo Kinnunen
2023-04-17 13:55:09 +03:00
committed by Angle LUCI CQ
parent 3e74b09e8b
commit 20b6624a88
25 changed files with 37 additions and 169 deletions

View File

@@ -678,11 +678,10 @@ template("translator_lib") {
_needs_glsl_and_vulkan_base = true
sources += angle_translator_glsl_sources
defines += [ "ANGLE_ENABLE_GLSL" ]
}
if (angle_enable_apple_translator_workarounds) {
sources += angle_translator_apple_sources
defines += [ "ANGLE_ENABLE_APPLE_WORKAROUNDS" ]
if (is_apple) {
sources += angle_translator_glsl_apple_sources
}
}
if (angle_enable_hlsl || use_fuzzing_engine) {

View File

@@ -287,8 +287,7 @@ declare_args() {
angle_enable_cgl = angle_enable_gl && !angle_enable_eagl && is_apple
angle_enable_apple_translator_workarounds =
is_apple &&
(angle_enable_glsl || angle_enable_metal || use_fuzzing_engine)
is_apple && (angle_enable_glsl || use_fuzzing_engine)
angle_has_histograms = angle_has_build

View File

@@ -170,13 +170,6 @@ struct FeaturesMtl : FeatureSetBase
&members,
};
FeatureInfo rewriteRowMajorMatrices = {
"rewriteRowMajorMatrices",
FeatureCategory::MetalFeatures,
"Rewrite row major matrices in shaders as column major.",
&members,
};
FeatureInfo intelExplicitBoolCastWorkaround = {
"intelExplicitBoolCastWorkaround",
FeatureCategory::MetalWorkarounds,

View File

@@ -157,13 +157,6 @@
"Turn this on to allow transform feedback in Metal using a 2-pass VS for GLES3."
]
},
{
"name": "rewrite_row_major_matrices",
"category": "Features",
"description": [
"Rewrite row major matrices in shaders as column major."
]
},
{
"name": "intel_explicit_bool_cast_workaround",
"category": "Workarounds",

View File

@@ -4,7 +4,7 @@
"include/platform/FeaturesGL_autogen.h":
"331b1660b3982f6540e362764df26021",
"include/platform/FeaturesMtl_autogen.h":
"8ac8af62087b103ce3744d55c18a41f5",
"4c7e4b74b49b88542820b8ab76b131ca",
"include/platform/FeaturesVk_autogen.h":
"38ce2b494fac31f1b866d75be8330bea",
"include/platform/FrontendFeatures_autogen.h":
@@ -18,7 +18,7 @@
"include/platform/gl_features.json":
"cef92e7ede4c824b8bae37123401d354",
"include/platform/mtl_features.json":
"e859b9d81f83924af68a3154ff86463e",
"2472b8a7eb65fc243fc9380b8a1d8dcd",
"include/platform/vk_features.json":
"bc04d0a45f9ecb1bec30aef49d73b583",
"util/angle_features_autogen.cpp":

View File

@@ -192,7 +192,6 @@ IGNORED_INCLUDES = {
b'libANGLE/renderer/d3d/DeviceD3D.h',
b'libANGLE/renderer/d3d/DisplayD3D.h',
b'libANGLE/renderer/d3d/RenderTargetD3D.h',
b'libANGLE/renderer/gl/apple/DisplayApple_api.h',
b'libANGLE/renderer/gl/cgl/DisplayCGL.h',
b'libANGLE/renderer/gl/eagl/DisplayEAGL.h',
b'libANGLE/renderer/gl/egl/android/DisplayAndroid.h',

View File

@@ -269,7 +269,7 @@ angle_translator_glsl_sources = [
"src/compiler/translator/tree_ops/gl/RewriteRepeatedAssignToSwizzled.cpp",
"src/compiler/translator/tree_ops/gl/UseInterfaceBlockFields.cpp",
]
angle_translator_apple_sources = [
angle_translator_glsl_apple_sources = [
"src/compiler/translator/tree_ops/apple/AddAndTrueToLoopCondition.cpp",
"src/compiler/translator/tree_ops/apple/RewriteDoWhile.cpp",
"src/compiler/translator/tree_ops/apple/RewriteRowMajorMatrices.cpp",

View File

@@ -8,10 +8,8 @@
#include "angle_gl.h"
#include "common/utilities.h"
#include "compiler/translator/BuiltinsWorkaroundGLSL.h"
#include "compiler/translator/DriverUniformMetal.h"
#include "compiler/translator/ImmutableStringBuilder.h"
#include "compiler/translator/OutputGLSLBase.h"
#include "compiler/translator/StaticType.h"
#include "compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.h"
#include "compiler/translator/TranslatorMetalDirect/AstHelpers.h"
@@ -43,7 +41,6 @@
#include "compiler/translator/tree_ops/RewriteDfdy.h"
#include "compiler/translator/tree_ops/RewriteStructSamplers.h"
#include "compiler/translator/tree_ops/SeparateStructFromUniformDeclarations.h"
#include "compiler/translator/tree_ops/apple/RewriteRowMajorMatrices.h"
#include "compiler/translator/tree_util/BuiltIn.h"
#include "compiler/translator/tree_util/DriverUniform.h"
#include "compiler/translator/tree_util/FindFunction.h"
@@ -1344,17 +1341,6 @@ bool TranslatorMetalDirect::translateImpl(TInfoSinkBase &sink,
return false;
}
}
else if (getShaderType() == GL_GEOMETRY_SHADER)
{
WriteGeometryShaderLayoutQualifiers(
sink, getGeometryShaderInputPrimitiveType(), getGeometryShaderInvocations(),
getGeometryShaderOutputPrimitiveType(), getGeometryShaderMaxVertices());
}
else
{
ASSERT(getShaderType() == GL_COMPUTE_SHADER);
EmitWorkGroupSizeGLSL(*this, sink);
}
if (getShaderType() == GL_VERTEX_SHADER)
{
@@ -1419,8 +1405,6 @@ bool TranslatorMetalDirect::translateImpl(TInfoSinkBase &sink,
return false;
}
// Note: ReduceInterfaceBlocks removes row_major matrix layout specifiers
// so it must come after RewriteRowMajorMatrices.
if (!ReduceInterfaceBlocks(*this, *root, idGen, &getSymbolTable()))
{
return false;

View File

@@ -17,7 +17,7 @@ namespace sh
class TCompiler;
class TIntermNode;
#if defined(ANGLE_ENABLE_GLSL) && defined(ANGLE_ENABLE_APPLE_WORKAROUNDS)
#if ANGLE_ENABLE_GLSL && ANGLE_PLATFORM_APPLE
[[nodiscard]] bool AddAndTrueToLoopCondition(TCompiler *compiler, TIntermNode *root);
#else
[[nodiscard]] ANGLE_INLINE bool AddAndTrueToLoopCondition(TCompiler *compiler, TIntermNode *root)

View File

@@ -20,7 +20,7 @@ class TCompiler;
class TIntermNode;
class TSymbolTable;
#if defined(ANGLE_ENABLE_GLSL) && defined(ANGLE_ENABLE_APPLE_WORKAROUNDS)
#if ANGLE_ENABLE_GLSL && ANGLE_PLATFORM_APPLE
[[nodiscard]] bool RewriteDoWhile(TCompiler *compiler,
TIntermNode *root,
TSymbolTable *symbolTable);

View File

@@ -18,8 +18,7 @@ class TCompiler;
class TIntermBlock;
class TSymbolTable;
#if (defined(ANGLE_ENABLE_GLSL) || defined(ANGLE_ENABLE_METAL)) && \
defined(ANGLE_ENABLE_APPLE_WORKAROUNDS)
#if ANGLE_ENABLE_GLSL && ANGLE_PLATFORM_APPLE
[[nodiscard]] bool RewriteRowMajorMatrices(TCompiler *compiler,
TIntermBlock *root,
TSymbolTable *symbolTable);

View File

@@ -16,7 +16,7 @@ namespace sh
class TCompiler;
class TIntermNode;
#if defined(ANGLE_ENABLE_GLSL) && defined(ANGLE_ENABLE_APPLE_WORKAROUNDS)
#if ANGLE_ENABLE_GLSL && ANGLE_PLATFORM_APPLE
[[nodiscard]] bool RewriteUnaryMinusOperatorFloat(TCompiler *compiler, TIntermNode *root);
#else
[[nodiscard]] ANGLE_INLINE bool RewriteUnaryMinusOperatorFloat(TCompiler *compiler,

View File

@@ -19,7 +19,7 @@ namespace sh
class TCompiler;
class TIntermBlock;
#if defined(ANGLE_ENABLE_GLSL) && defined(ANGLE_ENABLE_APPLE_WORKAROUNDS)
#if defined(ANGLE_ENABLE_GLSL) && defined(ANGLE_PLATFORM_APPLE)
[[nodiscard]] bool UnfoldShortCircuitAST(TCompiler *compiler, TIntermBlock *root);
#else
[[nodiscard]] ANGLE_INLINE bool UnfoldShortCircuitAST(TCompiler *compiler, TIntermBlock *root)

View File

@@ -368,7 +368,6 @@ void PrintSystemInfo(const SystemInfo &info)
std::cout << "Optimus: " << (info.isOptimus ? "true" : "false") << "\n";
std::cout << "AMD Switchable: " << (info.isAMDSwitchable ? "true" : "false") << "\n";
std::cout << "Mac Switchable: " << (info.isMacSwitchable ? "true" : "false") << "\n";
std::cout << "Needs EAGL on Mac: " << (info.needsEAGLOnMac ? "true" : "false") << "\n";
std::cout << "\n";
if (!info.machineManufacturer.empty())

View File

@@ -78,8 +78,6 @@ struct SystemInfo
bool isAMDSwitchable = false;
// Only true on dual-GPU Mac laptops.
bool isMacSwitchable = false;
// Only true on Apple Silicon Macs when running in macCatalyst.
bool needsEAGLOnMac = false;
// Only available on Android
std::string machineManufacturer;

View File

@@ -391,10 +391,6 @@ bool GetSystemInfo_mac(SystemInfo *info)
info->isMacSwitchable = true;
}
#if defined(ANGLE_PLATFORM_MACCATALYST) && defined(ANGLE_ENABLE_EAGL)
info->needsEAGLOnMac = true;
#endif
return true;
}

View File

@@ -53,8 +53,10 @@
#if defined(ANGLE_ENABLE_OPENGL)
# if defined(ANGLE_PLATFORM_WINDOWS)
# include "libANGLE/renderer/gl/wgl/DisplayWGL.h"
# elif defined(ANGLE_PLATFORM_APPLE)
# include "libANGLE/renderer/gl/apple/DisplayApple_api.h"
# elif ANGLE_ENABLE_CGL
# include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
# elif ANGLE_ENABLE_EAGL
# include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
# elif defined(ANGLE_PLATFORM_LINUX)
# include "libANGLE/renderer/gl/egl/DisplayEGL.h"
# if defined(ANGLE_USE_X11)
@@ -342,8 +344,12 @@ rx::DisplayImpl *CreateDisplayFromAttribs(EGLAttrib displayType,
impl = new rx::DisplayWGL(state);
break;
# elif defined(ANGLE_PLATFORM_APPLE)
impl = rx::CreateDisplayCGLOrEAGL(state);
# elif ANGLE_ENABLE_CGL
impl = new rx::DisplayCGL(state);
break;
# elif ANGLE_ENABLE_EAGL
impl = new rx::DisplayEAGL(state);
break;
# elif defined(ANGLE_PLATFORM_LINUX)

View File

@@ -1394,21 +1394,9 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddRGBAXFormat(&map, GL_RGBA, false, FB< 8, 8, 8, 8, 0, 0>(), GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAXFormat(&map, GL_SRGB, false, FB< 8, 8, 8, 0, 0, 0>(), GL_SRGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGBEXT>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAXFormat(&map, GL_SRGB_ALPHA_EXT, false, FB< 8, 8, 8, 8, 0, 0>(), GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGBEXT>, AlwaysSupported, RequireExt<&Extensions::sRGBEXT>, NeverSupported, NeverSupported);
#if (ANGLE_PLATFORM_IOS_FAMILY && !ANGLE_PLATFORM_MACCATALYST) || (ANGLE_PLATFORM_MACCATALYST && ANGLE_ENABLE_EAGL)
angle::SystemInfo info;
if (angle::GetSystemInfo(&info))
{
if (info.needsEAGLOnMac)
{
// Using OpenGLES.framework.
AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, AlwaysSupported, RequireES<2, 0>, NeverSupported, NeverSupported);
}
else
{
// Using OpenGL.framework.
AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888EXT>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>, NeverSupported, NeverSupported);
}
}
#if ANGLE_ENABLE_EAGL
// Using OpenGLES.framework.
AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, AlwaysSupported, RequireES<2, 0>, NeverSupported, NeverSupported);
#else
AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888EXT>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>, NeverSupported, NeverSupported);
#endif

View File

@@ -1,49 +0,0 @@
//
// 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.
//
// DisplayApple_api.cpp:
// Chooses CGL or EAGL either at compile time or runtime based on the platform.
//
#include "libANGLE/renderer/gl/apple/DisplayApple_api.h"
#include "gpu_info_util/SystemInfo.h"
#include "libANGLE/renderer/DisplayImpl.h"
#if defined(ANGLE_ENABLE_CGL)
# include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
#endif
#if defined(ANGLE_ENABLE_EAGL)
# include "libANGLE/renderer/gl/eagl/DisplayEAGL.h"
#endif
namespace rx
{
DisplayImpl *CreateDisplayCGLOrEAGL(const egl::DisplayState &state)
{
#if defined(ANGLE_ENABLE_EAGL) && defined(ANGLE_ENABLE_CGL)
angle::SystemInfo info;
if (!angle::GetSystemInfo(&info))
{
return nullptr;
}
if (info.needsEAGLOnMac)
{
return new rx::DisplayEAGL(state);
}
else
{
return new rx::DisplayCGL(state);
}
#elif defined(ANGLE_ENABLE_CGL)
return new rx::DisplayCGL(state);
#elif defined(ANGLE_ENABLE_EAGL)
return new rx::DisplayEAGL(state);
#endif
}
} // namespace rx

View File

@@ -1,22 +0,0 @@
//
// 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.
//
// DisplayApple_api.h:
// Chooses CGL or EAGL either at compile time or runtime based on the platform.
//
#ifndef LIBANGLE_RENDERER_GL_APPLE_DISPLAYAPPLE_API_H_
#define LIBANGLE_RENDERER_GL_APPLE_DISPLAYAPPLE_API_H_
#include "libANGLE/renderer/DisplayImpl.h"
namespace rx
{
DisplayImpl *CreateDisplayCGLOrEAGL(const egl::DisplayState &state);
} // namespace rx
#endif /* LIBANGLE_RENDERER_GL_APPLE_DISPLAYAPPLE_API_H_ */

View File

@@ -1770,18 +1770,14 @@ void GenerateCaps(const FunctionsGL *functions,
extensions->compressedETC2RGB8TextureOES || functions->isAtLeastGLES(gl::Version(3, 0)) ||
functions->hasGLESExtension("GL_EXT_compressed_ETC1_RGB8_sub_texture");
#if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
angle::SystemInfo info;
if (angle::GetSystemInfo(&info) && !info.needsEAGLOnMac)
#if ANGLE_ENABLE_CGL
VendorID vendor = GetVendorID(functions);
if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0))
{
VendorID vendor = GetVendorID(functions);
if ((IsAMD(vendor) || IsIntel(vendor)) && *maxSupportedESVersion >= gl::Version(3, 0))
{
// Apple Intel/AMD drivers do not correctly use the TEXTURE_SRGB_DECODE property of
// sampler states. Disable this extension when we would advertise any ES version
// that has samplers.
extensions->textureSRGBDecodeEXT = false;
}
// Apple Intel/AMD drivers do not correctly use the TEXTURE_SRGB_DECODE property of
// sampler states. Disable this extension when we would advertise any ES version
// that has samplers.
extensions->textureSRGBDecodeEXT = false;
}
#endif

View File

@@ -46,13 +46,13 @@ angle_source_set("angle_metal_backend") {
cflags_objc += objc_flags
cflags_objcc += objc_flags
if (is_mac) {
if (is_apple) {
frameworks = [
"Cocoa.framework",
"IOSurface.framework",
"QuartzCore.framework",
]
if (is_mac) {
frameworks += [ "Cocoa.framework" ]
}
}
# TODO(hqle): iOS support.
}

View File

@@ -1250,7 +1250,6 @@ void DisplayMtl::initializeFeatures()
ANGLE_FEATURE_CONDITION((&mFeatures), allowSeparateDepthStencilBuffers,
!isOSX && !isCatalyst && !isSimulator);
ANGLE_FEATURE_CONDITION((&mFeatures), rewriteRowMajorMatrices, true);
ANGLE_FEATURE_CONDITION((&mFeatures), emulateTransformFeedback, true);
ANGLE_FEATURE_CONDITION((&mFeatures), intelExplicitBoolCastWorkaround,

View File

@@ -123,11 +123,6 @@ std::shared_ptr<WaitableCompileEvent> ShaderMtl::compile(const gl::Context *cont
options->clampFragDepth = true;
#endif
if (displayMtl->getFeatures().rewriteRowMajorMatrices.enabled)
{
options->rewriteRowMajorMatrices = true;
}
if (displayMtl->getFeatures().emulateAlphaToCoverage.enabled)
{
options->emulateAlphaToCoverage = true;

View File

@@ -562,11 +562,7 @@ libangle_cl_sources = [
"src/libANGLE/validationCL.cpp",
]
libangle_mac_sources = [
"src/libANGLE/renderer/driver_utils_mac.mm",
"src/libANGLE/renderer/gl/apple/DisplayApple_api.cpp",
"src/libANGLE/renderer/gl/apple/DisplayApple_api.h",
]
libangle_mac_sources = [ "src/libANGLE/renderer/driver_utils_mac.mm" ]
# The frame capture headers are always visible to libANGLE.
libangle_sources += [