Title: [284940] branches/safari-612-branch
Revision
284940
Author
[email protected]
Date
2021-10-27 14:05:15 -0700 (Wed, 27 Oct 2021)

Log Message

Cherry-pick r281794. rdar://problem/84625240

    webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html fails
    https://bugs.webkit.org/show_bug.cgi?id=223317
    <rdar://problem/75772659>

    Patch by Kimmo Kinnunen <[email protected]> on 2021-08-31
    Reviewed by Kenneth Russell.

    Source/ThirdParty/ANGLE:

    The parser maintains invariance metadata for each input and output
    with the help of the symbol table, during parsing.

    Use this metadata through the collection phase done by CollectVariables
    section of shader compilation.

    Remove the manual tree rewrite section that collected the invariance
    information. The implementation had following problems:
    1) It would declare the variables present. This would fail the test case
    fixed here, due to the test case using invariant declarations to both
    FragColor and FragData, which would cause both to be present as outputs
    to the MSL.
    2) It would operate on rewritten variables. For example, FragCoord would
    be replaced with different variable, causing the invariance be marked
    based on the rewritten name but the later lookup intended to be done
    with the original name.

    Remove logic to mark FragCoord as invariant, as MSL specification explicitly
    says that only the vertex [[position]] output can be marked as [[invariant]].
    As noted above, this never worked.

    Fix cases where the tree rewriters assume that all variable references are
    done within functions. The global qualifier declarations are now left
    in the tree and as such can refer to variables but do not belong to any
    function.

    Fixes:
    webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
    webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html

    * ANGLE.xcodeproj/project.pbxproj:
    * src/compiler/translator/TranslatorMetalDirect.cpp:
    (sh::TranslatorMetalDirect::translateImpl):
    * src/compiler/translator/TranslatorMetalDirect/DiscoverDependentFunctions.cpp:
    * src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:
    (GenMetalTraverser::GenMetalTraverser):
    (GenMetalTraverser::emitPostQualifier):
    (GenMetalTraverser::visitGlobalQualifierDeclaration):
    (sh::EmitMetal):
    * src/compiler/translator/TranslatorMetalDirect/EmitMetal.h:
    * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.cpp: Removed.
    * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h: Removed.
    * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.cpp:
    (sh::IsVariableInvariant):
    (sh::GeneratePipelineStruct::Exec):
    (sh::GeneratePipelineStruct::GeneratePipelineStruct):
    (sh::GeneratePipelineStruct::createInternalPipelineStruct):
    (sh::UpdatePipelineSymbols):
    (sh::RewritePipeline):
    (sh::RewritePipelines):
    * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.h:
    * src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp:

    LayoutTests:

           Fixes tests:
           webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
           webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html

    * TestExpectations:
    Mark the skipped tests as Pass until all 1.0.x/2.0.y tests
    are unskipped.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281794 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Removed Paths

Diff

Modified: branches/safari-612-branch/LayoutTests/ChangeLog (284939 => 284940)


--- branches/safari-612-branch/LayoutTests/ChangeLog	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/LayoutTests/ChangeLog	2021-10-27 21:05:15 UTC (rev 284940)
@@ -1,3 +1,97 @@
+2021-10-26  Alan Coon  <[email protected]>
+
+        Cherry-pick r281794. rdar://problem/84625240
+
+    webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html fails
+    https://bugs.webkit.org/show_bug.cgi?id=223317
+    <rdar://problem/75772659>
+    
+    Patch by Kimmo Kinnunen <[email protected]> on 2021-08-31
+    Reviewed by Kenneth Russell.
+    
+    Source/ThirdParty/ANGLE:
+    
+    The parser maintains invariance metadata for each input and output
+    with the help of the symbol table, during parsing.
+    
+    Use this metadata through the collection phase done by CollectVariables
+    section of shader compilation.
+    
+    Remove the manual tree rewrite section that collected the invariance
+    information. The implementation had following problems:
+    1) It would declare the variables present. This would fail the test case
+    fixed here, due to the test case using invariant declarations to both
+    FragColor and FragData, which would cause both to be present as outputs
+    to the MSL.
+    2) It would operate on rewritten variables. For example, FragCoord would
+    be replaced with different variable, causing the invariance be marked
+    based on the rewritten name but the later lookup intended to be done
+    with the original name.
+    
+    Remove logic to mark FragCoord as invariant, as MSL specification explicitly
+    says that only the vertex [[position]] output can be marked as [[invariant]].
+    As noted above, this never worked.
+    
+    Fix cases where the tree rewriters assume that all variable references are
+    done within functions. The global qualifier declarations are now left
+    in the tree and as such can refer to variables but do not belong to any
+    function.
+    
+    Fixes:
+    webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+    webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+    
+    * ANGLE.xcodeproj/project.pbxproj:
+    * src/compiler/translator/TranslatorMetalDirect.cpp:
+    (sh::TranslatorMetalDirect::translateImpl):
+    * src/compiler/translator/TranslatorMetalDirect/DiscoverDependentFunctions.cpp:
+    * src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:
+    (GenMetalTraverser::GenMetalTraverser):
+    (GenMetalTraverser::emitPostQualifier):
+    (GenMetalTraverser::visitGlobalQualifierDeclaration):
+    (sh::EmitMetal):
+    * src/compiler/translator/TranslatorMetalDirect/EmitMetal.h:
+    * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.cpp: Removed.
+    * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h: Removed.
+    * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.cpp:
+    (sh::IsVariableInvariant):
+    (sh::GeneratePipelineStruct::Exec):
+    (sh::GeneratePipelineStruct::GeneratePipelineStruct):
+    (sh::GeneratePipelineStruct::createInternalPipelineStruct):
+    (sh::UpdatePipelineSymbols):
+    (sh::RewritePipeline):
+    (sh::RewritePipelines):
+    * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.h:
+    * src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp:
+    
+    LayoutTests:
+    
+           Fixes tests:
+           webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+           webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+    
+    * TestExpectations:
+    Mark the skipped tests as Pass until all 1.0.x/2.0.y tests
+    are unskipped.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281794 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-31  Kimmo Kinnunen  <[email protected]>
+
+            webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html fails
+            https://bugs.webkit.org/show_bug.cgi?id=223317
+            <rdar://problem/75772659>
+
+            Reviewed by Kenneth Russell.
+
+           Fixes tests:
+           webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+           webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+
+            * TestExpectations:
+            Mark the skipped tests as Pass until all 1.0.x/2.0.y tests
+            are unskipped.
+
 2021-10-25  Null  <[email protected]>
 
         Cherry-pick r284532. rdar://problem/84625267

