diff --git a/Test/150.frag b/Test/150.frag
index de0905c11b15330b56f84ab76d9fc90b0744178d..16963afb0bd9bdd08b0b52e57bd8dc147f925788 100644
--- a/Test/150.frag
+++ b/Test/150.frag
@@ -43,3 +43,8 @@ void barWxyz()
     ivec4 t42 = texelFetch(ismsa, ivec3(2), samp);
     uvec4 t43 = texelFetch(usmsa, p3, samp);
 }
+
+int primitiveID()
+{
+   return gl_PrimitiveID;
+}
diff --git a/Test/440.frag b/Test/440.frag
index f5e330add65669a8fc08d5b70d4dca1da0b85f40..4eb1a3ffd2853106ec1d889a0c5f1a54efbc81e5 100644
--- a/Test/440.frag
+++ b/Test/440.frag
@@ -146,3 +146,8 @@ void interp()
     interpolateAtCentroid(sampInArray[2].xy);
     interpolateAtSample(sampInArray[2].x.x, 2);
 }
+
+int layer()
+{
+    return gl_Layer;
+}
diff --git a/Test/baseResults/150.frag.out b/Test/baseResults/150.frag.out
index f8a6fc8790276c281c7b6e6be01bbe284e1a5bd7..73bd45a11c981dcc8d2aa82600a5101dfbd4dcf4 100644
--- a/Test/baseResults/150.frag.out
+++ b/Test/baseResults/150.frag.out
@@ -101,6 +101,11 @@ ERROR: node is still EOpNull!
 0:44            'usmsa' (uniform usampler2DMSArray)
 0:44            'p3' (flat in 3-component vector of int)
 0:44            'samp' (flat in int)
+0:47  Function Definition: primitiveID( (global int)
+0:47    Function Parameters: 
+0:49    Sequence
+0:49      Branch: Return with expression
+0:49        'gl_PrimitiveID' (flat in int PrimitiveID)
 0:?   Linker Objects
 0:?     'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord)
 0:?     'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord)
@@ -216,6 +221,11 @@ ERROR: node is still EOpNull!
 0:44            'usmsa' (uniform usampler2DMSArray)
 0:44            'p3' (flat in 3-component vector of int)
 0:44            'samp' (flat in int)
+0:47  Function Definition: primitiveID( (global int)
+0:47    Function Parameters: 
+0:49    Sequence
+0:49      Branch: Return with expression
+0:49        'gl_PrimitiveID' (flat in int PrimitiveID)
 0:?   Linker Objects
 0:?     'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord)
 0:?     'gl_FragCoord' (gl_FragCoord 4-component vector of float FragCoord)
diff --git a/Test/baseResults/440.frag.out b/Test/baseResults/440.frag.out
index 799ca26080ca7b8b124a00d2ba3d0b25778898a2..0d43981eb2834a5194cf751e37053eafcaae4d59 100644
--- a/Test/baseResults/440.frag.out
+++ b/Test/baseResults/440.frag.out
@@ -77,6 +77,11 @@ ERROR: node is still EOpNull!
 0:147            0 (const int)
 0:147        Constant:
 0:147          2 (const int)
+0:150  Function Definition: layer( (global int)
+0:150    Function Parameters: 
+0:152    Sequence
+0:152      Branch: Return with expression
+0:152        'gl_Layer' (flat in int Layer)
 0:?   Linker Objects
 0:?     'a' (layout(location=4 component=2 ) smooth in 2-component vector of float)
 0:?     'b' (layout(location=4 component=1 ) smooth in float)
@@ -145,6 +150,11 @@ ERROR: node is still EOpNull!
 0:147            0 (const int)
 0:147        Constant:
 0:147          2 (const int)
+0:150  Function Definition: layer( (global int)
+0:150    Function Parameters: 
+0:152    Sequence
+0:152      Branch: Return with expression
+0:152        'gl_Layer' (flat in int Layer)
 0:?   Linker Objects
 0:?     'a' (layout(location=4 component=2 ) smooth in 2-component vector of float)
 0:?     'b' (layout(location=4 component=1 ) smooth in float)
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index d05a67312785ff1aaf2e5e3d8745db49b1af5431..80f8ec1793a426c3161af680d592161433b46358 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -3165,8 +3165,11 @@ void IdentifyBuiltIns(int version, EProfile profile, int spv, EShLanguage langua
         }
 
         symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
-        symbolTable.setVariableExtensions("gl_PrimitiveID",  Num_AEP_geometry_shader, AEP_geometry_shader);
-        symbolTable.setVariableExtensions("gl_Layer",        Num_AEP_geometry_shader, AEP_geometry_shader);
+
+        if (profile == EEsProfile) {
+            symbolTable.setVariableExtensions("gl_PrimitiveID",  Num_AEP_geometry_shader, AEP_geometry_shader);
+            symbolTable.setVariableExtensions("gl_Layer",        Num_AEP_geometry_shader, AEP_geometry_shader);
+        }
 
         if (profile == EEsProfile) {
             symbolTable.setFunctionExtensions("imageAtomicAdd",      1, &E_GL_OES_shader_image_atomic);