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/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;
}