Modified: branches/safari-612-branch/LayoutTests/TestExpectations (284939 => 284940)


--- branches/safari-612-branch/LayoutTests/TestExpectations	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/LayoutTests/TestExpectations	2021-10-27 21:05:15 UTC (rev 284940)
@@ -3683,7 +3683,9 @@
 webgl/1.0.x/conformance/canvas/to-data-url-test.html [ Pass ]
 webgl/1.0.x/conformance/misc/invalid-passed-params.html [ Pass ]
 webgl/1.0.x/conformance/glsl/bugs/character-set.html [ Pass ]
+webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html [ Pass ]
 
+
 # WebGL conformance test suite 2.0.1 is skipped until 2.0.0 is retired.
 webgl/2.0.y [ Skip ]
 
@@ -3694,6 +3696,7 @@
 
 # Explicitly turn on conformance test until all of webgl/2.0.y is enabled
 webgl/2.0.y/conformance/extensions/webgl-compressed-texture-s3tc-srgb.html [ Pass ]
+webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html [ Pass ]
 
 # WebGL 1.0.3 and 2.0.0 tests where behavior is obsolete and WebKit contains implementation
 # and tests for the new behavior. Should be removed once 1.0.3 and 2.0.0 are retired.

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj	2021-10-27 21:05:15 UTC (rev 284940)
@@ -446,7 +446,6 @@
 		DF83E23C2639FCD5000825EF /* ReduceInterfaceBlocks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FF81FF3D2581919700894E24 /* ReduceInterfaceBlocks.cpp */; };
 		DF83E23D2639FCD5000825EF /* DiscoverEnclosingFunctionTraverser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FF81FF412581919700894E24 /* DiscoverEnclosingFunctionTraverser.cpp */; };
 		DF83E23E2639FCD5000825EF /* IdGen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FF81FF512581919700894E24 /* IdGen.cpp */; };
-		DF83E23F2639FCD5000825EF /* RewriteGlobalQualifierDecls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FF81FF452581919700894E24 /* RewriteGlobalQualifierDecls.cpp */; };
 		DF83E2402639FCD5000825EF /* RewriteUnaddressableReferences.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FF81FF462581919700894E24 /* RewriteUnaddressableReferences.cpp */; };
 		DF83E2412639FCD5000825EF /* IntroduceVertexIndexID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FF33284725F6CAB9005FDFC4 /* IntroduceVertexIndexID.cpp */; };
 		DF83E2422639FCD5000825EF /* ToposortStructs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FF81FF332581919700894E24 /* ToposortStructs.cpp */; };
