Title: [278298] trunk/Source/ThirdParty/ANGLE
Revision
278298
Author
[email protected]
Date
2021-06-01 01:01:43 -0700 (Tue, 01 Jun 2021)

Log Message

ANGLE Metal translator pre-rotation code is unused and it asserts when used
https://bugs.webkit.org/show_bug.cgi?id=226262

Patch by Kimmo Kinnunen <[email protected]> on 2021-06-01
Reviewed by Dean Jackson.

Remove the pre-rotation code. It is Android specific and most likely it is useful
only when ANGLE is used as the drawing mechanism for the primary app window picture.
Thus most likely it is not useful in WebKit on Cocoa platforms where the window
server does the compositing.

* src/compiler/translator/TranslatorMetalDirect.cpp:
(sh::TranslatorMetalDirect::translateImpl):
* src/compiler/translator/TranslatorMetalDirect.h:
* src/libANGLE/renderer/metal/ContextMtl.h:
* src/libANGLE/renderer/metal/ContextMtl.mm:
(rx::ContextMtl::handleDirtyDriverUniforms):

Modified Paths

Diff

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (278297 => 278298)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-06-01 06:59:45 UTC (rev 278297)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-06-01 08:01:43 UTC (rev 278298)
@@ -1,3 +1,22 @@
+2021-06-01  Kimmo Kinnunen  <[email protected]>
+
+        ANGLE Metal translator pre-rotation code is unused and it asserts when used
+        https://bugs.webkit.org/show_bug.cgi?id=226262
+
+        Reviewed by Dean Jackson.
+
+        Remove the pre-rotation code. It is Android specific and most likely it is useful
+        only when ANGLE is used as the drawing mechanism for the primary app window picture.
+        Thus most likely it is not useful in WebKit on Cocoa platforms where the window
+        server does the compositing.
+
+        * src/compiler/translator/TranslatorMetalDirect.cpp:
+        (sh::TranslatorMetalDirect::translateImpl):
+        * src/compiler/translator/TranslatorMetalDirect.h:
+        * src/libANGLE/renderer/metal/ContextMtl.h:
+        * src/libANGLE/renderer/metal/ContextMtl.mm:
+        (rx::ContextMtl::handleDirtyDriverUniforms):
+
 2021-05-31  Kimmo Kinnunen  <[email protected]>
 
         Cherry-pick ANGLE: Add array bounds checks for WebGL shaders

Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp (278297 => 278298)


--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp	2021-06-01 06:59:45 UTC (rev 278297)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp	2021-06-01 08:01:43 UTC (rev 278298)
@@ -78,12 +78,11 @@
     TExtension::UNDEFINED,
     StaticType::Get<EbtUInt, EbpHigh, EvqVertexID, 1, 1>());
 
-
-constexpr size_t kNumGraphicsDriverUniforms                                                = 12;
+// Keep this list in sync with ContextMtl::DriverUniforms.
+constexpr size_t kNumGraphicsDriverUniforms                                                = 10;
 constexpr std::array<const char *, kNumGraphicsDriverUniforms> kGraphicsDriverUniformNames = {
     {kViewport, kHalfRenderArea, kFlipXY, kNegFlipXY, kClipDistancesEnabled, kXfbActiveUnpaused,
-     kXfbVerticesPerDraw, kXfbBufferOffsets, kAcbBufferOffsets, kDepthRange, kPreRotation,
-     kFragRotation}};
+     kXfbVerticesPerDraw, kXfbBufferOffsets, kAcbBufferOffsets, kDepthRange}};
 
 constexpr size_t kNumComputeDriverUniforms                                               = 1;
 constexpr std::array<const char *, kNumComputeDriverUniforms> kComputeDriverUniformNames = {
@@ -344,7 +343,7 @@
             .first->getType()
             .getStruct();
 
-    // This field list mirrors the structure of GraphicsDriverUniforms in ContextVk.cpp.
+    // This field list mirrors the structure of GraphicsDriverUniforms in ContextMtl.cpp.
     TFieldList *driverFieldList = new TFieldList;
 
     const std::array<TType *, kNumGraphicsDriverUniforms> kDriverUniformTypes = {{
@@ -359,8 +358,6 @@
         new TType(EbtInt, 4),
         new TType(EbtUInt, 4),
         new TType(emulatedDepthRangeParams, false),
-        new TType(EbtFloat, 2, 4),
-        new TType(EbtFloat, 2, 4),
     }};
 
     for (size_t uniformIndex = 0; uniformIndex < kNumGraphicsDriverUniforms; ++uniformIndex)
@@ -454,35 +451,6 @@
     return RunAtTheEndOfShader(&compiler, &root, assignment, &symbolTable);
 }
 
