From 105704eff23677d0454bca77c1159d22951aa74e Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Fri, 19 Jun 2015 06:28:59 +0000
Subject: [PATCH] glslang: Finish turn on of AEP geometry shaders for ES 3.1.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31532 e7fa87d3-cd2b-0410-9028-fcbf551c1848
---
 Test/310.frag                             |  11 +
 Test/310.geom                             |  39 ++-
 Test/baseResults/310.frag.out             |  46 ++-
 Test/baseResults/310.geom.out             | 409 ++++++++++++----------
 glslang/MachineIndependent/Initialize.cpp |  10 +-
 glslang/MachineIndependent/Versions.cpp   |   4 +-
 6 files changed, 325 insertions(+), 194 deletions(-)

diff --git a/Test/310.frag b/Test/310.frag
index 1db77f2ac..d33de94be 100644
--- a/Test/310.frag
+++ b/Test/310.frag
@@ -179,6 +179,17 @@ layout(depth_any) out float gl_FragDepth;  // ERROR, non-ES
 void foo_IO()
 {
     gl_FragDepth = 0.2;  // ERROR, early_fragment_tests declared
+    gl_Layer;            // ERROR, not present
+    gl_PrimitiveID;      // ERROR, not present
+    bool f = gl_FrontFacing;
 }
 
 out float gl_FragDepth;
+
+#extension GL_OES_geometry_shader : enable
+
+void foo_GS()
+{
+    highp int l = gl_Layer;
+    highp int p = gl_PrimitiveID;
+}
diff --git a/Test/310.geom b/Test/310.geom
index 3a2df84cf..0bb813b52 100644
--- a/Test/310.geom
+++ b/Test/310.geom
@@ -1,6 +1,14 @@
 #version 310 es
 
+#ifdef GL_EXT_geometry_shader
 #extension GL_EXT_geometry_shader : enable
+#else
+#error no GL_EXT_geometry_shader 
+#endif
+
+#ifndef GL_OES_geometry_shader
+#error no GL_OES_geometry_shader
+#endif
 
 precision mediump float;
 
@@ -18,15 +26,15 @@ out fromVertex {  // okay to reuse a block name for another block name
     vec3 color;
 };
 
-out fooB {
+out fooB {        // ERROR, cannot reuse block name as block instance
     vec2 color;
-} fromVertex;     // ERROR, cannot reuse block name as block instance
+} fromVertex;
 
 int fromVertex;   // ERROR, cannot reuse a block name for something else
 