@@ -1716,9 +1715,7 @@
 		FF81FF402581919700894E24 /* Layout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Layout.h; sourceTree = "<group>"; };
 		FF81FF412581919700894E24 /* DiscoverEnclosingFunctionTraverser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiscoverEnclosingFunctionTraverser.cpp; sourceTree = "<group>"; };
 		FF81FF422581919700894E24 /* ProgramPrelude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgramPrelude.h; sourceTree = "<group>"; };
-		FF81FF432581919700894E24 /* RewriteGlobalQualifierDecls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RewriteGlobalQualifierDecls.h; sourceTree = "<group>"; };
 		FF81FF442581919700894E24 /* SymbolEnv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolEnv.h; sourceTree = "<group>"; };
-		FF81FF452581919700894E24 /* RewriteGlobalQualifierDecls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RewriteGlobalQualifierDecls.cpp; sourceTree = "<group>"; };
 		FF81FF462581919700894E24 /* RewriteUnaddressableReferences.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RewriteUnaddressableReferences.cpp; sourceTree = "<group>"; };
 		FF81FF472581919700894E24 /* AstHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AstHelpers.h; sourceTree = "<group>"; };
 		FF81FF482581919700894E24 /* HoistConstants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HoistConstants.cpp; sourceTree = "<group>"; };
@@ -3051,8 +3048,6 @@
 				FF81FF4B2581919700894E24 /* Reference.h */,
 				FF81FF582581919700894E24 /* RewriteCaseDeclarations.cpp */,
 				FF81FF592581919700894E24 /* RewriteCaseDeclarations.h */,
-				FF81FF452581919700894E24 /* RewriteGlobalQualifierDecls.cpp */,
-				FF81FF432581919700894E24 /* RewriteGlobalQualifierDecls.h */,
 				FF81FF4F2581919700894E24 /* RewriteKeywords.cpp */,
 				FF81FF312581919700894E24 /* RewriteKeywords.h */,
 				FF81FF362581919700894E24 /* RewriteOutArgs.cpp */,
@@ -3846,7 +3841,6 @@
 				DF83E2632639FD33000825EF /* RewriteDfdy.cpp in Sources */,
 				DF83E2742639FD33000825EF /* RewriteDoWhile.cpp in Sources */,
 				DF83E25C2639FD33000825EF /* RewriteExpressionsWithShaderStorageBlock.cpp in Sources */,
