Changeset 278298 in webkit


Ignore:
Timestamp:
Jun 1, 2021, 1:01:43 AM (4 years ago)
Author:
commit-queue@webkit.org
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 <kkinnunen@apple.com> 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):

Location:
trunk/Source/ThirdParty/ANGLE
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/ANGLE/ChangeLog

    r278296 r278298  
     12021-06-01  Kimmo Kinnunen  <kkinnunen@apple.com>
     2
     3        ANGLE Metal translator pre-rotation code is unused and it asserts when used
     4        https://bugs.webkit.org/show_bug.cgi?id=226262
     5
     6        Reviewed by Dean Jackson.
     7
     8        Remove the pre-rotation code. It is Android specific and most likely it is useful
     9        only when ANGLE is used as the drawing mechanism for the primary app window picture.
     10        Thus most likely it is not useful in WebKit on Cocoa platforms where the window
     11        server does the compositing.
     12
     13        * src/compiler/translator/TranslatorMetalDirect.cpp:
     14        (sh::TranslatorMetalDirect::translateImpl):
     15        * src/compiler/translator/TranslatorMetalDirect.h:
     16        * src/libANGLE/renderer/metal/ContextMtl.h:
     17        * src/libANGLE/renderer/metal/ContextMtl.mm:
     18        (rx::ContextMtl::handleDirtyDriverUniforms):
     19
    1202021-05-31  Kimmo Kinnunen  <kkinnunen@apple.com>
    221
  • trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp

    r275841 r278298  
    7979    StaticType::Get<EbtUInt, EbpHigh, EvqVertexID, 1, 1>());
    8080
    81 
    82 constexpr size_t kNumGraphicsDriverUniforms                                                = 12;
     81// Keep this list in sync with ContextMtl::DriverUniforms.
     82constexpr size_t kNumGraphicsDriverUniforms                                                = 10;
    8383constexpr std::array<const char *, kNumGraphicsDriverUniforms> kGraphicsDriverUniformNames = {
    8484    {kViewport, kHalfRenderArea, kFlipXY, kNegFlipXY, kClipDistancesEnabled, kXfbActiveUnpaused,
    85      kXfbVerticesPerDraw, kXfbBufferOffsets, kAcbBufferOffsets, kDepthRange, kPreRotation,
    86      kFragRotation}};
     85     kXfbVerticesPerDraw, kXfbBufferOffsets, kAcbBufferOffsets, kDepthRange}};
    8786
    8887constexpr size_t kNumComputeDriverUniforms                                               = 1;
     
    345344            .getStruct();
    346345
    347     // This field list mirrors the structure of GraphicsDriverUniforms in ContextVk.cpp.
     346    // This field list mirrors the structure of GraphicsDriverUniforms in ContextMtl.cpp.
    348347    TFieldList *driverFieldList = new TFieldList;
    349348
     
    360359        new TType(EbtUInt, 4),
    361360        new TType(emulatedDepthRangeParams, false),
    362         new TType(EbtFloat, 2, 4),
    363         new TType(EbtFloat, 2, 4),
    364361    }};
    365362
     
    455452}
    456453
    457 // This operation performs Android pre-rotation and y-flip.  For Android (and potentially other
    458 // platforms), the device may rotate, such that the orientation of the application is rotated
    459 // relative to the native orientation of the device.  This is corrected in part by multiplying
    460 // gl_Position by a mat2.
    461 // The equations reduce to an expression:
    462 //
    463 //     gl_Position.xy = gl_Position.xy * preRotation
    464 ANGLE_NO_DISCARD bool AppendPreRotation(TCompiler &compiler,
    465                                         TIntermBlock &root,
    466                                         const TVariable &driverUniforms)
    467 {
    468     TSymbolTable &symbolTable     = compiler.getSymbolTable();
    469     TIntermBinary *preRotationRef = CreateDriverUniformRef(driverUniforms, kPreRotation);
    470     TIntermSymbol *glPos          = new TIntermSymbol(BuiltInVariable::gl_Position());
    471     TVector<int> swizzleOffsetXY  = {0, 1};
    472     TIntermSwizzle *glPosXY       = new TIntermSwizzle(glPos, swizzleOffsetXY);
    473 
    474     // Create the expression "(gl_Position.xy * preRotation)"
    475     TIntermBinary *zRotated =
    476         new TIntermBinary(EOpMatrixTimesVector, preRotationRef->deepCopy(), glPosXY->deepCopy());
    477 
    478     // Create the assignment "gl_Position.xy = (gl_Position.xy * preRotation)"
    479     TIntermBinary *assignment =
    480         new TIntermBinary(TOperator::EOpAssign, glPosXY->deepCopy(), zRotated);
    481 
    482     // Append the assignment as a statement at the end of the shader.
    483     return RunAtTheEndOfShader(&compiler, &root, assignment, &symbolTable);
    484 }
    485 
    486454ANGLE_NO_DISCARD bool RotateAndFlipBuiltinVariable(TCompiler &compiler,
    487455                                                   TIntermBlock &root,
     
    562530    TIntermBinary &flipXY       = *CreateDriverUniformRef(driverUniforms, kFlipXY);
    563531    TIntermBinary &pivot        = *CreateDriverUniformRef(driverUniforms, kHalfRenderArea);
    564     TIntermBinary *fragRotation = (compileOptions & SH_ADD_PRE_ROTATION)
    565                                       ? CreateDriverUniformRef(driverUniforms, kFragRotation)
    566                                       : nullptr;
     532    TIntermBinary *fragRotation = nullptr;
    567533    return RotateAndFlipBuiltinVariable(compiler, root, insertSequence, flipXY,
    568534                                        *BuiltInVariable::gl_FragCoord(), kFlippedFragCoordName,
     
    12641230#endif
    12651231
    1266         bool usePreRotation = compileOptions & SH_ADD_PRE_ROTATION;
    1267 
    12681232        if (usesPointCoord)
    12691233        {
    12701234            TIntermBinary &flipXY       = *CreateDriverUniformRef(driverUniforms, kNegFlipXY);
    12711235            TIntermConstantUnion &pivot = *CreateFloatNode(0.5f);
    1272             TIntermBinary *fragRotation =
    1273                 usePreRotation ? CreateDriverUniformRef(driverUniforms, kFragRotation) : nullptr;
     1236            TIntermBinary *fragRotation = nullptr;
    12741237            if (!RotateAndFlipBuiltinVariable(*this, root, *GetMainSequence(root), flipXY,
    12751238                                              *BuiltInVariable::gl_PointCoord(),
     
    12931256        {
    12941257            TIntermBinary *flipXY = CreateDriverUniformRef(driverUniforms, kFlipXY);
    1295             TIntermBinary *fragRotation =
    1296                 usePreRotation ? CreateDriverUniformRef(driverUniforms, kFragRotation) : nullptr;
     1258            TIntermBinary *fragRotation = nullptr;
    12971259            if (!RewriteDfdy(this, &root, symbolTable, getShaderVersion(), flipXY, fragRotation))
    12981260            {
     
    13681330            return false;
    13691331        }
    1370 
    1371 
    1372 
    1373         if ((compileOptions & SH_ADD_PRE_ROTATION) != 0 &&
    1374             !AppendPreRotation(*this, root, driverUniforms))
    1375         {
    1376             return false;
    1377         }
    13781332    }
    13791333    else if (getShaderType() == GL_GEOMETRY_SHADER)
  • trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.h

    r278192 r278298  
    2424constexpr const char kAcbBufferOffsets[]          = "acbBufferOffsets";
    2525constexpr const char kDepthRange[]                = "depthRange";
    26 constexpr const char kPreRotation[]               = "preRotation";
    27 constexpr const char kFragRotation[]              = "fragRotation";
    2826constexpr const char kUnassignedAttributeString[] = " __unassigned_attribute__";
    2927
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.h

    r277824 r278298  
    501501    };
    502502
    503     // See compiler/translator/TranslatorVulkan.cpp: AddDriverUniformsToShader()
     503    // Keep this in sync with TranslatorMetalDirect.cpp: kGraphicsDriverUniformNames.
    504504    struct DriverUniforms
    505505    {
     
    523523        // We'll use x, y, z, w for near / far / diff / zscale respectively.
    524524        float depthRange[4];
    525 
    526         // Used to pre-rotate gl_Position for Vulkan swapchain images on Android (a mat2, which is
    527         // padded to the size of two vec4's).
    528         // Unused in Metal.
    529         float preRotation[8] = {};
    530 
    531         // Used to pre-rotate gl_FragCoord for Vulkan swapchain images on Android (a mat2, which is
    532         // padded to the size of two vec4's).
    533         // Unused in Metal.
    534         float fragRotation[8] = {};
    535525
    536526        uint32_t coverageMask;
  • trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/ContextMtl.mm

    r278152 r278298  
    22992299    mDriverUniforms.depthRange[3] = NeedToInvertDepthRange(depthRangeNear, depthRangeFar) ? -1 : 1;
    23002300
    2301     // NOTE(hqle): preRotation & fragRotation are unused.
    2302 
    23032301    // Sample coverage mask
    23042302    uint32_t sampleBitCount = mDrawFramebuffer->getSamples();
Note: See TracChangeset for help on using the changeset viewer.