Title: [279016] trunk
Revision
279016
Author
[email protected]
Date
2021-06-17 15:35:36 -0700 (Thu, 17 Jun 2021)

Log Message

[Metal ANGLE] Shaders with reserved metal keywords do not translate, nor do shaders with struct and variable names that are the same except prefixed by an underscore
https://bugs.webkit.org/show_bug.cgi?id=226660

Source/ThirdParty/ANGLE:

Fix keyword translation problem by correcting symbol space. This avoids renaming structs unnecessarily

Reviewed by Dean Jackson.

* src/compiler/translator/TranslatorMetalDirect/RewriteKeywords.cpp:
(sh::Rewriter::createRenamed):

LayoutTests:

Reviewed by Dean Jackson.

* fast/canvas/webgl/shader-with-reserved-keyword-expected.txt: Added.
* fast/canvas/webgl/shader-with-reserved-keyword.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (279015 => 279016)


--- trunk/LayoutTests/ChangeLog	2021-06-17 22:20:37 UTC (rev 279015)
+++ trunk/LayoutTests/ChangeLog	2021-06-17 22:35:36 UTC (rev 279016)
@@ -1,3 +1,13 @@
+2021-06-17  John Cunningham  <[email protected]>
+
+        [Metal ANGLE] Shaders with reserved metal keywords do not translate, nor do shaders with struct and variable names that are the same except prefixed by an underscore
+        https://bugs.webkit.org/show_bug.cgi?id=226660
+
+        Reviewed by Dean Jackson.
+
+        * fast/canvas/webgl/shader-with-reserved-keyword-expected.txt: Added.
+        * fast/canvas/webgl/shader-with-reserved-keyword.html: Added.
+
 2021-06-17  Chris Dumez  <[email protected]>
 
         Resync DOM WPT tests from upstream

Added: trunk/LayoutTests/fast/canvas/webgl/shader-with-reserved-keyword-expected.txt (0 => 279016)


--- trunk/LayoutTests/fast/canvas/webgl/shader-with-reserved-keyword-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/shader-with-reserved-keyword-expected.txt	2021-06-17 22:35:36 UTC (rev 279016)
@@ -0,0 +1,19 @@
+Tests that program compiling/linking with a reserved keyword.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword in struct
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword in variable name
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword for struct name
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword for struct name with global struct
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword in type with global struct
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword for struct name  with global struct
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword for variable name with global struct
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword for variable name and struct name with global struct
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword in nested struct
+PASS getError was expected value: NO_ERROR : no error for using reserved keyword to access nested struct
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/webgl/shader-with-reserved-keyword.html (0 => 279016)


--- trunk/LayoutTests/fast/canvas/webgl/shader-with-reserved-keyword.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/webgl/shader-with-reserved-keyword.html	2021-06-17 22:35:36 UTC (rev 279016)
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src="" type="text/_javascript_"></script>
+    <script src="" type="text/_javascript_"></script>
+    <script src="" </script>
+    
+</head>
+<body>
+    <canvas id="webgl-canvas" width="100px" height="100px"></canvas>
+    <script>
+    var wtu = WebGLTestUtils;
+    
+    function runShaderTest(gl, vShaderSource, fshaderSource, errorShouldBeText)
+    {
+        var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
+        var program = gl.createProgram();
+        var vertexShader = gl.createShader(gl.VERTEX_SHADER);
+        gl.shaderSource(vertexShader, vShaderSource);
+        gl.compileShader(vertexShader);
+        gl.shaderSource(fragmentShader, fshaderSource);
+        gl.compileShader(fragmentShader);
+        gl.attachShader(program, vertexShader);
+        gl.attachShader(program, fragmentShader);
+        gl.linkProgram(program);
+        gl.useProgram(program);
+        gl.drawArrays(gl.TRIANGLES, 0, 3);
+        
+        wtu.glErrorShouldBe(gl,0,errorShouldBeText);
+        gl.deleteProgram(program)
+        gl.deleteShader(vertexShader);
+        gl.deleteShader(fragmentShader);
+    }
+    function runTest()
+    {
+        description("Tests that program compiling/linking with a reserved keyword.");
+        var canvas = document.getElementById('webgl-canvas');
+        var gl = canvas.getContext("webgl2");
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct s { float metal; };\n float helper(s _s) { return _s.metal; }\n void main() { s _s; float a = helper(_s); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword in struct")
+        }
+        
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct s { float a; };\n float helper(s _s) { return _s.a; }\n void main() { s metal; float a = helper(metal); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword in variable name")
+        }
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct metal { float a; };\n float helper(metal _s) { return _s.a; }\n void main() { metal _s; float a = helper(_s); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword for struct name")
+        }
+        
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct metal { float a; } _s;\n float helper(metal _s) { return _s.a; }\n void main() { metal _s; float a = helper(_s); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword for struct name with global struct ")
+        }
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct s { float metal; } _s;\n float helper(s _s) { return _s.metal; }\n void main() { _s.metal = 1.0f; float a = helper(_s); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword in type with global struct ")
+        }
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct metal { float a; } _s;\n float helper(metal _s) { return _s.a; }\n void main() { _s.a = 1.0f; float a = helper(_s); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword for struct name  with global struct ")
+        }
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct s { float a; } metal;\n float helper(s _s) { return _s.a; }\n void main() { metal.a = 1.0f; float a = helper(metal); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword for variable name with global struct ")
+        }
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct threadgroup_imageblock { float a; } metal;\n float helper(threadgroup_imageblock _s) { return _s.a; }\n void main() { metal.a = 1.0f; float a = helper(metal); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword for variable name and struct name with global struct ")
+        }
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct s { float metal; };\n struct p { s q; };\n float helper(s _s) { return _s.metal; }\n void main() { p _p; float a = helper(_p.q); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword in nested struct")
+        }
+        {
+            var vShaderSource = '#version 300 es\n in vec2 pos;\nvoid main() { gl_Position = vec4(pos, 0, 1); }'
+            var fshaderSource = '#version 300 es\n precision mediump float;\n out vec4 color;\n struct s { float metal; };\n struct p { s metal; };\n float helper(s _s) { return _s.metal; }\n void main() { p _p; float a = helper(_p.metal); color = vec4(a,0.8,0,1); }\n'
+            runShaderTest(gl, vShaderSource, fshaderSource, "no error for using reserved keyword to access nested struct")
+        }
+        
+        
+
+    }
+    runTest();
+
+    </script>
+</body>
+</html>