-				DF83E23F2639FCD5000825EF /* RewriteGlobalQualifierDecls.cpp in Sources */,
 				DF83E27F2639FD33000825EF /* RewriteInterpolateAtOffset.cpp in Sources */,
 				DF83E2452639FCD5000825EF /* RewriteKeywords.cpp in Sources */,
 				DF83E2342639FCD5000825EF /* RewriteOutArgs.cpp in Sources */,

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/ChangeLog (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/ChangeLog	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/ChangeLog	2021-10-27 21:05:15 UTC (rev 284940)
@@ -1,3 +1,142 @@
+2021-10-26  Alan Coon  <[email protected]>
+
+        Cherry-pick r281794. rdar://problem/84625240
+
+    webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html fails
+    https://bugs.webkit.org/show_bug.cgi?id=223317
+    <rdar://problem/75772659>
+    
+    Patch by Kimmo Kinnunen <[email protected]> on 2021-08-31
+    Reviewed by Kenneth Russell.
+    
+    Source/ThirdParty/ANGLE:
+    
+    The parser maintains invariance metadata for each input and output
+    with the help of the symbol table, during parsing.
+    
+    Use this metadata through the collection phase done by CollectVariables
+    section of shader compilation.
+    
+    Remove the manual tree rewrite section that collected the invariance
+    information. The implementation had following problems:
+    1) It would declare the variables present. This would fail the test case
+    fixed here, due to the test case using invariant declarations to both
+    FragColor and FragData, which would cause both to be present as outputs
+    to the MSL.
+    2) It would operate on rewritten variables. For example, FragCoord would
+    be replaced with different variable, causing the invariance be marked
+    based on the rewritten name but the later lookup intended to be done
+    with the original name.
+    
+    Remove logic to mark FragCoord as invariant, as MSL specification explicitly
+    says that only the vertex [[position]] output can be marked as [[invariant]].
+    As noted above, this never worked.
+    
+    Fix cases where the tree rewriters assume that all variable references are
+    done within functions. The global qualifier declarations are now left
+    in the tree and as such can refer to variables but do not belong to any
+    function.
+    
+    Fixes:
+    webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+    webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+    
+    * ANGLE.xcodeproj/project.pbxproj:
+    * src/compiler/translator/TranslatorMetalDirect.cpp:
+    (sh::TranslatorMetalDirect::translateImpl):
+    * src/compiler/translator/TranslatorMetalDirect/DiscoverDependentFunctions.cpp:
+    * src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:
+    (GenMetalTraverser::GenMetalTraverser):
+    (GenMetalTraverser::emitPostQualifier):
+    (GenMetalTraverser::visitGlobalQualifierDeclaration):
+    (sh::EmitMetal):
+    * src/compiler/translator/TranslatorMetalDirect/EmitMetal.h:
+    * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.cpp: Removed.
+    * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h: Removed.
+    * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.cpp:
+    (sh::IsVariableInvariant):
+    (sh::GeneratePipelineStruct::Exec):
+    (sh::GeneratePipelineStruct::GeneratePipelineStruct):
+    (sh::GeneratePipelineStruct::createInternalPipelineStruct):
+    (sh::UpdatePipelineSymbols):
+    (sh::RewritePipeline):
+    (sh::RewritePipelines):
+    * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.h:
+    * src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp:
+    
+    LayoutTests:
+    
+           Fixes tests:
+           webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+           webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+    
+    * TestExpectations:
+    Mark the skipped tests as Pass until all 1.0.x/2.0.y tests
+    are unskipped.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281794 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-08-31  Kimmo Kinnunen  <[email protected]>
+
+            webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html fails
+            https://bugs.webkit.org/show_bug.cgi?id=223317
+            <rdar://problem/75772659>
+
+            Reviewed by Kenneth Russell.
+
+            The parser maintains invariance metadata for each input and output
+            with the help of the symbol table, during parsing.
+
+            Use this metadata through the collection phase done by CollectVariables
+            section of shader compilation.
+
+            Remove the manual tree rewrite section that collected the invariance
+            information. The implementation had following problems:
+            1) It would declare the variables present. This would fail the test case
+            fixed here, due to the test case using invariant declarations to both
+            FragColor and FragData, which would cause both to be present as outputs
+            to the MSL.
+            2) It would operate on rewritten variables. For example, FragCoord would
+            be replaced with different variable, causing the invariance be marked
+            based on the rewritten name but the later lookup intended to be done
+            with the original name.
+
+            Remove logic to mark FragCoord as invariant, as MSL specification explicitly
+            says that only the vertex [[position]] output can be marked as [[invariant]].
+            As noted above, this never worked.
+
+            Fix cases where the tree rewriters assume that all variable references are
+            done within functions. The global qualifier declarations are now left
+            in the tree and as such can refer to variables but do not belong to any
+            function.
+
+            Fixes:
+            webgl/1.0.x/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+            webgl/2.0.y/conformance/glsl/misc/fragcolor-fragdata-invariant.html
+
+            * ANGLE.xcodeproj/project.pbxproj:
+            * src/compiler/translator/TranslatorMetalDirect.cpp:
+            (sh::TranslatorMetalDirect::translateImpl):
+            * src/compiler/translator/TranslatorMetalDirect/DiscoverDependentFunctions.cpp:
+            * src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:
+            (GenMetalTraverser::GenMetalTraverser):
+            (GenMetalTraverser::emitPostQualifier):
+            (GenMetalTraverser::visitGlobalQualifierDeclaration):
+            (sh::EmitMetal):
+            * src/compiler/translator/TranslatorMetalDirect/EmitMetal.h:
+            * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.cpp: Removed.
+            * src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h: Removed.
+            * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.cpp:
+            (sh::IsVariableInvariant):
+            (sh::GeneratePipelineStruct::Exec):
+            (sh::GeneratePipelineStruct::GeneratePipelineStruct):
+            (sh::GeneratePipelineStruct::createInternalPipelineStruct):
+            (sh::UpdatePipelineSymbols):
+            (sh::RewritePipeline):
+            (sh::RewritePipelines):
+            * src/compiler/translator/TranslatorMetalDirect/RewritePipelines.h:
+            * src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp:
+
 2021-10-25  Null  <[email protected]>
 
         Cherry-pick r284125. rdar://problem/84630015

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/DiscoverDependentFunctions.cpp (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/DiscoverDependentFunctions.cpp	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/DiscoverDependentFunctions.cpp	2021-10-27 21:05:15 UTC (rev 284940)
@@ -43,8 +43,10 @@
             return;
         }
         const TFunction *owner = discoverEnclosingFunction(symbolNode);
-        ASSERT(owner);
-        mDepFunctions.insert(owner);
+        if (owner)
+        {
+            mDepFunctions.insert(owner);
+        }
     }
 
     bool visitAggregate(Visit visit, TIntermAggregate *aggregateNode) override

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp	2021-10-27 21:05:15 UTC (rev 284940)
@@ -84,7 +84,6 @@
                       Sink &out,
                       IdGen &idGen,
                       const PipelineStructs &pipelineStructs,
-                      const Invariants &invariants,
                       SymbolEnv &symbolEnv);
 
     void visitSymbol(TIntermSymbol *) override;
@@ -183,7 +182,6 @@
     Sink &mOut;
     const TCompiler &mCompiler;
     const PipelineStructs &mPipelineStructs;
-    const Invariants &mInvariants;
     SymbolEnv &mSymbolEnv;
     IdGen &mIdGen;
     int mIndentLevel           = -1;
@@ -212,13 +210,11 @@
                                      Sink &out,
                                      IdGen &idGen,
                                      const PipelineStructs &pipelineStructs,
-                                     const Invariants &invariants,
                                      SymbolEnv &symbolEnv)
     : TIntermTraverser(true, false, false),
       mOut(out),
       mCompiler(compiler),
       mPipelineStructs(pipelineStructs),
