Diff
Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/ChangeLog 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog 2021-04-12 22:41:31 UTC (rev 275841)
@@ -1,3 +1,32 @@
+2021-04-12 Dean Jackson <[email protected]>
+
+ REGRESSION (Metal ANGLE): [Catalina] 6 consistent WebGL failures / timeouts
+ https://bugs.webkit.org/show_bug.cgi?id=224016
+ <rdar://problem/76070325>
+
+ Patch by John Cunningham <[email protected]>
+ Reviewed by Dean Jackson.
+
+ Implement a workaround for Intel GPUs where we explicitly type cast floating
+ point values to booleans. This is only needed for Catalina systems.
+
+ * include/GLSLANG/ShaderLang.h:
+ * include/platform/FeaturesMtl.h:
+ * src/compiler/translator/TranslatorMetalDirect.cpp:
+ (sh::TranslatorMetalDirect::translateImpl):
+ * src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.cpp:
+ (sh::Rewriter::Rewriter):
+ (sh::AddExplicitTypeCasts):
+ * src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.h:
+ * src/compiler/translator/TranslatorMetalDirect/AstHelpers.cpp:
+ (sh::SubVector):
+ (sh::CoerceSimple):
+ * src/compiler/translator/TranslatorMetalDirect/AstHelpers.h:
+ * src/libANGLE/renderer/metal/DisplayMtl.mm:
+ (rx::DisplayMtl::initializeFeatures):
+ * src/libANGLE/renderer/metal/ShaderMtl.mm:
+ (rx::ShaderMtl::compile):
+
2021-04-12 Kyle Piddington <[email protected]>
Crash in webgl/2.0.y/conformance/glsl/misc/uninitialized-local-global-variables.html ANGLE+METAL
Modified: trunk/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderLang.h 2021-04-12 22:41:31 UTC (rev 275841)
@@ -344,6 +344,9 @@
// Allow compiler to insert Android pre-rotation code.
const ShCompileOptions SH_ADD_PRE_ROTATION = UINT64_C(1) << 56;
+// Insert explicit casts for float/double/unsigned/signed int on macOS 10.15 with Intel driver
+const ShCompileOptions SH_ADD_EXPLICIT_BOOL_CASTS = UINT64_C(1) << 57;
+
// Defines alternate strategies for implementing array index clamping.
enum ShArrayIndexClampingStrategy
{
Modified: trunk/Source/ThirdParty/ANGLE/include/platform/FeaturesMtl.h (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/include/platform/FeaturesMtl.h 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/include/platform/FeaturesMtl.h 2021-04-12 22:41:31 UTC (rev 275841)
@@ -125,6 +125,11 @@
"intel_thin_mipmap_workaround", FeatureCategory::MetalWorkarounds,
"Generate mipmaps for thin (<5 pixel) wide textures on the CPU for Intel",
&members};
+
+ Feature intelExplicitBoolCastWorkaround = {
+ "intel_explicit_bool_cast_workaround", FeatureCategory::MetalWorkarounds,
+ "Insert explicit casts for float/double/unsigned/signed int on macOS 10.15 with Intel driver",
+ &members};
};
} // namespace angle
Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.cpp (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.cpp 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.cpp 2021-04-12 22:41:31 UTC (rev 275841)
@@ -16,10 +16,11 @@
class Rewriter : public TIntermRebuild
{
SymbolEnv &mSymbolEnv;
+ bool mNeedsExplicitBoolCasts = false;
public:
- Rewriter(TCompiler &compiler, SymbolEnv &symbolEnv)
- : TIntermRebuild(compiler, false, true), mSymbolEnv(symbolEnv)
+ Rewriter(TCompiler &compiler, SymbolEnv &symbolEnv, bool needsExplicitBoolCasts)
+ : TIntermRebuild(compiler, false, true), mSymbolEnv(symbolEnv), mNeedsExplicitBoolCasts(needsExplicitBoolCasts)
{}
PostResult visitAggregatePost(TIntermAggregate &callNode) override
@@ -84,9 +85,9 @@
} // anonymous namespace
-bool sh::AddExplicitTypeCasts(TCompiler &compiler, TIntermBlock &root, SymbolEnv &symbolEnv)
+bool sh::AddExplicitTypeCasts(TCompiler &compiler, TIntermBlock &root, SymbolEnv &symbolEnv, bool needsExplicitBoolCasts)
{
- Rewriter rewriter(compiler, symbolEnv);
+ Rewriter rewriter(compiler, symbolEnv, needsExplicitBoolCasts);
if (!rewriter.rebuildRoot(root))
{
return false;
Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.h (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.h 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AddExplicitTypeCasts.h 2021-04-12 22:41:31 UTC (rev 275841)
@@ -17,7 +17,8 @@
// Adds explicit type casts into the AST where casting is done implicitly.
ANGLE_NO_DISCARD bool AddExplicitTypeCasts(TCompiler &compiler,
TIntermBlock &root,
- SymbolEnv &symbolEnv);
+ SymbolEnv &symbolEnv,
+ bool needsExplicitBoolCasts);
} // namespace sh
Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AstHelpers.cpp (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AstHelpers.cpp 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AstHelpers.cpp 2021-04-12 22:41:31 UTC (rev 275841)
@@ -273,7 +273,7 @@
}
TVector<int> offsets(static_cast<size_t>(end - begin));
std::iota(offsets.begin(), offsets.end(), begin);
- auto *swizzle = new TIntermSwizzle(&vectorNode, offsets);
+ auto *swizzle = new TIntermSwizzle(vectorNode.deepCopy(), offsets);
return *swizzle;
}
@@ -420,18 +420,46 @@
return false;
}
-TIntermTyped &sh::CoerceSimple(TBasicType toType, TIntermTyped &fromNode)
+TIntermTyped &sh::CoerceSimple(TBasicType toBasicType, TIntermTyped &fromNode)
{
const TType &fromType = fromNode.getType();
- ASSERT(HasScalarBasicType(toType));
+ ASSERT(HasScalarBasicType(toBasicType));
ASSERT(HasScalarBasicType(fromType));
ASSERT(!fromType.isArray());
+
+ const TBasicType fromBasicType = fromType.getBasicType();
- if (toType != fromType.getBasicType())
+ if (toBasicType != fromBasicType)
{
+ if (toBasicType == TBasicType::EbtBool &&
+ fromNode.isVector())
+ {
+ switch (fromBasicType)
+ {
+ case TBasicType::EbtFloat:
+ case TBasicType::EbtDouble:
+ case TBasicType::EbtInt:
+ case TBasicType::EbtUInt:
+ {
+ TIntermTyped &fromTypeSwizzle = SubVector(fromNode, 0, 1);
+ TIntermAggregate *boolConstructor = TIntermAggregate::CreateConstructor(
+ *new TType(toBasicType, 1, 1),
+ new TIntermSequence{&fromTypeSwizzle});
+ TIntermSequence *argsSequence = new TIntermSequence({boolConstructor});
+ return *TIntermAggregate::CreateConstructor(
+ *new TType(toBasicType, fromType.getNominalSize(), fromType.getSecondarySize()),
+ argsSequence);
+
+ }
+ break;
+ default:
+ break; // No explicit conversion needed
+ }
+ }
+
return *TIntermAggregate::CreateConstructor(
- *new TType(toType, fromType.getNominalSize(), fromType.getSecondarySize()),
+ *new TType(toBasicType, fromType.getNominalSize(), fromType.getSecondarySize()),
new TIntermSequence{&fromNode});
}
return fromNode;
@@ -447,9 +475,43 @@
ASSERT(toType.getSecondarySize() == fromType.getSecondarySize());
ASSERT(!toType.isArray());
ASSERT(!fromType.isArray());
+
+ const TBasicType toBasicType = toType.getBasicType();
+ const TBasicType fromBasicType = fromType.getBasicType();
- if (toType.getBasicType() != fromType.getBasicType())
+ if (toBasicType != fromBasicType)
{
+ if (toBasicType == TBasicType::EbtBool &&
+ fromNode.isVector())
+ {
+ switch (fromBasicType)
+ {
+ case TBasicType::EbtFloat:
+ case TBasicType::EbtDouble:
+ case TBasicType::EbtInt:
+ case TBasicType::EbtUInt:
+ {
+
+ TIntermSequence *argsSequence = new TIntermSequence();
+ for (int i = 0; i < fromType.getNominalSize(); i++)
+ {
+ TIntermTyped &fromTypeSwizzle = SubVector(fromNode, i, i+1);
+ TIntermAggregate *boolConstructor = TIntermAggregate::CreateConstructor(
+ *new TType(toBasicType, 1, 1),
+ new TIntermSequence{&fromTypeSwizzle});
+ argsSequence->push_back(boolConstructor);
+ }
+ return *TIntermAggregate::CreateConstructor(
+ *new TType(toBasicType, fromType.getNominalSize(), fromType.getSecondarySize()),
+ new TIntermSequence{*argsSequence});
+
+ }
+ break;
+ default:
+ break; // No explicit conversion needed
+ }
+ }
+
return *TIntermAggregate::CreateConstructor(toType, new TIntermSequence{&fromNode});
}
return fromNode;
Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AstHelpers.h (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AstHelpers.h 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/AstHelpers.h 2021-04-12 22:41:31 UTC (rev 275841)
@@ -143,7 +143,7 @@
// Coerces `fromNode` to `toType` by a constructor call of `toType` if their types differ.
// Vector and matrix dimensions are retained.
// Array types are not allowed.
-TIntermTyped &CoerceSimple(TBasicType toType, TIntermTyped &fromNode);
+TIntermTyped &CoerceSimple(TBasicType toBasicType, TIntermTyped &fromNode);
// Coerces `fromNode` to `toType` by a constructor call of `toType` if their types differ.
// Vector and matrix dimensions must coincide between to and from.
Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp 2021-04-12 22:41:31 UTC (rev 275841)
@@ -1453,8 +1453,8 @@
{
return false;
}
-
- if (!AddExplicitTypeCasts(*this, root, symbolEnv))
+ const bool needsExplicitBoolCasts = (compileOptions & SH_ADD_EXPLICIT_BOOL_CASTS) != 0;
+ if (!AddExplicitTypeCasts(*this, root, symbolEnv, needsExplicitBoolCasts))
{
return false;
}
Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/DisplayMtl.mm 2021-04-12 22:41:31 UTC (rev 275841)
@@ -13,6 +13,7 @@
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
+#include "libANGLE/renderer/driver_utils.h"
#include "libANGLE/renderer/glslang_wrapper_utils.h"
#include "libANGLE/renderer/metal/ContextMtl.h"
#include "libANGLE/renderer/metal/IOSurfaceSurfaceMtl.h"
@@ -907,7 +908,8 @@
ANGLE_FEATURE_CONDITION((&mFeatures), rewriteRowMajorMatrices, true);
ANGLE_FEATURE_CONDITION((&mFeatures), emulateTransformFeedback, true);
- ANGLE_FEATURE_CONDITION((&mFeatures),intelThinMipmapWorkaround, isIntel());
+ ANGLE_FEATURE_CONDITION((&mFeatures), intelThinMipmapWorkaround, isIntel());
+ ANGLE_FEATURE_CONDITION((&mFeatures), intelExplicitBoolCastWorkaround, isIntel() && GetMacOSVersion() < OSVersion(11, 0, 0));
angle::PlatformMethods *platform = ANGLEPlatformCurrent();
platform->overrideFeaturesMtl(platform, &mFeatures);
Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ShaderMtl.mm (275840 => 275841)
--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ShaderMtl.mm 2021-04-12 22:01:09 UTC (rev 275840)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ShaderMtl.mm 2021-04-12 22:41:31 UTC (rev 275841)
@@ -136,6 +136,11 @@
{
compileOptions |= SH_REWRITE_ROW_MAJOR_MATRICES;
}
+
+ if (contextMtl->getDisplay()->getFeatures().intelExplicitBoolCastWorkaround.enabled)
+ {
+ compileOptions |= SH_ADD_EXPLICIT_BOOL_CASTS;
+ }
return compileImplMtl(context, compilerInstance, getState().getSource(), compileOptions | options);
}