-// This operation performs Android pre-rotation and y-flip.  For Android (and potentially other
-// platforms), the device may rotate, such that the orientation of the application is rotated
-// relative to the native orientation of the device.  This is corrected in part by multiplying
-// gl_Position by a mat2.
-// The equations reduce to an _expression_:
-//
-//     gl_Position.xy = gl_Position.xy * preRotation
-ANGLE_NO_DISCARD bool AppendPreRotation(TCompiler &compiler,
-                                        TIntermBlock &root,
-                                        const TVariable &driverUniforms)
-{
-    TSymbolTable &symbolTable     = compiler.getSymbolTable();
-    TIntermBinary *preRotationRef = CreateDriverUniformRef(driverUniforms, kPreRotation);
-    TIntermSymbol *glPos          = new TIntermSymbol(BuiltInVariable::gl_Position());
-    TVector<int> swizzleOffsetXY  = {0, 1};
-    TIntermSwizzle *glPosXY       = new TIntermSwizzle(glPos, swizzleOffsetXY);
-
-    // Create the _expression_ "(gl_Position.xy * preRotation)"
-    TIntermBinary *zRotated =
-        new TIntermBinary(EOpMatrixTimesVector, preRotationRef->deepCopy(), glPosXY->deepCopy());
-
-    // Create the assignment "gl_Position.xy = (gl_Position.xy * preRotation)"
-    TIntermBinary *assignment =
-        new TIntermBinary(TOperator::EOpAssign, glPosXY->deepCopy(), zRotated);
-
-    // Append the assignment as a statement at the end of the shader.
-    return RunAtTheEndOfShader(&compiler, &root, assignment, &symbolTable);
-}
-
 ANGLE_NO_DISCARD bool RotateAndFlipBuiltinVariable(TCompiler &compiler,
                                                    TIntermBlock &root,
                                                    TIntermSequence &insertSequence,
@@ -561,9 +529,7 @@
 {
     TIntermBinary &flipXY       = *CreateDriverUniformRef(driverUniforms, kFlipXY);
     TIntermBinary &pivot        = *CreateDriverUniformRef(driverUniforms, kHalfRenderArea);
-    TIntermBinary *fragRotation = (compileOptions & SH_ADD_PRE_ROTATION)
-                                      ? CreateDriverUniformRef(driverUniforms, kFragRotation)
-                                      : nullptr;
+    TIntermBinary *fragRotation = nullptr;
     return RotateAndFlipBuiltinVariable(compiler, root, insertSequence, flipXY,
                                         *BuiltInVariable::gl_FragCoord(), kFlippedFragCoordName,
                                         pivot, fragRotation);
@@ -1263,14 +1229,11 @@
         }
 #endif
 
-        bool usePreRotation = compileOptions & SH_ADD_PRE_ROTATION;
-
         if (usesPointCoord)
         {
             TIntermBinary &flipXY       = *CreateDriverUniformRef(driverUniforms, kNegFlipXY);
             TIntermConstantUnion &pivot = *CreateFloatNode(0.5f);
-            TIntermBinary *fragRotation =
-                usePreRotation ? CreateDriverUniformRef(driverUniforms, kFragRotation) : nullptr;
+            TIntermBinary *fragRotation = nullptr;
             if (!RotateAndFlipBuiltinVariable(*this, root, *GetMainSequence(root), flipXY,
                                               *BuiltInVariable::gl_PointCoord(),
                                               kFlippedPointCoordName, pivot, fragRotation))
@@ -1292,8 +1255,7 @@
 
         {
             TIntermBinary *flipXY = CreateDriverUniformRef(driverUniforms, kFlipXY);
-            TIntermBinary *fragRotation =
-                usePreRotation ? CreateDriverUniformRef(driverUniforms, kFragRotation) : nullptr;
+            TIntermBinary *fragRotation = nullptr;
             if (!RewriteDfdy(this, &root, symbolTable, getShaderVersion(), flipXY, fragRotation))
             {
                 return false;
@@ -1367,14 +1329,6 @@
         {
             return false;
         }
-
-
-
-        if ((compileOptions & SH_ADD_PRE_ROTATION) != 0 &&
-            !AppendPreRotation(*this, root, driverUniforms))
-        {
-            return false;
-        }
     }
     else if (getShaderType() == GL_GEOMETRY_SHADER)
     {

Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.h (278297 => 278298)


--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.h	2021-06-01 06:59:45 UTC (rev 278297)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.h	2021-06-01 08:01:43 UTC (rev 278298)
@@ -23,8 +23,6 @@
 constexpr const char kXfbBufferOffsets[]          = "xfbBufferOffsets";
 constexpr const char kAcbBufferOffsets[]          = "acbBufferOffsets";
 constexpr const char kDepthRange[]                = "depthRange";
-constexpr const char kPreRotation[]               = "preRotation";
-constexpr const char kFragRotation[]              = "fragRotation";
 constexpr const char kUnassignedAttributeString[] = " __unassigned_attribute__";
 
 class TOutputMSL;

Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.h (278297 => 278298)


--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.h	2021-06-01 06:59:45 UTC (rev 278297)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.h	2021-06-01 08:01:43 UTC (rev 278298)
@@ -500,7 +500,7 @@
         DIRTY_BIT_MAX,
     };
 
-    // See compiler/translator/TranslatorVulkan.cpp: AddDriverUniformsToShader()
+    // Keep this in sync with TranslatorMetalDirect.cpp: kGraphicsDriverUniformNames.
     struct DriverUniforms
     {
         float viewport[4];
@@ -523,16 +523,6 @@
         // We'll use x, y, z, w for near / far / diff / zscale respectively.
         float depthRange[4];
 
-        // Used to pre-rotate gl_Position for Vulkan swapchain images on Android (a mat2, which is
-        // padded to the size of two vec4's).
-        // Unused in Metal.
-        float preRotation[8] = {};
-
-        // Used to pre-rotate gl_FragCoord for Vulkan swapchain images on Android (a mat2, which is
-        // padded to the size of two vec4's).
-        // Unused in Metal.
-        float fragRotation[8] = {};
-
         uint32_t coverageMask;
 
         int32_t emulatedInstanceID;

Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm (278297 => 278298)


--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm	2021-06-01 06:59:45 UTC (rev 278297)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm	2021-06-01 08:01:43 UTC (rev 278298)
@@ -2298,8 +2298,6 @@
     mDriverUniforms.depthRange[2] = depthRangeDiff;
     mDriverUniforms.depthRange[3] = NeedToInvertDepthRange(depthRangeNear, depthRangeFar) ? -1 : 1;
 
-    // NOTE(hqle): preRotation & fragRotation are unused.
-
     // Sample coverage mask
     uint32_t sampleBitCount = mDrawFramebuffer->getSamples();
     uint32_t coverageSampleBitCount =
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to