-      mInvariants(invariants),
       mSymbolEnv(symbolEnv),
       mIdGen(idGen)
 {}
@@ -937,9 +933,12 @@
                                           const VarDecl &decl,
                                           const TQualifier qualifier)
 {
+    bool isInvariant = false;
     switch (qualifier)
     {
         case TQualifier::EvqPosition:
+            isInvariant = decl.type().isInvariant();
+            // Fallthrough.
         case TQualifier::EvqFragCoord:
             mOut << " [[position]]";
             break;
@@ -973,9 +972,6 @@
             break;
     }
 
-    const bool isInvariant =
-    (decl.isField() ? mInvariants.contains(decl.field()) : mInvariants.contains(decl.variable())) && (qualifier == TQualifier::EvqPosition || qualifier == TQualifier::EvqFragCoord);
-
     if (isInvariant)
     {
         mOut << " [[invariant]]";
@@ -2378,7 +2374,6 @@
 
 bool GenMetalTraverser::visitGlobalQualifierDeclaration(Visit, TIntermGlobalQualifierDeclaration *)
 {
-    LOGIC_ERROR();  // RewriteGlobalQualifierDecls should have been called before this.
     return false;
 }
 
@@ -2604,7 +2599,6 @@
                    TIntermBlock &root,
                    IdGen &idGen,
                    const PipelineStructs &pipelineStructs,
-                   const Invariants &invariants,
                    SymbolEnv &symbolEnv,
                    const ProgramPreludeConfig &ppc)
 {
@@ -2663,7 +2657,7 @@
 #else
         TInfoSinkBase &outWrapper = out;
 #endif
-        GenMetalTraverser gen(compiler, outWrapper, idGen, pipelineStructs, invariants, symbolEnv);
+        GenMetalTraverser gen(compiler, outWrapper, idGen, pipelineStructs, symbolEnv);
         root.traverse(&gen);
     }
 

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/EmitMetal.h (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/EmitMetal.h	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/EmitMetal.h	2021-10-27 21:05:15 UTC (rev 284940)
@@ -11,7 +11,6 @@
 #include "compiler/translator/Compiler.h"
 #include "compiler/translator/TranslatorMetalDirect/IdGen.h"
 #include "compiler/translator/TranslatorMetalDirect/ProgramPrelude.h"
-#include "compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h"
 #include "compiler/translator/TranslatorMetalDirect/RewritePipelines.h"
 #include "compiler/translator/TranslatorMetalDirect/SymbolEnv.h"
 
@@ -23,7 +22,6 @@
                                 TIntermBlock &root,
                                 IdGen &idGen,
                                 const PipelineStructs &pipelineStructs,
-                                const Invariants &invariants,
                                 SymbolEnv &symbolEnv,
                                 const ProgramPreludeConfig &ppc);
 

Deleted: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.cpp (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.cpp	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.cpp	2021-10-27 21:05:15 UTC (rev 284940)
@@ -1,114 +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.
-//
-
-#include "compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h"
-#include "compiler/translator/TranslatorMetalDirect/Debug.h"
-#include "compiler/translator/tree_util/IntermRebuild.h"
-
-using namespace sh;
-
-namespace
-{
-
-class FindDeclaredGlobals : public TIntermRebuild
-{
-  public:
-    std::unordered_set<const TVariable *> mDeclaredGlobals;
-
-    FindDeclaredGlobals(TCompiler &compiler) : TIntermRebuild(compiler, true, false) {}
-
-    PreResult visitDeclarationPre(TIntermDeclaration &declNode) override
-    {
-        TIntermNode *declaratorNode = declNode.getChildNode(0);
-        TIntermSymbol *symbolNode   = nullptr;
-
-        if (TIntermBinary *initNode = declaratorNode->getAsBinaryNode())
-        {
-            symbolNode = initNode->getLeft()->getAsSymbolNode();
-        }
-        else
-        {
-            symbolNode = declaratorNode->getAsSymbolNode();
-        }
-
-        ASSERT(symbolNode);
-        const TVariable &var = symbolNode->variable();
-
-        mDeclaredGlobals.insert(&var);
-
-        return {declNode, VisitBits::Neither};
-    }
-
-    PreResult visitFunctionDefinitionPre(TIntermFunctionDefinition &node) override
-    {
-        return {node, VisitBits::Neither};
-    }
-};
-
-class Rewriter : public TIntermRebuild
-{
-    const std::unordered_set<const TVariable *> &mDeclaredGlobals;
-    Invariants &mOutInvariants;
-
-  public:
-    Rewriter(TCompiler &compiler,
-             const std::unordered_set<const TVariable *> &declaredGlobals,
-             Invariants &outInvariants)
-        : TIntermRebuild(compiler, true, false),
-          mDeclaredGlobals(declaredGlobals),
-          mOutInvariants(outInvariants)
-    {}
-
-    PreResult visitGlobalQualifierDeclarationPre(
-        TIntermGlobalQualifierDeclaration &gqDeclNode) override
-    {
-        TIntermSymbol &symbolNode = *gqDeclNode.getSymbol();
-        const TVariable &var      = symbolNode.variable();
-
-        if (gqDeclNode.isInvariant())
-        {
-            mOutInvariants.insert(var);
-        }
-
-        if (mDeclaredGlobals.find(&var) == mDeclaredGlobals.end())
-        {
-            return *new TIntermDeclaration{&symbolNode};
-        }
-        return nullptr;
-    }
-
-    PreResult visitDeclarationPre(TIntermDeclaration &node) override
-    {
-        return {node, VisitBits::Neither};
-    }
-
-    PreResult visitFunctionDefinitionPre(TIntermFunctionDefinition &node) override
-    {
-        return {node, VisitBits::Neither};
-    }
-};
-
-}  // anonymous namespace
-
-bool sh::RewriteGlobalQualifierDecls(TCompiler &compiler,
-                                     TIntermBlock &root,
-                                     Invariants &outInvariants)
-{
-    FindDeclaredGlobals fdg(compiler);
-    if (!fdg.rebuildRoot(root))
-    {
-        LOGIC_ERROR();
-        return false;
-    }
-
-    Rewriter rewriter(compiler, fdg.mDeclaredGlobals, outInvariants);
-    if (!rewriter.rebuildRoot(root))
-    {
-        return false;
-    }
-
-    return true;
-}

Deleted: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h	2021-10-27 21:05:15 UTC (rev 284940)
@@ -1,48 +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.
-//
-
-#ifndef COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_REWRITEGLOBALQUALIFIERDECLS_H_
-#define COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_REWRITEGLOBALQUALIFIERDECLS_H_
-
-#include <unordered_set>
-
-#include "compiler/translator/Compiler.h"
-
-namespace sh
-{
-
-// Tracks TVariables and TFields that are marked as "invariant".
-class Invariants
-{
-  public:
-    void insert(const TVariable &var) { mInvariants.insert(&var); }
-
-    void insert(const TField &field) { mInvariants.insert(&field); }
-
-    bool contains(const TVariable &var) const
-    {
-        return mInvariants.find(&var) != mInvariants.end();
-    }
-
-    bool contains(const TField &field) const
-    {
-        return mInvariants.find(&field) != mInvariants.end();
-    }
-
-  private:
-    std::unordered_set<const void *> mInvariants;
-};
-
-// This rewrites TIntermGlobalQualifierDeclarations as TIntermDeclarations.
-// `outInvariants` is populated with the information that would otherwise be lost by such a
-// transform.
-ANGLE_NO_DISCARD bool RewriteGlobalQualifierDecls(TCompiler &compiler,
-                                                  TIntermBlock &root,
-                                                  Invariants &outInvariants);
-
-}  // namespace sh
-
-#endif  // COMPILER_TRANSLATOR_TRANSLATORMETALDIRECT_REWRITEGLOBALQUALIFIERDECLS_H_

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewritePipelines.cpp (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewritePipelines.cpp	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewritePipelines.cpp	2021-10-27 21:05:15 UTC (rev 284940)
@@ -27,6 +27,20 @@
 namespace
 {
 
+bool IsVariableInvariant(const std::vector<sh::ShaderVariable> &mVars, const ImmutableString &name)
+{
+    for (const auto &var : mVars)
+    {
+        if (name == var.name)
+        {
+            return var.isInvariant;
+        }
+    }
+    // TODO: this should be UNREACHABLE() but isn't because the translator generates
+    // declarations to unused built-in variables.
+    return false;
+}
+
 using VariableSet  = std::unordered_set<const TVariable *>;
 using VariableList = std::vector<const TVariable *>;
 
@@ -60,7 +74,7 @@
   private:
     const Pipeline &mPipeline;
     SymbolEnv &mSymbolEnv;
-    Invariants &mInvariants;
+    const std::vector<sh::ShaderVariable>* mVariableInfos;
     VariableList mPipelineVariableList;
     IdGen &mIdGen;
     PipelineStructInfo mInfo;
@@ -72,9 +86,9 @@
                      IdGen &idGen,
                      const Pipeline &pipeline,
                      SymbolEnv &symbolEnv,
-                     Invariants &invariants)
+                     const std::vector<sh::ShaderVariable>* variableInfos)
     {
-        GeneratePipelineStruct self(compiler, idGen, pipeline, symbolEnv, invariants);
+        GeneratePipelineStruct self(compiler, idGen, pipeline, symbolEnv, variableInfos);
         if (!self.exec(root))
         {
             return false;
@@ -88,11 +102,11 @@
                            IdGen &idGen,
                            const Pipeline &pipeline,
                            SymbolEnv &symbolEnv,
-                           Invariants &invariants)
+                           const std::vector<sh::ShaderVariable>* variableInfos)
         : TIntermRebuild(compiler, true, true),
           mPipeline(pipeline),
           mSymbolEnv(symbolEnv),
-          mInvariants(invariants),
+          mVariableInfos(variableInfos),
           mIdGen(idGen)
     {}
 
@@ -212,7 +226,6 @@
             {
                 for (const TVariable *var : mPipelineVariableList)
                 {
-                    ASSERT(!mInvariants.contains(*var));
                     const TType &varType         = var->getType();
                     const TBasicType samplerType = varType.getBasicType();
 
@@ -247,13 +260,12 @@
                 for (const TVariable *var : mPipelineVariableList)
                 {
                     auto &type  = CloneType(var->getType());
+                    if (mVariableInfos && IsVariableInvariant(*mVariableInfos, var->name()))
+                    {
+                        type.setInvariant(true);
+                    }
                     auto *field = new TField(&type, var->name(), kNoSourceLoc, var->symbolType());
                     fields.push_back(field);
-
-                    if (mInvariants.contains(*var))
-                    {
-                        mInvariants.insert(*field);
-                    }
                 }
             }
             break;
@@ -848,12 +860,13 @@
                            PipelineScoped<TVariable> pipelineMainLocalVar)
 {
     auto map = [&](const TFunction *owner, TIntermSymbol &symbol) -> TIntermNode & {
+        if (!owner)
+            return symbol;
         const TVariable &var = symbol.variable();
         if (pipelineVariables.find(&var) == pipelineVariables.end())
         {
             return symbol;
         }
-        ASSERT(owner);
         const TVariable *structInstanceVar;
         if (owner->isMain())
         {
@@ -878,7 +891,7 @@
                      IdGen &idGen,
                      const Pipeline &pipeline,
                      SymbolEnv &symbolEnv,
-                     Invariants &invariants,
+                     const std::vector<sh::ShaderVariable>* variableInfo,
                      PipelineScoped<TStructure> &outStruct)
 {
     ASSERT(outStruct.isTotallyEmpty());
@@ -886,7 +899,7 @@
     TSymbolTable &symbolTable = compiler.getSymbolTable();
 
     PipelineStructInfo psi;
-    if (!GeneratePipelineStruct::Exec(psi, compiler, root, idGen, pipeline, symbolEnv, invariants))
+    if (!GeneratePipelineStruct::Exec(psi, compiler, root, idGen, pipeline, symbolEnv, variableInfo))
     {
         return false;
     }
@@ -932,10 +945,11 @@
 
 bool sh::RewritePipelines(TCompiler &compiler,
                           TIntermBlock &root,
+                          const std::vector<sh::ShaderVariable> &inputVaryings,
+                          const std::vector<sh::ShaderVariable> &outputVaryings,
                           IdGen &idGen,
                           const TVariable &angleUniformsGlobalInstanceVar,
                           SymbolEnv &symbolEnv,
-                          Invariants &invariants,
                           PipelineStructs &outStructs)
 {
     struct Info
@@ -943,27 +957,28 @@
         Pipeline::Type pipelineType;
         PipelineScoped<TStructure> &outStruct;
         const TVariable *globalInstanceVar;
+        const std::vector<sh::ShaderVariable> *variableInfo;
     };
 
     Info infos[] = {
-        {Pipeline::Type::InstanceId, outStructs.instanceId, nullptr},
-        {Pipeline::Type::Texture, outStructs.texture, nullptr},
+        {Pipeline::Type::InstanceId, outStructs.instanceId, nullptr, nullptr},
+        {Pipeline::Type::Texture, outStructs.texture, nullptr, nullptr},
         {Pipeline::Type::NonConstantGlobals, outStructs.nonConstantGlobals, nullptr},
         {Pipeline::Type::AngleUniforms, outStructs.angleUniforms, &angleUniformsGlobalInstanceVar},
-        {Pipeline::Type::UserUniforms, outStructs.userUniforms, nullptr},
-        {Pipeline::Type::VertexIn, outStructs.vertexIn, nullptr},
-        {Pipeline::Type::VertexOut, outStructs.vertexOut, nullptr},
-        {Pipeline::Type::FragmentIn, outStructs.fragmentIn, nullptr},
-        {Pipeline::Type::FragmentOut, outStructs.fragmentOut, nullptr},
-        {Pipeline::Type::InvocationVertexGlobals, outStructs.invocationVertexGlobals, nullptr},
-        {Pipeline::Type::InvocationFragmentGlobals, outStructs.invocationFragmentGlobals, nullptr},
-        {Pipeline::Type::UniformBuffer, outStructs.uniformBuffers, nullptr},
+        {Pipeline::Type::UserUniforms, outStructs.userUniforms, nullptr, nullptr},
+        {Pipeline::Type::VertexIn, outStructs.vertexIn, nullptr, &inputVaryings},
+        {Pipeline::Type::VertexOut, outStructs.vertexOut, nullptr, &outputVaryings},
+        {Pipeline::Type::FragmentIn, outStructs.fragmentIn, nullptr, &inputVaryings},
+        {Pipeline::Type::FragmentOut, outStructs.fragmentOut, nullptr, &outputVaryings},
+        {Pipeline::Type::InvocationVertexGlobals, outStructs.invocationVertexGlobals, nullptr, nullptr},
+        {Pipeline::Type::InvocationFragmentGlobals, outStructs.invocationFragmentGlobals, nullptr, &inputVaryings},
+        {Pipeline::Type::UniformBuffer, outStructs.uniformBuffers, nullptr, nullptr},
     };
 
     for (Info &info : infos)
     {
         Pipeline pipeline{info.pipelineType, info.globalInstanceVar};
-        if (!RewritePipeline(compiler, root, idGen, pipeline, symbolEnv, invariants,
+        if (!RewritePipeline(compiler, root, idGen, pipeline, symbolEnv, info.variableInfo,
                              info.outStruct))
         {
             return false;

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewritePipelines.h (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewritePipelines.h	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewritePipelines.h	2021-10-27 21:05:15 UTC (rev 284940)
@@ -11,7 +11,6 @@
 #include "compiler/translator/Compiler.h"
 #include "compiler/translator/TranslatorMetalDirect/IdGen.h"
 #include "compiler/translator/TranslatorMetalDirect/Pipeline.h"
-#include "compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h"
 #include "compiler/translator/TranslatorMetalDirect/SymbolEnv.h"
 
 namespace sh
@@ -34,10 +33,11 @@
 //      from `main`.
 ANGLE_NO_DISCARD bool RewritePipelines(TCompiler &compiler,
                                        TIntermBlock &root,
+                                       const std::vector<sh::ShaderVariable> &inputVaryings,
+                                       const std::vector<sh::ShaderVariable> &outputVariables,
                                        IdGen &idGen,
                                        const TVariable &angleUniformsGlobalInstanceVar,
                                        SymbolEnv &symbolEnv,
-                                       Invariants &invariants,
                                        PipelineStructs &outStructs);
 
 }  // namespace sh

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/SeparateCompoundExpressions.cpp	2021-10-27 21:05:15 UTC (rev 284940)
@@ -619,7 +619,6 @@
 
     PostResult visitGlobalQualifierDeclarationPost(TIntermGlobalQualifierDeclaration &node) override
     {
-        ASSERT(false);  // These should be scrubbed from AST before rewriter is called.
         pushStmt(node);
         return node;
     }

Modified: branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp (284939 => 284940)


--- branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp	2021-10-27 20:09:21 UTC (rev 284939)
+++ branches/safari-612-branch/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect.cpp	2021-10-27 21:05:15 UTC (rev 284940)
@@ -20,7 +20,6 @@
 #include "compiler/translator/TranslatorMetalDirect/Name.h"
 #include "compiler/translator/TranslatorMetalDirect/ReduceInterfaceBlocks.h"
 #include "compiler/translator/TranslatorMetalDirect/RewriteCaseDeclarations.h"
-#include "compiler/translator/TranslatorMetalDirect/RewriteGlobalQualifierDecls.h"
 #include "compiler/translator/TranslatorMetalDirect/RewriteKeywords.h"
 #include "compiler/translator/TranslatorMetalDirect/RewriteOutArgs.h"
 #include "compiler/translator/TranslatorMetalDirect/RewritePipelines.h"
@@ -1402,11 +1401,6 @@
         return false;
     }
 
-    Invariants invariants;
-    if (!RewriteGlobalQualifierDecls(*this, root, invariants))
-    {
-        return false;
-    }
     const bool needsExplicitBoolCasts = (compileOptions & SH_ADD_EXPLICIT_BOOL_CASTS) != 0;
     if (!AddExplicitTypeCasts(*this, root, symbolEnv, needsExplicitBoolCasts))
     {
@@ -1414,8 +1408,8 @@
     }
 
     PipelineStructs pipelineStructs;
-    if (!RewritePipelines(*this, root, idGen, driverUniforms, symbolEnv, invariants,
-                          pipelineStructs))
+    if (!RewritePipelines(*this, root, getInputVaryings(), getOutputVaryings(), idGen,
+                          driverUniforms, symbolEnv, pipelineStructs))
     {
         return false;
     }
@@ -1453,7 +1447,7 @@
     {
         return false;
     }
-    if (!EmitMetal(*this, root, idGen, pipelineStructs, invariants, symbolEnv, ppc))
+    if (!EmitMetal(*this, root, idGen, pipelineStructs, symbolEnv, ppc))
     {
         return false;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to