Simplify symbol table setup.

Previously, `setupSymbolTable` would add a bunch of non-ES2 type aliases
to the program's symbol table if ES2 restrictions were disabled. As it
turns out, this was largely unnecessary ever since we restructured how
non-ES2 types are restricted. Nowadays, the root symbol table has all
types in it, and Type::isAllowedInES2 is used to disallow non-ES2 types
when strict ES2 mode is on. (See http://review.skia.org/459119)

The only missing piece here was that `add_glsl_type_aliases` was never
updated to add the non-square GLSL matrix alias types, and
`setupSymbolTable` papered over this. Now, `add_glsl_type_aliases` adds
these types directly.

Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512946
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Change-Id: I4a38509c9a235b93136c4afc24b300074a749182
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/523420
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 1f7b452..868324f 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -273,6 +273,16 @@
     symbols->addWithoutOwnership(types.fMat3.get());
     symbols->addWithoutOwnership(types.fMat4.get());
 
+    symbols->addWithoutOwnership(types.fMat2x2.get());
+    symbols->addWithoutOwnership(types.fMat2x3.get());
+    symbols->addWithoutOwnership(types.fMat2x4.get());
+    symbols->addWithoutOwnership(types.fMat3x2.get());
+    symbols->addWithoutOwnership(types.fMat3x3.get());
+    symbols->addWithoutOwnership(types.fMat3x4.get());
+    symbols->addWithoutOwnership(types.fMat4x2.get());
+    symbols->addWithoutOwnership(types.fMat4x3.get());
+    symbols->addWithoutOwnership(types.fMat4x4.get());
+
     // Alias every private type to "invalid". This will prevent code from using built-in names like
     // `sampler2D` as variable names.
     for (BuiltinTypePtr privateType : kPrivateTypes) {
diff --git a/src/sksl/SkSLThreadContext.cpp b/src/sksl/SkSLThreadContext.cpp
index 9b58eaf..1815bbe 100644
--- a/src/sksl/SkSLThreadContext.cpp
+++ b/src/sksl/SkSLThreadContext.cpp
@@ -69,58 +69,14 @@
 void ThreadContext::setupSymbolTable() {
     SkSL::Context& context = *fCompiler->fContext;
     SymbolTable::Push(&fCompiler->fSymbolTable, context.fConfig->fIsBuiltinCode);
-    SkSL::SymbolTable& symbols = *fCompiler->fSymbolTable;
 
     if (fSettings.fExternalFunctions) {
         // Add any external values to the new symbol table, so they're only visible to this Program.
+        SkSL::SymbolTable& symbols = *fCompiler->fSymbolTable;
         for (const std::unique_ptr<ExternalFunction>& ef : *fSettings.fExternalFunctions) {
             symbols.addWithoutOwnership(ef.get());
         }
     }
-
-    bool runtimeEffect = ProgramConfig::IsRuntimeEffect(context.fConfig->fKind);
-    if (runtimeEffect && !context.fConfig->fSettings.fEnforceES2Restrictions) {
-        // We're compiling a runtime effect, but we're not enforcing ES2 restrictions. Add various
-        // non-ES2 types to our symbol table to allow them to be tested.
-        symbols.addWithoutOwnership(context.fTypes.fMat2x2.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat2x3.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat2x4.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat3x2.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat3x3.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat3x4.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat4x2.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat4x3.get());
-        symbols.addWithoutOwnership(context.fTypes.fMat4x4.get());
-
-        symbols.addWithoutOwnership(context.fTypes.fFloat2x3.get());
-        symbols.addWithoutOwnership(context.fTypes.fFloat2x4.get());
-        symbols.addWithoutOwnership(context.fTypes.fFloat3x2.get());
-        symbols.addWithoutOwnership(context.fTypes.fFloat3x4.get());
-        symbols.addWithoutOwnership(context.fTypes.fFloat4x2.get());
-        symbols.addWithoutOwnership(context.fTypes.fFloat4x3.get());
-
-        symbols.addWithoutOwnership(context.fTypes.fHalf2x3.get());
-        symbols.addWithoutOwnership(context.fTypes.fHalf2x4.get());
-        symbols.addWithoutOwnership(context.fTypes.fHalf3x2.get());
-        symbols.addWithoutOwnership(context.fTypes.fHalf3x4.get());
-        symbols.addWithoutOwnership(context.fTypes.fHalf4x2.get());
-        symbols.addWithoutOwnership(context.fTypes.fHalf4x3.get());
-
-        symbols.addWithoutOwnership(context.fTypes.fUInt.get());
-        symbols.addWithoutOwnership(context.fTypes.fUInt2.get());
-        symbols.addWithoutOwnership(context.fTypes.fUInt3.get());
-        symbols.addWithoutOwnership(context.fTypes.fUInt4.get());
-
-        symbols.addWithoutOwnership(context.fTypes.fShort.get());
-        symbols.addWithoutOwnership(context.fTypes.fShort2.get());
-        symbols.addWithoutOwnership(context.fTypes.fShort3.get());
-        symbols.addWithoutOwnership(context.fTypes.fShort4.get());
-
-        symbols.addWithoutOwnership(context.fTypes.fUShort.get());
-        symbols.addWithoutOwnership(context.fTypes.fUShort2.get());
-        symbols.addWithoutOwnership(context.fTypes.fUShort3.get());
-        symbols.addWithoutOwnership(context.fTypes.fUShort4.get());
-    }
 }
 
 SkSL::Context& ThreadContext::Context() {