Modified: trunk/Source/ThirdParty/ANGLE/ChangeLog (279015 => 279016)


--- trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-06-17 22:20:37 UTC (rev 279015)
+++ trunk/Source/ThirdParty/ANGLE/ChangeLog	2021-06-17 22:35:36 UTC (rev 279016)
@@ -1,3 +1,15 @@
+2021-06-17  Kyle Piddington  <[email protected]>
+
+        [Metal ANGLE] Shaders with reserved metal keywords do not translate, nor do shaders with struct and variable names that are the same except prefixed by an underscore
+        https://bugs.webkit.org/show_bug.cgi?id=226660
+
+        Fix keyword translation problem by correcting symbol space. This avoids renaming structs unnecessarily 
+
+        Reviewed by Dean Jackson.
+
+        * src/compiler/translator/TranslatorMetalDirect/RewriteKeywords.cpp:
+        (sh::Rewriter::createRenamed):
+
 2021-06-16  Kimmo Kinnunen  <[email protected]>
 
         ANGLE Metal gl sync objects do not work in case of listener being needed

Modified: trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteKeywords.cpp (279015 => 279016)


--- trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteKeywords.cpp	2021-06-17 22:20:37 UTC (rev 279015)
+++ trunk/Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/RewriteKeywords.cpp	2021-06-17 22:35:36 UTC (rev 279016)
@@ -60,7 +60,7 @@
     {
         auto *renamed =
             new TField(const_cast<TType *>(&getRenamedOrOriginal(*field.type())),
-                       maybeCreateNewName(field), field.line(), SymbolType::AngleInternal);
+                       maybeCreateNewName(field), field.line(), field.symbolType());
 
         return renamed;
     }
@@ -78,7 +78,7 @@
     const TFunction *createRenamed(const TFunction &function)
     {
         auto *renamed =
-            new TFunction(&mSymbolTable, maybeCreateNewName(function), SymbolType::AngleInternal,
+            new TFunction(&mSymbolTable, maybeCreateNewName(function), function.symbolType(),
                           &getRenamedOrOriginal(function.getReturnType()),
                           function.isKnownToNotHaveSideEffects());
 
@@ -111,7 +111,7 @@
         auto *renamed =
             new TInterfaceBlock(&mSymbolTable, maybeCreateNewName(interfaceBlock),
                                 &getRenamedOrOriginal(interfaceBlock.fields()), layoutQualifier,
-                                SymbolType::AngleInternal, interfaceBlock.extension());
+                                interfaceBlock.symbolType(), interfaceBlock.extension());
 
         return renamed;
     }
@@ -120,7 +120,7 @@
     {
         auto *renamed =
             new TStructure(&mSymbolTable, maybeCreateNewName(structure),
-                           &getRenamedOrOriginal(structure.fields()), SymbolType::AngleInternal);
+                           &getRenamedOrOriginal(structure.fields()), structure.symbolType());
 
         renamed->setAtGlobalScope(structure.atGlobalScope());
 
@@ -134,6 +134,7 @@
         if (const TStructure *structure = type.getStruct())
         {
             renamed = new TType(&getRenamedOrOriginal(*structure), type.isStructSpecifier());
+            renamed->setQualifier(type.getQualifier());
         }
         else if (const TInterfaceBlock *interfaceBlock = type.getInterfaceBlock())
         {
@@ -162,7 +163,7 @@
     {
         auto *renamed = new TVariable(&mSymbolTable, maybeCreateNewName(variable),
                                       &getRenamedOrOriginal(variable.getType()),
-                                      SymbolType::AngleInternal, variable.extension());
+                                      variable.symbolType(), variable.extension());
 
         return renamed;
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to