Add compute shader special variables

Support is added for the compute shader special variables given in
OpenGL GLSL ES 3.1 Revision 4, 7.1.3 Compute Shader Special Variables.
Unit tests are added for legal and illegal usage of the special
variables.

BUG=angleproject:1442

TEST=angle_unittests

Change-Id: Idb25811c15c4044c55c611c0e73ef26eb5b3e9d7
Reviewed-on: https://chromium-review.googlesource.com/366661
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/Initialize.cpp b/src/compiler/translator/Initialize.cpp
index 76bed47..0bf6ac4 100644
--- a/src/compiler/translator/Initialize.cpp
+++ b/src/compiler/translator/Initialize.cpp
@@ -683,8 +683,29 @@
                                                          TType(EbtInt, EbpHigh, EvqVertexID, 1)));
         break;
       case GL_COMPUTE_SHADER:
-          // TODO (mradev): add compute shader built-ins
-          break;
+      {
+          symbolTable.insert(ESSL3_1_BUILTINS,
+                             new TVariable(NewPoolTString("gl_NumWorkGroups"),
+                                           TType(EbtUInt, EbpUndefined, EvqNumWorkGroups, 3)));
+          symbolTable.insert(ESSL3_1_BUILTINS,
+                             new TVariable(NewPoolTString("gl_WorkGroupSize"),
+                                           TType(EbtUInt, EbpUndefined, EvqWorkGroupSize, 3)));
+          symbolTable.insert(ESSL3_1_BUILTINS,
+                             new TVariable(NewPoolTString("gl_WorkGroupID"),
+                                           TType(EbtUInt, EbpUndefined, EvqWorkGroupID, 3)));
+          symbolTable.insert(ESSL3_1_BUILTINS,
+                             new TVariable(NewPoolTString("gl_LocalInvocationID"),
+                                           TType(EbtUInt, EbpUndefined, EvqLocalInvocationID, 3)));
+          symbolTable.insert(ESSL3_1_BUILTINS,
+                             new TVariable(NewPoolTString("gl_GlobalInvocationID"),
+                                           TType(EbtUInt, EbpUndefined, EvqGlobalInvocationID, 3)));
+          symbolTable.insert(
+              ESSL3_1_BUILTINS,
+              new TVariable(NewPoolTString("gl_LocalInvocationIndex"),
+                            TType(EbtUInt, EbpUndefined, EvqLocalInvocationIndex, 1)));
+      }
+      break;
+
       default:
         assert(false && "Language not supported");
     }