-out fooC {
+out fooC {        // ERROR, cannot have same name for block and instance name
     vec2 color;
-} fooC;           // ERROR, cannot have same name for block and instance name
+} fooC;
 
 void main()
 {
@@ -74,7 +82,7 @@ layout(lines) out;  // ERROR, not on output
 layout(lines_adjacency) in;
 layout(triangles) in;             // ERROR, can't change it
 layout(triangles_adjacency) in;   // ERROR, can't change it
-layout(invocations = 4) in;       // ERROR, not until 4.0
+layout(invocations = 4) in;
 
 in sameName {
     int a15;
@@ -107,4 +115,25 @@ void fooe1()
 {
     gl_ViewportIndex;  // ERROR, not in ES
     gl_MaxViewports;   // ERROR, not in ES
+    insn.length();     // 4: lines_adjacency
+    int inv = gl_InvocationID;
+}
+
+in vec4 explArray[4];
+in vec4 explArrayBad[5];  // ERROR, wrong size
+in vec4 nonArrayed;       // ERROR, not an array
+flat out vec3 myColor1;
+centroid out vec3 myColor2;
+centroid in vec3 centr[];
+sample out vec4 perSampleColor;  // ERROR without sample extensions
+
+layout(max_vertices = 200) out;  // matching redecl
+
+layout(location = 7, component = 2) in float comp[];  // ERROR, es has no component
+
+void notHere()
+{
+    gl_MaxGeometryVaryingComponents;  // ERROR, not in ES
+    gl_VerticesIn;                    // ERROR, not in ES
 }
+
diff --git a/Test/baseResults/310.frag.out b/Test/baseResults/310.frag.out
index f610635fe..f9c42e515 100644
--- a/Test/baseResults/310.frag.out
+++ b/Test/baseResults/310.frag.out
@@ -54,11 +54,19 @@ ERROR: 0:173: 'pixel_center_integer' : not supported with this profile: es
 ERROR: 0:173: 'redeclaration' : cannot redeclare with different qualification: gl_FragCoord
 ERROR: 0:177: 'depth layout qualifier' : not supported with this profile: es
 ERROR: 0:181: 'assign' :  l-value required "gl_FragDepth" (can't modify gl_FragDepth if using early_fragment_tests)
-ERROR: 54 compilation errors.  No code generated.
+ERROR: 0:182: 'gl_Layer' : required extension not requested: Possible extensions include:
+GL_EXT_geometry_shader
+GL_OES_geometry_shader
+ERROR: 0:183: 'gl_PrimitiveID' : required extension not requested: Possible extensions include:
+GL_EXT_geometry_shader
+GL_OES_geometry_shader
+ERROR: 56 compilation errors.  No code generated.
 
 
 Shader version: 310
 Requested GL_EXT_shader_io_blocks
+Requested GL_OES_geometry_shader
+Requested GL_OES_shader_io_blocks
 gl_FragCoord pixel center is integer
 gl_FragCoord origin is upper left
 using early_fragment_tests
@@ -315,6 +323,23 @@ ERROR: node is still EOpNull!
 0:181        'gl_FragDepth' (gl_FragDepth highp float FragDepth)
 0:181        Constant:
 0:181          0.200000
+0:182      'gl_Layer' (flat in highp int Layer)
+0:183      'gl_PrimitiveID' (flat in highp int PrimitiveID)
+0:184      Sequence
+0:184        move second child to first child (temp bool)
+0:184          'f' (temp bool)
+0:184          'gl_FrontFacing' (gl_FrontFacing bool Face)
+0:191  Function Definition: foo_GS( (global void)
+0:191    Function Parameters: 
+0:193    Sequence
+0:193      Sequence
+0:193        move second child to first child (temp highp int)
+0:193          'l' (temp highp int)
+0:193          'gl_Layer' (flat in highp int Layer)
+0:194      Sequence
+0:194        move second child to first child (temp highp int)
+0:194          'p' (temp highp int)
+0:194          'gl_PrimitiveID' (flat in highp int PrimitiveID)
 0:?   Linker Objects
 0:?     'gl_FragCoord' (smooth in mediump 4-component vector of float)
 0:?     'v3' (layout(location=2 ) smooth in mediump 3-component vector of float)
@@ -371,6 +396,8 @@ ERROR: Linking fragment stage: when more than one fragment shader output, all mu
 
 Shader version: 310
 Requested GL_EXT_shader_io_blocks
+Requested GL_OES_geometry_shader
+Requested GL_OES_shader_io_blocks
 gl_FragCoord pixel center is integer
 gl_FragCoord origin is upper left
 using early_fragment_tests
@@ -627,6 +654,23 @@ ERROR: node is still EOpNull!
 0:181        'gl_FragDepth' (gl_FragDepth highp float FragDepth)
 0:181        Constant:
 0:181          0.200000
+0:182      'gl_Layer' (flat in highp int Layer)
+0:183      'gl_PrimitiveID' (flat in highp int PrimitiveID)
+0:184      Sequence
+0:184        move second child to first child (temp bool)
+0:184          'f' (temp bool)
+0:184          'gl_FrontFacing' (gl_FrontFacing bool Face)
+0:191  Function Definition: foo_GS( (global void)
+0:191    Function Parameters: 
+0:193    Sequence
+0:193      Sequence
+0:193        move second child to first child (temp highp int)
+0:193          'l' (temp highp int)
+0:193          'gl_Layer' (flat in highp int Layer)
+0:194      Sequence
+0:194        move second child to first child (temp highp int)
+0:194          'p' (temp highp int)
+0:194          'gl_PrimitiveID' (flat in highp int PrimitiveID)
 0:?   Linker Objects
 0:?     'gl_FragCoord' (smooth in mediump 4-component vector of float)
 0:?     'v3' (layout(location=2 ) smooth in mediump 3-component vector of float)
diff --git a/Test/baseResults/310.geom.out b/Test/baseResults/310.geom.out
index 7efb5f23b..d00cce083 100644
--- a/Test/baseResults/310.geom.out
+++ b/Test/baseResults/310.geom.out
@@ -1,36 +1,41 @@
 310.geom
 Warning, version 310 is not yet complete; most version-specific features are present, but some are missing.
-WARNING: 0:3: '#extension' : extension is only partially supported: GL_EXT_geometry_shader
-ERROR: 0:21: 'fromVertex' : block instance name redefinition 
-ERROR: 0:25: 'fromVertex' : redefinition 
-ERROR: 0:27: 'fooC' : block instance name redefinition 
-ERROR: 0:35: 'EmitStreamVertex' : no matching overloaded function found 
-ERROR: 0:36: 'EndStreamPrimitive' : no matching overloaded function found 
-ERROR: 0:39: 'gl_ClipDistance' : undeclared identifier 
-ERROR: 0:39: 'gl_ClipDistance' :  left of '[' is not of type array, matrix, or vector  
-ERROR: 0:40: 'gl_ClipDistance' : no such field in structure 
-ERROR: 0:40: 'expression' :  left of '[' is not of type array, matrix, or vector  
-ERROR: 0:39: 'assign' :  l-value required (can't modify a const)
-ERROR: 0:47: 'selecting output stream' : not supported with this profile: es
-ERROR: 0:54: 'max_vertices' : too large, must be less than gl_MaxGeometryOutputVertices 
-ERROR: 0:54: 'max_vertices' : cannot change previously set layout value 
-ERROR: 0:55: 'max_vertices' : can only apply to a standalone qualifier 
-ERROR: 0:60: 'points' : cannot change previously set output primitive 
-ERROR: 0:61: 'points' : cannot change previously set output primitive 
-ERROR: 0:62: 'triangle_strip' : cannot apply to input 
-ERROR: 0:63: 'triangle_strip' : cannot apply to: uniform
-ERROR: 0:64: 'triangle_strip' : can only apply to a standalone qualifier 
-ERROR: 0:65: 'triangle_strip' : can only apply to a standalone qualifier 
-ERROR: 0:66: 'invocations' : can only apply to a standalone qualifier 
-ERROR: 0:68: 'invocations' : can only apply to a standalone qualifier 
-ERROR: 0:69: 'max_vertices' : can only apply to a standalone qualifier 
-ERROR: 0:70: 'triangle_strip' : can only apply to a standalone qualifier 
-ERROR: 0:73: 'lines' : cannot apply to 'out' 
-ERROR: 0:75: 'triangles' : cannot change previously set input primitive 
-ERROR: 0:76: 'triangles_adjacency' : cannot change previously set input primitive 
-ERROR: 0:108: 'gl_ViewportIndex' : undeclared identifier 
-ERROR: 0:109: 'gl_MaxViewports' : undeclared identifier 
-ERROR: 29 compilation errors.  No code generated.
+ERROR: 0:29: 'fromVertex' : block instance name redefinition 
+ERROR: 0:33: 'fromVertex' : redefinition 
+ERROR: 0:35: 'fooC' : block instance name redefinition 
+ERROR: 0:43: 'EmitStreamVertex' : no matching overloaded function found 
+ERROR: 0:44: 'EndStreamPrimitive' : no matching overloaded function found 
+ERROR: 0:47: 'gl_ClipDistance' : undeclared identifier 
+ERROR: 0:47: 'gl_ClipDistance' :  left of '[' is not of type array, matrix, or vector  
+ERROR: 0:48: 'gl_ClipDistance' : no such field in structure 
+ERROR: 0:48: 'expression' :  left of '[' is not of type array, matrix, or vector  
+ERROR: 0:47: 'assign' :  l-value required (can't modify a const)
+ERROR: 0:55: 'selecting output stream' : not supported with this profile: es
+ERROR: 0:62: 'max_vertices' : too large, must be less than gl_MaxGeometryOutputVertices 
+ERROR: 0:62: 'max_vertices' : cannot change previously set layout value 
+ERROR: 0:63: 'max_vertices' : can only apply to a standalone qualifier 
+ERROR: 0:68: 'points' : cannot change previously set output primitive 
+ERROR: 0:69: 'points' : cannot change previously set output primitive 
+ERROR: 0:70: 'triangle_strip' : cannot apply to input 
+ERROR: 0:71: 'triangle_strip' : cannot apply to: uniform
+ERROR: 0:72: 'triangle_strip' : can only apply to a standalone qualifier 
+ERROR: 0:73: 'triangle_strip' : can only apply to a standalone qualifier 
+ERROR: 0:74: 'invocations' : can only apply to a standalone qualifier 
+ERROR: 0:76: 'invocations' : can only apply to a standalone qualifier 
+ERROR: 0:77: 'max_vertices' : can only apply to a standalone qualifier 
+ERROR: 0:78: 'triangle_strip' : can only apply to a standalone qualifier 
+ERROR: 0:81: 'lines' : cannot apply to 'out' 
+ERROR: 0:83: 'triangles' : cannot change previously set input primitive 
+ERROR: 0:84: 'triangles_adjacency' : cannot change previously set input primitive 
+ERROR: 0:116: 'gl_ViewportIndex' : undeclared identifier 
+ERROR: 0:117: 'gl_MaxViewports' : undeclared identifier 
+ERROR: 0:123: 'lines_adjacency' : inconsistent input primitive for array size of explArrayBad
+ERROR: 0:124: 'in' : type must be an array: nonArrayed
+ERROR: 0:128: 'sample' : Reserved word. 
+ERROR: 0:132: 'component' : not supported with this profile: es
+ERROR: 0:136: 'gl_MaxGeometryVaryingComponents' : undeclared identifier 
+ERROR: 0:137: 'gl_VerticesIn' : undeclared identifier 
+ERROR: 35 compilation errors.  No code generated.
 
 
 Shader version: 310
@@ -41,82 +46,93 @@ max_vertices = 200
 input primitive = lines_adjacency
 output primitive = triangle_strip
 ERROR: node is still EOpNull!
-0:31  Function Definition: main( (global void)
-0:31    Function Parameters: 
-0:33    Sequence
-0:33      EmitVertex (global void)
-0:34      EndPrimitive (global void)
-0:35      Constant:
-0:35        0.000000
-0:36      Constant:
-0:36        0.000000
-0:38      move second child to first child (temp mediump 3-component vector of float)
-0:38        color: direct index for structure (layout(stream=0 ) out mediump 3-component vector of float)
-0:38          'anon@0' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 3-component vector of float color})
-0:38          Constant:
-0:38            0 (const uint)
-0:38        color: direct index for structure (in mediump 3-component vector of float)
-0:38          direct index (temp block{in mediump 3-component vector of float color})
-0:38            'fromV' (in 4-element array of block{in mediump 3-component vector of float color})
-0:38            Constant:
-0:38              0 (const int)
-0:38          Constant:
-0:38            0 (const int)
-0:39      move second child to first child (temp float)
-0:39        Constant:
-0:39          0.000000
-0:40        Constant:
-0:40          0.000000
-0:41      move second child to first child (temp highp 4-component vector of float)
-0:41        gl_Position: direct index for structure (layout(stream=0 ) gl_Position highp 4-component vector of float Position)
-0:41          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
-0:41          Constant:
-0:41            0 (const uint)
-0:41        gl_Position: direct index for structure (in highp 4-component vector of float Position)
-0:41          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:41            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:41            Constant:
-0:41              0 (const int)
-0:41          Constant:
-0:41            0 (const int)
-0:42      move second child to first child (temp highp float)
-0:42        gl_PointSize: direct index for structure (layout(stream=0 ) gl_PointSize highp float PointSize)
-0:42          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
-0:42          Constant:
-0:42            1 (const uint)
-0:42        gl_PointSize: direct index for structure (in highp float PointSize)
-0:42          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:42            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:42            Constant:
-0:42              3 (const int)
-0:42          Constant:
-0:42            1 (const int)
-0:43      move second child to first child (temp highp int)
-0:43        'gl_PrimitiveID' (layout(stream=0 ) out highp int PrimitiveID)
-0:43        'gl_PrimitiveIDIn' (in highp int PrimitiveID)
-0:44      move second child to first child (temp highp int)
-0:44        'gl_Layer' (layout(stream=0 ) out highp int Layer)
-0:44        Constant:
-0:44          2 (const int)
-0:55  Function Definition: foo(i1; (global void)
-0:55    Function Parameters: 
-0:55      'a' (in highp int)
-0:57    Sequence
-0:57      move second child to first child (temp mediump 4-component vector of float)
-0:57        a: direct index for structure (layout(stream=0 ) out mediump 4-component vector of float)
-0:57          'ouuaa6' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 4-component vector of float a})
-0:57          Constant:
-0:57            0 (const int)
-0:57        Constant:
-0:57          1.000000
-0:57          1.000000
-0:57          1.000000
-0:57          1.000000
-0:106  Function Definition: fooe1( (global void)
-0:106    Function Parameters: 
-0:108    Sequence
-0:108      'gl_ViewportIndex' (temp float)
-0:109      'gl_MaxViewports' (temp float)
+0:39  Function Definition: main( (global void)
+0:39    Function Parameters: 
+0:41    Sequence
+0:41      EmitVertex (global void)
+0:42      EndPrimitive (global void)
+0:43      Constant:
+0:43        0.000000
+0:44      Constant:
+0:44        0.000000
+0:46      move second child to first child (temp mediump 3-component vector of float)
+0:46        color: direct index for structure (layout(stream=0 ) out mediump 3-component vector of float)
+0:46          'anon@0' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 3-component vector of float color})
+0:46          Constant:
+0:46            0 (const uint)
+0:46        color: direct index for structure (in mediump 3-component vector of float)
+0:46          direct index (temp block{in mediump 3-component vector of float color})
+0:46            'fromV' (in 4-element array of block{in mediump 3-component vector of float color})
+0:46            Constant:
+0:46              0 (const int)
+0:46          Constant:
+0:46            0 (const int)
+0:47      move second child to first child (temp float)
+0:47        Constant:
+0:47          0.000000
+0:48        Constant:
+0:48          0.000000
+0:49      move second child to first child (temp highp 4-component vector of float)
+0:49        gl_Position: direct index for structure (layout(stream=0 ) gl_Position highp 4-component vector of float Position)
+0:49          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
+0:49          Constant:
+0:49            0 (const uint)
+0:49        gl_Position: direct index for structure (in highp 4-component vector of float Position)
+0:49          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:49            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:49            Constant:
+0:49              0 (const int)
+0:49          Constant:
+0:49            0 (const int)
+0:50      move second child to first child (temp highp float)
+0:50        gl_PointSize: direct index for structure (layout(stream=0 ) gl_PointSize highp float PointSize)
+0:50          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
+0:50          Constant:
+0:50            1 (const uint)
+0:50        gl_PointSize: direct index for structure (in highp float PointSize)
+0:50          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:50            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:50            Constant:
+0:50              3 (const int)
+0:50          Constant:
+0:50            1 (const int)
+0:51      move second child to first child (temp highp int)
+0:51        'gl_PrimitiveID' (layout(stream=0 ) out highp int PrimitiveID)
+0:51        'gl_PrimitiveIDIn' (in highp int PrimitiveID)
+0:52      move second child to first child (temp highp int)
+0:52        'gl_Layer' (layout(stream=0 ) out highp int Layer)
+0:52        Constant:
+0:52          2 (const int)
+0:63  Function Definition: foo(i1; (global void)
+0:63    Function Parameters: 
+0:63      'a' (in highp int)
+0:65    Sequence
+0:65      move second child to first child (temp mediump 4-component vector of float)
+0:65        a: direct index for structure (layout(stream=0 ) out mediump 4-component vector of float)
+0:65          'ouuaa6' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 4-component vector of float a})
+0:65          Constant:
+0:65            0 (const int)
+0:65        Constant:
+0:65          1.000000
+0:65          1.000000
+0:65          1.000000
+0:65          1.000000
+0:114  Function Definition: fooe1( (global void)
+0:114    Function Parameters: 
+0:116    Sequence
+0:116      'gl_ViewportIndex' (temp float)
+0:117      'gl_MaxViewports' (temp float)
+0:118      Constant:
+0:118        4 (const int)
+0:119      Sequence
+0:119        move second child to first child (temp highp int)
+0:119          'inv' (temp highp int)
+0:119          'gl_InvocationID' (in highp int InvocationID)
+0:134  Function Definition: notHere( (global void)
+0:134    Function Parameters: 
+0:136    Sequence
+0:136      'gl_MaxGeometryVaryingComponents' (temp float)
+0:137      'gl_VerticesIn' (temp float)
 0:?   Linker Objects
 0:?     'fromV' (in 4-element array of block{in mediump 3-component vector of float color})
 0:?     'nonBlockUnsized' (in 4-element array of mediump 4-component vector of float)
@@ -134,6 +150,14 @@ ERROR: node is still EOpNull!
 0:?     'anon@3' (layout(column_major shared ) uniform block{layout(column_major shared ) uniform bool b15})
 0:?     'summ' (const highp int)
 0:?       2752 (const int)
+0:?     'explArray' (in 4-element array of mediump 4-component vector of float)
+0:?     'explArrayBad' (in 5-element array of mediump 4-component vector of float)
+0:?     'nonArrayed' (in mediump 4-component vector of float)
+0:?     'myColor1' (layout(stream=0 ) flat out mediump 3-component vector of float)
+0:?     'myColor2' (layout(stream=0 ) centroid out mediump 3-component vector of float)
+0:?     'centr' (centroid in 4-element array of mediump 3-component vector of float)
+0:?     'perSampleColor' (layout(stream=0 ) sample out mediump 4-component vector of float)
+0:?     'comp' (layout(location=7 component=2 ) in 4-element array of mediump float)
 
 
 Linked geometry stage:
@@ -147,82 +171,93 @@ max_vertices = 200
 input primitive = lines_adjacency
 output primitive = triangle_strip
 ERROR: node is still EOpNull!
-0:31  Function Definition: main( (global void)
-0:31    Function Parameters: 
-0:33    Sequence
-0:33      EmitVertex (global void)
-0:34      EndPrimitive (global void)
-0:35      Constant:
-0:35        0.000000
-0:36      Constant:
-0:36        0.000000
-0:38      move second child to first child (temp mediump 3-component vector of float)
-0:38        color: direct index for structure (layout(stream=0 ) out mediump 3-component vector of float)
-0:38          'anon@0' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 3-component vector of float color})
-0:38          Constant:
-0:38            0 (const uint)
-0:38        color: direct index for structure (in mediump 3-component vector of float)
-0:38          direct index (temp block{in mediump 3-component vector of float color})
-0:38            'fromV' (in 4-element array of block{in mediump 3-component vector of float color})
-0:38            Constant:
-0:38              0 (const int)
-0:38          Constant:
-0:38            0 (const int)
-0:39      move second child to first child (temp float)
-0:39        Constant:
-0:39          0.000000
-0:40        Constant:
-0:40          0.000000
-0:41      move second child to first child (temp highp 4-component vector of float)
-0:41        gl_Position: direct index for structure (layout(stream=0 ) gl_Position highp 4-component vector of float Position)
-0:41          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
-0:41          Constant:
-0:41            0 (const uint)
-0:41        gl_Position: direct index for structure (in highp 4-component vector of float Position)
-0:41          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:41            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:41            Constant:
-0:41              0 (const int)
-0:41          Constant:
-0:41            0 (const int)
-0:42      move second child to first child (temp highp float)
-0:42        gl_PointSize: direct index for structure (layout(stream=0 ) gl_PointSize highp float PointSize)
-0:42          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
-0:42          Constant:
-0:42            1 (const uint)
-0:42        gl_PointSize: direct index for structure (in highp float PointSize)
-0:42          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:42            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
-0:42            Constant:
-0:42              3 (const int)
-0:42          Constant:
-0:42            1 (const int)
-0:43      move second child to first child (temp highp int)
-0:43        'gl_PrimitiveID' (layout(stream=0 ) out highp int PrimitiveID)
-0:43        'gl_PrimitiveIDIn' (in highp int PrimitiveID)
-0:44      move second child to first child (temp highp int)
-0:44        'gl_Layer' (layout(stream=0 ) out highp int Layer)
-0:44        Constant:
-0:44          2 (const int)
-0:55  Function Definition: foo(i1; (global void)
-0:55    Function Parameters: 
-0:55      'a' (in highp int)
-0:57    Sequence
-0:57      move second child to first child (temp mediump 4-component vector of float)
-0:57        a: direct index for structure (layout(stream=0 ) out mediump 4-component vector of float)
-0:57          'ouuaa6' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 4-component vector of float a})
-0:57          Constant:
-0:57            0 (const int)
-0:57        Constant:
-0:57          1.000000
-0:57          1.000000
-0:57          1.000000
-0:57          1.000000
-0:106  Function Definition: fooe1( (global void)
-0:106    Function Parameters: 
-0:108    Sequence
-0:108      'gl_ViewportIndex' (temp float)
-0:109      'gl_MaxViewports' (temp float)
+0:39  Function Definition: main( (global void)
+0:39    Function Parameters: 
+0:41    Sequence
+0:41      EmitVertex (global void)
+0:42      EndPrimitive (global void)
+0:43      Constant:
+0:43        0.000000
+0:44      Constant:
+0:44        0.000000
+0:46      move second child to first child (temp mediump 3-component vector of float)
+0:46        color: direct index for structure (layout(stream=0 ) out mediump 3-component vector of float)
+0:46          'anon@0' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 3-component vector of float color})
+0:46          Constant:
+0:46            0 (const uint)
+0:46        color: direct index for structure (in mediump 3-component vector of float)
+0:46          direct index (temp block{in mediump 3-component vector of float color})
+0:46            'fromV' (in 4-element array of block{in mediump 3-component vector of float color})
+0:46            Constant:
+0:46              0 (const int)
+0:46          Constant:
+0:46            0 (const int)
+0:47      move second child to first child (temp float)
+0:47        Constant:
+0:47          0.000000
+0:48        Constant:
+0:48          0.000000
+0:49      move second child to first child (temp highp 4-component vector of float)
+0:49        gl_Position: direct index for structure (layout(stream=0 ) gl_Position highp 4-component vector of float Position)
+0:49          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
+0:49          Constant:
+0:49            0 (const uint)
+0:49        gl_Position: direct index for structure (in highp 4-component vector of float Position)
+0:49          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:49            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:49            Constant:
+0:49              0 (const int)
+0:49          Constant:
+0:49            0 (const int)
+0:50      move second child to first child (temp highp float)
+0:50        gl_PointSize: direct index for structure (layout(stream=0 ) gl_PointSize highp float PointSize)
+0:50          'anon@1' (layout(stream=0 ) out block{layout(stream=0 ) gl_Position highp 4-component vector of float Position gl_Position, layout(stream=0 ) gl_PointSize highp float PointSize gl_PointSize})
+0:50          Constant:
+0:50            1 (const uint)
+0:50        gl_PointSize: direct index for structure (in highp float PointSize)
+0:50          direct index (temp block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:50            'gl_in' (in 4-element array of block{in highp 4-component vector of float Position gl_Position, in highp float PointSize gl_PointSize})
+0:50            Constant:
+0:50              3 (const int)
+0:50          Constant:
+0:50            1 (const int)
+0:51      move second child to first child (temp highp int)
+0:51        'gl_PrimitiveID' (layout(stream=0 ) out highp int PrimitiveID)
+0:51        'gl_PrimitiveIDIn' (in highp int PrimitiveID)
+0:52      move second child to first child (temp highp int)
+0:52        'gl_Layer' (layout(stream=0 ) out highp int Layer)
+0:52        Constant:
+0:52          2 (const int)
+0:63  Function Definition: foo(i1; (global void)
+0:63    Function Parameters: 
+0:63      'a' (in highp int)
+0:65    Sequence
+0:65      move second child to first child (temp mediump 4-component vector of float)
+0:65        a: direct index for structure (layout(stream=0 ) out mediump 4-component vector of float)
+0:65          'ouuaa6' (layout(stream=0 ) out block{layout(stream=0 ) out mediump 4-component vector of float a})
+0:65          Constant:
+0:65            0 (const int)
+0:65        Constant:
+0:65          1.000000
+0:65          1.000000
+0:65          1.000000
+0:65          1.000000
+0:114  Function Definition: fooe1( (global void)
+0:114    Function Parameters: 
+0:116    Sequence
+0:116      'gl_ViewportIndex' (temp float)
+0:117      'gl_MaxViewports' (temp float)
+0:118      Constant:
+0:118        4 (const int)
+0:119      Sequence
+0:119        move second child to first child (temp highp int)
+0:119          'inv' (temp highp int)
+0:119          'gl_InvocationID' (in highp int InvocationID)
+0:134  Function Definition: notHere( (global void)
+0:134    Function Parameters: 
+0:136    Sequence
+0:136      'gl_MaxGeometryVaryingComponents' (temp float)
+0:137      'gl_VerticesIn' (temp float)
 0:?   Linker Objects
 0:?     'fromV' (in 4-element array of block{in mediump 3-component vector of float color})
 0:?     'nonBlockUnsized' (in 4-element array of mediump 4-component vector of float)
@@ -240,4 +275,12 @@ ERROR: node is still EOpNull!
 0:?     'anon@3' (layout(column_major shared ) uniform block{layout(column_major shared ) uniform bool b15})
 0:?     'summ' (const highp int)
 0:?       2752 (const int)
+0:?     'explArray' (in 4-element array of mediump 4-component vector of float)
+0:?     'explArrayBad' (in 5-element array of mediump 4-component vector of float)
+0:?     'nonArrayed' (in mediump 4-component vector of float)
+0:?     'myColor1' (layout(stream=0 ) flat out mediump 3-component vector of float)
+0:?     'myColor2' (layout(stream=0 ) centroid out mediump 3-component vector of float)
+0:?     'centr' (centroid in 4-element array of mediump 3-component vector of float)
+0:?     'perSampleColor' (layout(stream=0 ) sample out mediump 4-component vector of float)
+0:?     'comp' (layout(location=7 component=2 ) in 4-element array of mediump float)
 
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index 5517b55d8..95485c47a 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -1474,7 +1474,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
                 stageBuiltins[EShLangVertex].append(
                     "out gl_PerVertex {"
                         "highp vec4  gl_Position;"    // needs qualifier fixed later
-                        "highp float gl_PointSize;"    // needs qualifier fixed later
+                        "highp float gl_PointSize;"   // needs qualifier fixed later
                     "};"
                     );
         }
@@ -1674,7 +1674,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
         stageBuiltins[EShLangTessEvaluation].append(
             "};"
             "\n");
-    } else {
+    } else if (profile == EEsProfile && version >= 310) {
         // Note:  "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
         // as it depends on the resource sizing of gl_MaxPatchVertices.
 
@@ -1792,7 +1792,9 @@ void TBuiltIns::initialize(int version, EProfile profile)
                 );
             if (version >= 310)
                 stageBuiltins[EShLangFragment].append(
-                        "bool  gl_HelperInvocation;"  // needs qualifier fixed later
+                    "bool gl_HelperInvocation;"    // needs qualifier fixed later
+                    "flat in highp int gl_PrimitiveID;"  // needs qualifier fixed later
+                    "flat in highp int gl_Layer;"        // needs qualifier fixed later
                     );
         }
         stageBuiltins[EShLangFragment].append(
@@ -2946,6 +2948,8 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
         }
 
         symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &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);
         break;
 
     case EShLangCompute:
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index e64732c08..7f9d5c9b6 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -181,7 +181,7 @@ void TParseContext::initializeExtensionBehavior()
     extensionBehavior[GL_OES_shader_image_atomic]                  = EBhDisablePartial;
     extensionBehavior[GL_OES_shader_multisample_interpolation]     = EBhDisablePartial;
     extensionBehavior[GL_OES_texture_storage_multisample_2d_array] = EBhDisablePartial;
-    extensionBehavior[GL_EXT_geometry_shader]                      = EBhDisablePartial;
+    extensionBehavior[GL_EXT_geometry_shader]                      = EBhDisable;
     extensionBehavior[GL_EXT_geometry_point_size]                  = EBhDisablePartial;
     extensionBehavior[GL_EXT_gpu_shader5]                          = EBhDisablePartial;
     extensionBehavior[GL_EXT_primitive_bounding_box]               = EBhDisablePartial;
@@ -192,7 +192,7 @@ void TParseContext::initializeExtensionBehavior()
     extensionBehavior[GL_EXT_texture_cube_map_array]               = EBhDisablePartial;
 
     // OES matching AEP
-    extensionBehavior[GL_OES_geometry_shader]          = EBhDisablePartial;
+    extensionBehavior[GL_OES_geometry_shader]          = EBhDisable;
     extensionBehavior[GL_OES_gpu_shader5]              = EBhDisablePartial;
     extensionBehavior[GL_OES_primitive_bounding_box]   = EBhDisablePartial;
     extensionBehavior[GL_OES_shader_io_blocks]         = EBhDisable;
-- 
GitLab