Put in infrastructure for tessellation, geometry, and compute stages, and partially...
authorJohn Kessenich <cepheus@frii.com>
Fri, 9 Aug 2013 17:14:49 +0000 (17:14 +0000)
committerJohn Kessenich <cepheus@frii.com>
Fri, 9 Aug 2013 17:14:49 +0000 (17:14 +0000)
Added the built-in functions EmitVertex(), EndPrimitive(), barrier(), memoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(), memoryBarrierImage(), memoryBarrierShared(), and groupMemoryBarrier().

Have not added any new built-in variables.

Also changed the linear performance relateToOperator() to a high-performance version.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22659 e7fa87d3-cd2b-0410-9028-fcbf551c1848

28 files changed:
README.txt
StandAlone/StandAlone.cpp
Test/150.geom [new file with mode: 0644]
Test/400.geom [new file with mode: 0644]
Test/400.tesc [new file with mode: 0644]
Test/400.tese [new file with mode: 0644]
Test/420.tese [new file with mode: 0644]
Test/430.comp [new file with mode: 0644]
Test/baseResults/120.frag.out
Test/baseResults/400.geom.out [new file with mode: 0644]
Test/baseResults/400.tesc.out [new file with mode: 0644]
Test/baseResults/400.tese.out [new file with mode: 0644]
Test/baseResults/420.tese.out [new file with mode: 0644]
Test/baseResults/430.comp.out [new file with mode: 0644]
Test/baseResults/Operations.frag.out
Test/testlist
glslang/Include/intermediate.h
glslang/MachineIndependent/Constant.cpp
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/Initialize.h
glslang/MachineIndependent/Intermediate.cpp
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/ShaderLang.cpp
glslang/MachineIndependent/SymbolTable.cpp
glslang/MachineIndependent/SymbolTable.h
glslang/MachineIndependent/glslang.y
glslang/MachineIndependent/intermOut.cpp
glslang/MachineIndependent/localintermediate.h

index dd358f5..3c61ae5 100644 (file)
@@ -18,8 +18,13 @@ To use the standalone binary form, execute glslangValidator, and it will print
 a usage statement.  Basic operation is to give it a file containing a shader,
 and it will print out warnings/errors and optionally an AST.
 
-The applied stage-specific rules are based on the file extension.  Currently,
-either .frag or .vert, but soon to also include all stages.
+The applied stage-specific rules are based on the file extension:
+    .vert for a vertex shader
+    .tesc for a tessellation control shader
+    .tese for a tessellation evaluation shader
+    .geom for a geometry shader
+    .frag for a fragment shader
+    .comp for a compute shader
 
 Source: Build and run on linux
 -------------------------------
index f0a39df..ec493fd 100644 (file)
@@ -251,6 +251,8 @@ static EShLanguage FindLanguage(const std::string& name)
         return EShLangGeometry;
     else if (suffix == "frag")
         return EShLangFragment;
+    else if (suffix == "comp")
+        return EShLangCompute;
 
     usage();
     return EShLangVertex;
@@ -306,7 +308,13 @@ bool CompileFile(const char *fileName, ShHandle compiler, int debugOptions, cons
 void usage()
 {
     printf("Usage: standalone [ options ] filename\n"
-           "Where: filename is a name ending in .frag or .vert\n\n"
+           "Where: filename is a name ending in\n"
+           "    .vert for a vertex shader\n"
+           "    .tesc for a tessellation control shader\n"
+           "    .tese for a tessellation evaluation shader\n"
+           "    .geom for a geometry shader\n"
+           "    .frag for a fragment shader\n"
+           "    .comp for a compute shader\n\n"
            "Compilation warnings and errors will be printed to stdout.\n"
            "To get other information, use one of the following options:\n"
            "-i: intermediate tree (glslang AST) is printed out\n"
diff --git a/Test/150.geom b/Test/150.geom
new file mode 100644 (file)
index 0000000..4db5bd3
--- /dev/null
@@ -0,0 +1,9 @@
+#version 150 core\r
+\r
+void main()\r
+{\r
+    EmitVertex();\r
+    EndPrimitive();\r
+    EmitStreamVertex(1);    // ERROR\r
+    EndStreamPrimitive(0);  // ERROR\r
+}\r
diff --git a/Test/400.geom b/Test/400.geom
new file mode 100644 (file)
index 0000000..f8af8b2
--- /dev/null
@@ -0,0 +1,9 @@
+#version 400 core\r
+\r
+void main()\r
+{\r
+    EmitStreamVertex(1);\r
+    EndStreamPrimitive(0);\r
+    EmitVertex();\r
+    EndPrimitive();\r
+}\r
diff --git a/Test/400.tesc b/Test/400.tesc
new file mode 100644 (file)
index 0000000..855361c
--- /dev/null
@@ -0,0 +1,6 @@
+#version 400 core\r
+\r
+void main()\r
+{\r
+    barrier();\r
+}\r
diff --git a/Test/400.tese b/Test/400.tese
new file mode 100644 (file)
index 0000000..e6c4e25
--- /dev/null
@@ -0,0 +1,6 @@
+#version 400 core\r
+\r
+void main()\r
+{\r
+    barrier(); // ERROR\r
+}\r
diff --git a/Test/420.tese b/Test/420.tese
new file mode 100644 (file)
index 0000000..37a5213
--- /dev/null
@@ -0,0 +1,6 @@
+#version 420 core\r
+\r
+void main()\r
+{\r
+    memoryBarrier();\r
+}\r
diff --git a/Test/430.comp b/Test/430.comp
new file mode 100644 (file)
index 0000000..05e7bdc
--- /dev/null
@@ -0,0 +1,10 @@
+#version 430 core\r
+\r
+void main()\r
+{\r
+       memoryBarrierAtomicCounter();\r
+       memoryBarrierBuffer();\r
+       memoryBarrierShared();\r
+       memoryBarrierImage();\r
+       groupMemoryBarrier();\r
+}\r
index c0abb16..e93d647 100644 (file)
@@ -230,6 +230,28 @@ ERROR: node is still EOpNull!
 0:98        3.200000\r
 0:99      Function Call: foo(f1; (int)\r
 0:99        'a' (out float)\r
+0:102  Function Definition: gen(vf3; (bool)\r
+0:102    Function Parameters: \r
+0:102      'v' (in 3-component vector of float)\r
+0:104    Sequence\r
+0:104      Test condition and select (void)\r
+0:104        Condition\r
+0:104        logical-and (bool)\r
+0:104          Compare Less Than (bool)\r
+0:104            Absolute value (float)\r
+0:104              direct index (in float)\r
+0:104                'v' (in 3-component vector of float)\r
+0:104                0 (const int)\r
+0:104            0.000100\r
+0:104          Compare Less Than (bool)\r
+0:104            Absolute value (float)\r
+0:104              direct index (in float)\r
+0:104                'v' (in 3-component vector of float)\r
+0:104                1 (const int)\r
+0:104            0.000100\r
+0:104        true case\r
+0:105        Branch: Return with expression\r
+0:105          true (const bool)\r
 0:?   Linker Objects\r
 0:?     'i' (smooth in 4-component vector of float)\r
 0:?     'o' (out 4-component vector of float)\r
diff --git a/Test/baseResults/400.geom.out b/Test/baseResults/400.geom.out
new file mode 100644 (file)
index 0000000..edebc11
--- /dev/null
@@ -0,0 +1,10 @@
+0:3Function Definition: main( (void)\r
+0:3  Function Parameters: \r
+0:5  Sequence\r
+0:5    EmitStreamVertex (void)\r
+0:5      1 (const int)\r
+0:6    EndStreamPrimitive (void)\r
+0:6      0 (const int)\r
+0:7    EmitVertex (void)\r
+0:8    EndPrimitive (void)\r
+\r
diff --git a/Test/baseResults/400.tesc.out b/Test/baseResults/400.tesc.out
new file mode 100644 (file)
index 0000000..04ce0e4
--- /dev/null
@@ -0,0 +1,5 @@
+0:3Function Definition: main( (void)\r
+0:3  Function Parameters: \r
+0:5  Sequence\r
+0:5    Barrier (void)\r
+\r
diff --git a/Test/baseResults/400.tese.out b/Test/baseResults/400.tese.out
new file mode 100644 (file)
index 0000000..7356a2d
--- /dev/null
@@ -0,0 +1,8 @@
+ERROR: 0:5: 'barrier' : no matching overloaded function found \r
+ERROR: 1 compilation errors.  No code generated.\r
+\r
+0:3Function Definition: main( (void)\r
+0:3  Function Parameters: \r
+0:5  Sequence\r
+0:5    0.000000\r
+\r
diff --git a/Test/baseResults/420.tese.out b/Test/baseResults/420.tese.out
new file mode 100644 (file)
index 0000000..b7880b7
--- /dev/null
@@ -0,0 +1,5 @@
+0:3Function Definition: main( (void)\r
+0:3  Function Parameters: \r
+0:5  Sequence\r
+0:5    MemoryBarrier (void)\r
+\r
diff --git a/Test/baseResults/430.comp.out b/Test/baseResults/430.comp.out
new file mode 100644 (file)
index 0000000..f160633
--- /dev/null
@@ -0,0 +1,9 @@
+0:3Function Definition: main( (void)\r
+0:3  Function Parameters: \r
+0:5  Sequence\r
+0:5    MemoryBarrierAtomicCounter (void)\r
+0:6    MemoryBarrierBuffer (void)\r
+0:7    MemoryBarrierShared (void)\r
+0:8    MemoryBarrierImage (void)\r
+0:9    GroupMemoryBarrier (void)\r
+\r
index ce568bd..ff98593 100644 (file)
 0:87          'v' (4-component vector of float)\r
 0:88      add second child into first child (4-component vector of float)\r
 0:88        'v' (4-component vector of float)\r
-0:88        normalize (4-component vector of float)\r
+0:88        step (4-component vector of float)\r
+0:88          'uf' (uniform float)\r
 0:88          'v' (4-component vector of float)\r
 0:89      add second child into first child (4-component vector of float)\r
 0:89        'v' (4-component vector of float)\r
-0:89        face-forward (4-component vector of float)\r
-0:89          'v' (4-component vector of float)\r
-0:89          'v' (4-component vector of float)\r
+0:89        smoothstep (4-component vector of float)\r
+0:89          'uf' (uniform float)\r
+0:89          'uf' (uniform float)\r
 0:89          'v' (4-component vector of float)\r
 0:90      add second child into first child (4-component vector of float)\r
 0:90        'v' (4-component vector of float)\r
-0:90        reflect (4-component vector of float)\r
-0:90          'v' (4-component vector of float)\r
+0:90        normalize (4-component vector of float)\r
 0:90          'v' (4-component vector of float)\r
 0:91      add second child into first child (4-component vector of float)\r
 0:91        'v' (4-component vector of float)\r
-0:91        refract (4-component vector of float)\r
+0:91        face-forward (4-component vector of float)\r
+0:91          'v' (4-component vector of float)\r
 0:91          'v' (4-component vector of float)\r
 0:91          'v' (4-component vector of float)\r
-0:91          'uf' (uniform float)\r
 0:92      add second child into first child (4-component vector of float)\r
 0:92        'v' (4-component vector of float)\r
-0:92        dPdx (4-component vector of float)\r
+0:92        reflect (4-component vector of float)\r
+0:92          'v' (4-component vector of float)\r
 0:92          'v' (4-component vector of float)\r
 0:93      add second child into first child (4-component vector of float)\r
 0:93        'v' (4-component vector of float)\r
-0:93        dPdy (4-component vector of float)\r
+0:93        refract (4-component vector of float)\r
+0:93          'v' (4-component vector of float)\r
 0:93          'v' (4-component vector of float)\r
+0:93          'uf' (uniform float)\r
 0:94      add second child into first child (4-component vector of float)\r
 0:94        'v' (4-component vector of float)\r
-0:94        fwidth (4-component vector of float)\r
+0:94        dPdx (4-component vector of float)\r
 0:94          'v' (4-component vector of float)\r
-0:128      move second child to first child (bool)\r
-0:128        'b' (bool)\r
-0:128        any (bool)\r
-0:128          Compare Less Than (4-component vector of bool)\r
-0:128            'v' (4-component vector of float)\r
-0:128            'uv4' (uniform 4-component vector of float)\r
-0:129      move second child to first child (bool)\r
-0:129        'b' (bool)\r
-0:129        logical-and (bool)\r
-0:129          'b' (bool)\r
-0:129          any (bool)\r
-0:129            Compare Less Than or Equal (4-component vector of bool)\r
-0:129              'v' (4-component vector of float)\r
-0:129              'uv4' (uniform 4-component vector of float)\r
+0:95      add second child into first child (4-component vector of float)\r
+0:95        'v' (4-component vector of float)\r
+0:95        dPdy (4-component vector of float)\r
+0:95          'v' (4-component vector of float)\r
+0:96      add second child into first child (4-component vector of float)\r
+0:96        'v' (4-component vector of float)\r
+0:96        fwidth (4-component vector of float)\r
+0:96          'v' (4-component vector of float)\r
 0:130      move second child to first child (bool)\r
 0:130        'b' (bool)\r
-0:130        logical-and (bool)\r
-0:130          'b' (bool)\r
-0:130          any (bool)\r
-0:130            Compare Greater Than (4-component vector of bool)\r
-0:130              'v' (4-component vector of float)\r
-0:130              'uv4' (uniform 4-component vector of float)\r
+0:130        any (bool)\r
+0:130          Compare Less Than (4-component vector of bool)\r
+0:130            'v' (4-component vector of float)\r
+0:130            'uv4' (uniform 4-component vector of float)\r
 0:131      move second child to first child (bool)\r
 0:131        'b' (bool)\r
 0:131        logical-and (bool)\r
 0:131          'b' (bool)\r
 0:131          any (bool)\r
-0:131            Compare Greater Than or Equal (4-component vector of bool)\r
+0:131            Compare Less Than or Equal (4-component vector of bool)\r
 0:131              'v' (4-component vector of float)\r
 0:131              'uv4' (uniform 4-component vector of float)\r
 0:132      move second child to first child (bool)\r
 0:132        logical-and (bool)\r
 0:132          'b' (bool)\r
 0:132          any (bool)\r
-0:132            Equal (4-component vector of bool)\r
-0:132              'ub41' (uniform 4-component vector of bool)\r
-0:132              'ub42' (uniform 4-component vector of bool)\r
+0:132            Compare Greater Than (4-component vector of bool)\r
+0:132              'v' (4-component vector of float)\r
+0:132              'uv4' (uniform 4-component vector of float)\r
 0:133      move second child to first child (bool)\r
 0:133        'b' (bool)\r
 0:133        logical-and (bool)\r
 0:133          'b' (bool)\r
 0:133          any (bool)\r
-0:133            NotEqual (4-component vector of bool)\r
-0:133              'ub41' (uniform 4-component vector of bool)\r
-0:133              'ub42' (uniform 4-component vector of bool)\r
+0:133            Compare Greater Than or Equal (4-component vector of bool)\r
+0:133              'v' (4-component vector of float)\r
+0:133              'uv4' (uniform 4-component vector of float)\r
 0:134      move second child to first child (bool)\r
 0:134        'b' (bool)\r
 0:134        logical-and (bool)\r
 0:134          'b' (bool)\r
 0:134          any (bool)\r
-0:134            'ub41' (uniform 4-component vector of bool)\r
+0:134            Equal (4-component vector of bool)\r
+0:134              'ub41' (uniform 4-component vector of bool)\r
+0:134              'ub42' (uniform 4-component vector of bool)\r
 0:135      move second child to first child (bool)\r
 0:135        'b' (bool)\r
 0:135        logical-and (bool)\r
 0:135          'b' (bool)\r
-0:135          all (bool)\r
-0:135            'ub41' (uniform 4-component vector of bool)\r
+0:135          any (bool)\r
+0:135            NotEqual (4-component vector of bool)\r
+0:135              'ub41' (uniform 4-component vector of bool)\r
+0:135              'ub42' (uniform 4-component vector of bool)\r
 0:136      move second child to first child (bool)\r
 0:136        'b' (bool)\r
 0:136        logical-and (bool)\r
 0:136          'b' (bool)\r
 0:136          any (bool)\r
-0:136            Negate conditional (4-component vector of bool)\r
-0:136              'ub41' (uniform 4-component vector of bool)\r
-0:138      move second child to first child (int)\r
-0:138        'i' (int)\r
-0:138        divide (int)\r
-0:138          subtract (int)\r
-0:138            component-wise multiply (int)\r
-0:138              add (int)\r
-0:138                'i' (int)\r
-0:138                'ui' (uniform int)\r
-0:138              'i' (int)\r
-0:138            'ui' (uniform int)\r
-0:138          'i' (int)\r
-0:139      move second child to first child (int)\r
-0:139        'i' (int)\r
-0:139        mod (int)\r
-0:139          'i' (int)\r
-0:139          'ui' (uniform int)\r
-0:140      Test condition and select (void)\r
-0:140        Condition\r
-0:140        logical-or (bool)\r
-0:140          Compare Equal (bool)\r
-0:140            'i' (int)\r
-0:140            'ui' (uniform int)\r
-0:140          logical-xor (bool)\r
-0:140            logical-and (bool)\r
-0:140              Compare Not Equal (bool)\r
-0:140                'i' (int)\r
-0:140                'ui' (uniform int)\r
-0:140              Compare Equal (bool)\r
+0:136            'ub41' (uniform 4-component vector of bool)\r
+0:137      move second child to first child (bool)\r
+0:137        'b' (bool)\r
+0:137        logical-and (bool)\r
+0:137          'b' (bool)\r
+0:137          all (bool)\r
+0:137            'ub41' (uniform 4-component vector of bool)\r
+0:138      move second child to first child (bool)\r
+0:138        'b' (bool)\r
+0:138        logical-and (bool)\r
+0:138          'b' (bool)\r
+0:138          any (bool)\r
+0:138            Negate conditional (4-component vector of bool)\r
+0:138              'ub41' (uniform 4-component vector of bool)\r
+0:140      move second child to first child (int)\r
+0:140        'i' (int)\r
+0:140        divide (int)\r
+0:140          subtract (int)\r
+0:140            component-wise multiply (int)\r
+0:140              add (int)\r
 0:140                'i' (int)\r
 0:140                'ui' (uniform int)\r
-0:140            Compare Not Equal (bool)\r
 0:140              'i' (int)\r
-0:140              2 (const int)\r
-0:140        true case\r
-0:141        Pre-Increment (int)\r
+0:140            'ui' (uniform int)\r
+0:140          'i' (int)\r
+0:141      move second child to first child (int)\r
+0:141        'i' (int)\r
+0:141        mod (int)\r
 0:141          'i' (int)\r
-0:143      move second child to first child (float)\r
-0:143        'f' (float)\r
-0:143        divide (float)\r
-0:143          subtract (float)\r
-0:143            component-wise multiply (float)\r
-0:143              add (float)\r
-0:143                'uf' (uniform float)\r
-0:143                'uf' (uniform float)\r
-0:143              'uf' (uniform float)\r
-0:143            'uf' (uniform float)\r
-0:143          'uf' (uniform float)\r
-0:145      add second child into first child (float)\r
+0:141          'ui' (uniform int)\r
+0:142      Test condition and select (void)\r
+0:142        Condition\r
+0:142        logical-or (bool)\r
+0:142          Compare Equal (bool)\r
+0:142            'i' (int)\r
+0:142            'ui' (uniform int)\r
+0:142          logical-xor (bool)\r
+0:142            logical-and (bool)\r
+0:142              Compare Not Equal (bool)\r
+0:142                'i' (int)\r
+0:142                'ui' (uniform int)\r
+0:142              Compare Equal (bool)\r
+0:142                'i' (int)\r
+0:142                'ui' (uniform int)\r
+0:142            Compare Not Equal (bool)\r
+0:142              'i' (int)\r
+0:142              2 (const int)\r
+0:142        true case\r
+0:143        Pre-Increment (int)\r
+0:143          'i' (int)\r
+0:145      move second child to first child (float)\r
 0:145        'f' (float)\r
-0:145        length (float)\r
-0:145          'v' (4-component vector of float)\r
-0:146      add second child into first child (float)\r
-0:146        'f' (float)\r
-0:146        distance (float)\r
-0:146          'v' (4-component vector of float)\r
-0:146          'v' (4-component vector of float)\r
+0:145        divide (float)\r
+0:145          subtract (float)\r
+0:145            component-wise multiply (float)\r
+0:145              add (float)\r
+0:145                'uf' (uniform float)\r
+0:145                'uf' (uniform float)\r
+0:145              'uf' (uniform float)\r
+0:145            'uf' (uniform float)\r
+0:145          'uf' (uniform float)\r
 0:147      add second child into first child (float)\r
 0:147        'f' (float)\r
-0:147        dot-product (float)\r
-0:147          'v' (4-component vector of float)\r
+0:147        length (float)\r
 0:147          'v' (4-component vector of float)\r
 0:148      add second child into first child (float)\r
 0:148        'f' (float)\r
-0:148        dot-product (float)\r
-0:148          'f' (float)\r
-0:148          'uf' (uniform float)\r
+0:148        distance (float)\r
+0:148          'v' (4-component vector of float)\r
+0:148          'v' (4-component vector of float)\r
 0:149      add second child into first child (float)\r
 0:149        'f' (float)\r
-0:149        direct index (float)\r
-0:149          cross-product (3-component vector of float)\r
-0:149            vector swizzle (3-component vector of float)\r
-0:149              'v' (4-component vector of float)\r
-0:149              Sequence\r
-0:149                0 (const int)\r
-0:149                1 (const int)\r
-0:149                2 (const int)\r
-0:149            vector swizzle (3-component vector of float)\r
-0:149              'v' (4-component vector of float)\r
-0:149              Sequence\r
-0:149                0 (const int)\r
-0:149                1 (const int)\r
-0:149                2 (const int)\r
-0:149          0 (const int)\r
-0:151      Test condition and select (void)\r
-0:151        Condition\r
-0:151        logical-or (bool)\r
-0:151          Compare Equal (bool)\r
-0:151            'f' (float)\r
-0:151            'uf' (uniform float)\r
-0:151          logical-and (bool)\r
-0:151            Compare Not Equal (bool)\r
-0:151              'f' (float)\r
-0:151              'uf' (uniform float)\r
-0:151            Compare Not Equal (bool)\r
-0:151              'f' (float)\r
-0:151              2.000000\r
-0:151        true case\r
-0:152        Pre-Increment (float)\r
-0:152          'f' (float)\r
-0:154      and second child into first child (int)\r
-0:154        'i' (int)\r
-0:154        'ui' (uniform int)\r
-0:155      or second child into first child (int)\r
-0:155        'i' (int)\r
-0:155        66 (const int)\r
-0:156      exclusive or second child into first child (int)\r
+0:149        dot-product (float)\r
+0:149          'v' (4-component vector of float)\r
+0:149          'v' (4-component vector of float)\r
+0:150      add second child into first child (float)\r
+0:150        'f' (float)\r
+0:150        dot-product (float)\r
+0:150          'f' (float)\r
+0:150          'uf' (uniform float)\r
+0:151      add second child into first child (float)\r
+0:151        'f' (float)\r
+0:151        direct index (float)\r
+0:151          cross-product (3-component vector of float)\r
+0:151            vector swizzle (3-component vector of float)\r
+0:151              'v' (4-component vector of float)\r
+0:151              Sequence\r
+0:151                0 (const int)\r
+0:151                1 (const int)\r
+0:151                2 (const int)\r
+0:151            vector swizzle (3-component vector of float)\r
+0:151              'v' (4-component vector of float)\r
+0:151              Sequence\r
+0:151                0 (const int)\r
+0:151                1 (const int)\r
+0:151                2 (const int)\r
+0:151          0 (const int)\r
+0:153      Test condition and select (void)\r
+0:153        Condition\r
+0:153        logical-or (bool)\r
+0:153          Compare Equal (bool)\r
+0:153            'f' (float)\r
+0:153            'uf' (uniform float)\r
+0:153          logical-and (bool)\r
+0:153            Compare Not Equal (bool)\r
+0:153              'f' (float)\r
+0:153              'uf' (uniform float)\r
+0:153            Compare Not Equal (bool)\r
+0:153              'f' (float)\r
+0:153              2.000000\r
+0:153        true case\r
+0:154        Pre-Increment (float)\r
+0:154          'f' (float)\r
+0:156      and second child into first child (int)\r
 0:156        'i' (int)\r
 0:156        'ui' (uniform int)\r
-0:157      mod second child into first child (int)\r
+0:157      or second child into first child (int)\r
 0:157        'i' (int)\r
-0:157        17 (const int)\r
-0:158      right shift second child into first child (int)\r
+0:157        66 (const int)\r
+0:158      exclusive or second child into first child (int)\r
 0:158        'i' (int)\r
-0:158        2 (const int)\r
-0:159      left shift second child into first child (int)\r
+0:158        'ui' (uniform int)\r
+0:159      mod second child into first child (int)\r
 0:159        'i' (int)\r
-0:159        'ui' (uniform int)\r
-0:160      move second child to first child (int)\r
+0:159        17 (const int)\r
+0:160      right shift second child into first child (int)\r
 0:160        'i' (int)\r
-0:160        Bitwise not (int)\r
-0:160          'i' (int)\r
-0:161      move second child to first child (bool)\r
-0:161        'b' (bool)\r
-0:161        Negate conditional (bool)\r
-0:161          'b' (bool)\r
-0:163      move second child to first child (4-component vector of float)\r
-0:163        'gl_FragColor' (fragColor 4-component vector of float)\r
-0:163        Test condition and select (4-component vector of float)\r
-0:163          Condition\r
+0:160        2 (const int)\r
+0:161      left shift second child into first child (int)\r
+0:161        'i' (int)\r
+0:161        'ui' (uniform int)\r
+0:162      move second child to first child (int)\r
+0:162        'i' (int)\r
+0:162        Bitwise not (int)\r
+0:162          'i' (int)\r
+0:163      move second child to first child (bool)\r
+0:163        'b' (bool)\r
+0:163        Negate conditional (bool)\r
 0:163          'b' (bool)\r
-0:163          true case\r
-0:163          add (4-component vector of float)\r
-0:163            add (4-component vector of float)\r
-0:163              Construct vec4 (4-component vector of float)\r
-0:163                Convert int to float (float)\r
-0:163                  'i' (int)\r
-0:163              Construct vec4 (4-component vector of float)\r
-0:163                'f' (float)\r
-0:163            'v' (4-component vector of float)\r
-0:163          false case\r
-0:163          'v' (4-component vector of float)\r
+0:165      move second child to first child (4-component vector of float)\r
+0:165        'gl_FragColor' (fragColor 4-component vector of float)\r
+0:165        Test condition and select (4-component vector of float)\r
+0:165          Condition\r
+0:165          'b' (bool)\r
+0:165          true case\r
+0:165          add (4-component vector of float)\r
+0:165            add (4-component vector of float)\r
+0:165              Construct vec4 (4-component vector of float)\r
+0:165                Convert int to float (float)\r
+0:165                  'i' (int)\r
+0:165              Construct vec4 (4-component vector of float)\r
+0:165                'f' (float)\r
+0:165            'v' (4-component vector of float)\r
+0:165          false case\r
+0:165          'v' (4-component vector of float)\r
 0:?   Linker Objects\r
 0:?     'uiv4' (uniform 4-component vector of int)\r
 0:?     'uv4' (uniform 4-component vector of float)\r
index f3d2d4b..32c1882 100644 (file)
@@ -44,6 +44,11 @@ tokenLength.vert
 430scope.vert
 lineContinuation.vert
 numeral.frag
+400.geom
+400.tesc
+400.tese
+420.tese
+430.comp
 ../../LunarGLASS/test/aggOps.frag
 ../../LunarGLASS/test/always-discard.frag
 ../../LunarGLASS/test/always-discard2.frag
index ae22cf3..4c7cf1c 100644 (file)
@@ -213,6 +213,19 @@ enum TOperator {
     EOpMatrixInverse,
     EOpTranspose,
 
+    EOpEmitVertex,           // geometry only
+    EOpEndPrimitive,         // geometry only
+    EOpEmitStreamVertex,     // geometry only
+    EOpEndStreamPrimitive,   // geometry only
+
+    EOpBarrier,
+    EOpMemoryBarrier,
+    EOpMemoryBarrierAtomicCounter,
+    EOpMemoryBarrierBuffer,
+    EOpMemoryBarrierImage,
+    EOpMemoryBarrierShared,  // compute only
+    EOpGroupMemoryBarrier,   // compute only
+
     EOpAny,
     EOpAll,
 
index 742fd90..d110513 100644 (file)
@@ -402,6 +402,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
         newConstArray = new constUnion[1];
         break;
 
+    case EOpEmitStreamVertex:
+    case EOpEndStreamPrimitive:
+        // These don't actually fold
+        return 0;
+
     default:
         newConstArray = new constUnion[objectSize];
     }
index 8364a26..6201763 100644 (file)
@@ -75,13 +75,6 @@ void TBuiltIns::initialize(int version, EProfile profile)
     //
     // Initialize all the built-in strings for parsing.
     //
-    TString BuiltInFunctions;
-    TString BuiltInFunctionsVertex;
-    TString BuiltInFunctionsFragment;
-    TString StandardVertexVaryings;
-    TString StandardFragmentVaryings;
-    TString StandardVertexAttributes;
-    TString StandardUniforms;
 
     {
         //============================================================================
@@ -90,7 +83,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
         //
         //============================================================================
 
-        TString& s = BuiltInFunctions;
+        TString& s = commonBuiltins;
 
         //
         // Angle and Trigonometric Functions.
@@ -655,7 +648,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
         //
         //============================================================================
 
-        TString& s = BuiltInFunctionsVertex;
+        TString& s = stageBuiltins[EShLangVertex];
 
         //
         // Geometric Functions.
@@ -685,6 +678,45 @@ void TBuiltIns::initialize(int version, EProfile profile)
         }
                s.append(TString("\n"));
     }
+    if (profile != EEsProfile && version >= 150) {
+        //============================================================================
+        //
+        // Prototypes for built-in functions seen by geometry shaders only.
+        //
+        //============================================================================
+
+        TString& s = stageBuiltins[EShLangGeometry];
+
+        if (version >= 400) {
+            s.append(TString("void EmitStreamVertex(int);"));
+            s.append(TString("void EndStreamPrimitive(int);"));
+        }
+        s.append(TString("void EmitVertex();"));
+        s.append(TString("void EndPrimitive();"));
+               s.append(TString("\n"));
+    }
+    if (profile != EEsProfile) {
+        //============================================================================
+        //
+        // Prototypes for all control functions.
+        //
+        //============================================================================
+
+        if (version >= 400)
+            stageBuiltins[EShLangTessControl].append("void barrier();");
+        if (version >= 430)
+            stageBuiltins[EShLangCompute].append("void barrier();");
+
+        if (version >= 420)
+            commonBuiltins.append("void memoryBarrier();");
+        if (version >= 430) {
+            commonBuiltins.append("void memoryBarrierAtomicCounter();");
+            commonBuiltins.append("void memoryBarrierBuffer();");
+            commonBuiltins.append("void memoryBarrierImage();");
+            stageBuiltins[EShLangCompute].append("void memoryBarrierShared();");
+            stageBuiltins[EShLangCompute].append("void groupMemoryBarrier();");
+        }
+    }
     {
         //============================================================================
         //
@@ -692,7 +724,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
         //
         //============================================================================
 
-        TString& s = BuiltInFunctionsFragment;
+        TString& s = stageBuiltins[EShLangFragment];
 
         //
         // Original-style texture Functions with bias.
@@ -739,7 +771,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
         //
         //============================================================================
 
-        TString& s = StandardUniforms;
+        TString& s = commonBuiltins;
 
         //
         // Depth range in window coordinates, p. 33
@@ -884,7 +916,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
     //============================================================================
 
     if (profile != EEsProfile) {
-        TString& s = StandardVertexAttributes;
+        TString& s = stageBuiltins[EShLangVertex];
 
         if (version < 130) {
             s.append(TString("attribute vec4  gl_Color;"));
@@ -925,7 +957,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
     //============================================================================
 
     if (profile != EEsProfile) {
-        TString& s = StandardVertexVaryings;
+        TString& s = stageBuiltins[EShLangVertex];
 
         if (version < 130) {
             s.append(TString("varying vec4  gl_FrontColor;"));
@@ -953,7 +985,7 @@ void TBuiltIns::initialize(int version, EProfile profile)
         //============================================================================
 
         if (profile != EEsProfile) {
-            TString& s = StandardFragmentVaryings;
+            TString& s = stageBuiltins[EShLangFragment];
             if (version < 130) {
                 s.append(TString("varying vec4  gl_Color;"));
                 s.append(TString("varying vec4  gl_SecondaryColor;"));
@@ -970,29 +1002,8 @@ void TBuiltIns::initialize(int version, EProfile profile)
         }
     }
 
-    builtInStrings[EShLangFragment].push_back(BuiltInFunctions);
-    builtInStrings[EShLangFragment].push_back(BuiltInFunctionsFragment);
-    builtInStrings[EShLangFragment].push_back(StandardUniforms);
-    builtInStrings[EShLangFragment].push_back(StandardFragmentVaryings);
-
-    builtInStrings[EShLangVertex].push_back(BuiltInFunctions);
-    builtInStrings[EShLangVertex].push_back(BuiltInFunctionsVertex);
-    builtInStrings[EShLangVertex].push_back(StandardVertexVaryings);
-    builtInStrings[EShLangVertex].push_back(StandardVertexAttributes);
-    builtInStrings[EShLangVertex].push_back(StandardUniforms);
-
     if (version >= 130)
         add2ndGenerationSamplingImaging(version, profile);
-
-#ifdef TEST_MODE
-    printf("VERTEX SYMBOLS \n");
-    for (unsigned int i = 0; i < builtInStrings[EShLangVertex].size(); ++i)
-        printf("%s", builtInStrings[EShLangVertex][i].c_str());
-    
-    printf("FRAGMENT SYMBOLS \n");
-    for (unsigned int i = 0; i < builtInStrings[EShLangFragment].size(); ++i)
-        printf("%s", builtInStrings[EShLangFragment][i].c_str());
-#endif
 }
 
 void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile)
@@ -1074,7 +1085,7 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, TString& typeName, int versi
     if (version < 430 && sampler.image)
         return;
 
-    TString s;
+    TString& s = commonBuiltins;
     if (profile == EEsProfile)
         s.append("highp ");
     int dims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0) - (sampler.dim == EsdCube ? 1 : 0);
@@ -1093,8 +1104,6 @@ void TBuiltIns::addQueryFunctions(TSampler sampler, TString& typeName, int versi
         s.append(",int);\n");
     else
         s.append(");\n");
-    builtInStrings[EShLangFragment].push_back(s);
-    builtInStrings[EShLangVertex].push_back(s);
 
     // TODO: 4.2 Functionality: imaging functions
 }
@@ -1268,9 +1277,12 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
 
                                 if (! bias) {
                                     functions[EShLangVertex].append(s);
-                                    // all stages other than fragment get this here too
+                                    functions[EShLangGeometry].append(s);
+                                    functions[EShLangTessControl].append(s);
+                                    functions[EShLangTessEvaluation].append(s);
+                                    functions[EShLangCompute].append(s);
                                 }
-                                functions[EShLangFragment].append(s);
+                                commonBuiltins.append(s);
                             }
                         }
                     }
@@ -1278,9 +1290,6 @@ void TBuiltIns::addSamplingFunctions(TSampler sampler, TString& typeName, int ve
             }
         }
     }
-
-    builtInStrings[EShLangVertex].push_back(functions[EShLangVertex]);
-    builtInStrings[EShLangFragment].push_back(functions[EShLangFragment]);
 }
 
 void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProfile profile, EShLanguage language)
@@ -1288,8 +1297,6 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
     //
     // Initialize the context-dependent (resource-dependent) built-in strings for parsing.
     //
-    TString StandardUniforms;
-
     {
         //============================================================================
         //
@@ -1297,7 +1304,7 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
         //
         //============================================================================
 
-        TString& s = StandardUniforms;
+        TString& s = commonBuiltins;
                const int maxSize = 80;
         char builtInConstant[maxSize];
 
@@ -1435,9 +1442,6 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
 
         s.append(TString("\n"));
     }
-
-    builtInStrings[EShLangFragment].push_back(StandardUniforms);
-    builtInStrings[EShLangVertex].push_back(StandardUniforms);
 }
 
 void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymbolTable& symbolTable)
@@ -1448,6 +1452,30 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
     // the built-in text strings.
     //
     switch(language) {
+    case EShLangVertex:
+        pq = profile == EEsProfile ? EpqHigh : EpqNone;
+        symbolTable.insert(*new TVariable(NewPoolTString("gl_Position"),    TType(EbtFloat, EvqPosition, pq, 4)));
+
+        pq = profile == EEsProfile ? (version > 100 ? EpqHigh : EpqMedium) : EpqNone;
+        symbolTable.insert(*new TVariable(NewPoolTString("gl_PointSize"),   TType(EbtFloat, EvqPointSize, pq, 1)));
+
+        if (profile != EEsProfile)
+            symbolTable.insert(*new TVariable(NewPoolTString("gl_ClipVertex"),  TType(EbtFloat, EvqClipVertex, 4)));
+
+        if (version >= 130) {
+            pq = profile == EEsProfile ? EpqHigh : EpqNone;
+            symbolTable.insert(*new TVariable(NewPoolTString("gl_VertexID"),    TType(EbtInt, EvqVertexId, pq, 1)));
+            if (version >= 140)
+                symbolTable.insert(*new TVariable(NewPoolTString("gl_InstanceID"),  TType(EbtInt, EvqInstanceId, pq, 1)));
+        }
+        break;
+
+    case EShLangTessControl:
+    case EShLangTessEvaluation:
+    case EShLangGeometry:
+        // TODO: desktop functionality: support new stages
+        break;
+
     case EShLangFragment:
         symbolTable.insert(*new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool,  EvqFace, 1)));
 
@@ -1473,28 +1501,9 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
         }
         break;
 
-    case EShLangVertex:
-        pq = profile == EEsProfile ? EpqHigh : EpqNone;
-        symbolTable.insert(*new TVariable(NewPoolTString("gl_Position"),    TType(EbtFloat, EvqPosition, pq, 4)));
-
-        pq = profile == EEsProfile ? (version > 100 ? EpqHigh : EpqMedium) : EpqNone;
-        symbolTable.insert(*new TVariable(NewPoolTString("gl_PointSize"),   TType(EbtFloat, EvqPointSize, pq, 1)));
-
-        if (profile != EEsProfile)
-            symbolTable.insert(*new TVariable(NewPoolTString("gl_ClipVertex"),  TType(EbtFloat, EvqClipVertex, 4)));
-
-        if (version >= 130) {
-            pq = profile == EEsProfile ? EpqHigh : EpqNone;
-            symbolTable.insert(*new TVariable(NewPoolTString("gl_VertexID"),    TType(EbtInt, EvqVertexId, pq, 1)));
-            if (version >= 140)
-                symbolTable.insert(*new TVariable(NewPoolTString("gl_InstanceID"),  TType(EbtInt, EvqInstanceId, pq, 1)));
-        }
-        break;
-
-    case EShLangTessControl:
-    case EShLangTessEvaluation:
-    case EShLangGeometry:
+    case EShLangCompute:
         // TODO: desktop functionality: support new stages
+        break;
     
     default:
         assert(false && "Language not supported");
@@ -1593,19 +1602,40 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
     symbolTable.relateToOperator("any",          EOpAny);
     symbolTable.relateToOperator("all",          EOpAll);
 
-    switch(language) {
+    symbolTable.relateToOperator("barrier",                    EOpBarrier);
+    symbolTable.relateToOperator("memoryBarrier",              EOpMemoryBarrier);
+    symbolTable.relateToOperator("memoryBarrierAtomicCounter", EOpMemoryBarrierAtomicCounter);
+    symbolTable.relateToOperator("memoryBarrierBuffer",        EOpMemoryBarrierBuffer);
+    symbolTable.relateToOperator("memoryBarrierImage",         EOpMemoryBarrierImage);
 
+    switch(language) {
     case EShLangVertex:
         break;
 
+    case EShLangTessControl:
+    case EShLangTessEvaluation:
+        break;
+
+    case EShLangGeometry:
+        symbolTable.relateToOperator("EmitStreamVertex",   EOpEmitStreamVertex);
+        symbolTable.relateToOperator("EndStreamPrimitive", EOpEndStreamPrimitive);
+        symbolTable.relateToOperator("EmitVertex",         EOpEmitVertex);
+        symbolTable.relateToOperator("EndPrimitive",       EOpEndPrimitive);
+        break;
+
     case EShLangFragment:
         symbolTable.relateToOperator("dFdx",         EOpDPdx);
         symbolTable.relateToOperator("dFdy",         EOpDPdy);
         symbolTable.relateToOperator("fwidth",       EOpFwidth);
+        break;
 
+    case EShLangCompute:
+        symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
+        symbolTable.relateToOperator("groupMemoryBarrier",  EOpGroupMemoryBarrier);
         break;
 
-       default: assert(false && "Language not supported");
+       default: 
+        assert(false && "Language not supported");
     }
 }
 
@@ -1628,6 +1658,7 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
         }
         break;
 
-       default: break;
+       default: 
+        break;
     }
 }
index 34d86b1..ef2986d 100644 (file)
@@ -43,8 +43,6 @@
 #include "SymbolTable.h"
 #include "Versions.h"
 
-typedef TVector<TString> TBuiltInStrings;
-
 class TBuiltIns {
 public:
     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
@@ -52,7 +50,8 @@ public:
     virtual ~TBuiltIns();
     void initialize(int version, EProfile);
        void initialize(const TBuiltInResource& resources, int version, EProfile, EShLanguage);
-    TBuiltInStrings* getBuiltInStrings() { return builtInStrings; }
+    const TString& getCommonString() const { return commonBuiltins; }
+    const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; }
 
 protected:
     void add2ndGenerationSamplingImaging(int version, EProfile profile);
@@ -60,7 +59,8 @@ protected:
     void addImageFunctions(TSampler, TString& typeName, int version, EProfile profile);
     void addSamplingFunctions(TSampler, TString& typeName, int version, EProfile profile);
 
-    TBuiltInStrings builtInStrings[EShLangCount];
+    TString commonBuiltins;
+    TString stageBuiltins[EShLangCount];
 
     // Helpers for making text
     const char* postfixes[5];
index dd9c1d7..c8faade 100644 (file)
@@ -264,7 +264,7 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode,
     return node;
 }
 
-TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TIntermNode* childNode, const TType& returnType)
+TIntermTyped* TIntermediate::addBuiltInFunctionCall(TSourceLoc loc, TOperator op, bool unary, TIntermNode* childNode, const TType& returnType)
 {
     if (unary) {
         //
@@ -279,9 +279,11 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TI
             return 0;
         }
 
-        if (child->getAsConstantUnion())
-
-            return child->getAsConstantUnion()->fold(op, returnType, infoSink);
+        if (child->getAsConstantUnion()) {
+            TIntermTyped* folded = child->getAsConstantUnion()->fold(op, returnType, infoSink);
+            if (folded)
+                return folded;
+        }
 
         TIntermUnary* node = new TIntermUnary(op);
         node->setLoc(child->getLoc());
@@ -299,7 +301,7 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(TOperator op, bool unary, TI
         return node;
     } else {
         // setAggregateOperater() calls fold() for constant folding
-        TIntermTyped* node = setAggregateOperator(childNode, op, returnType, childNode->getLoc());
+        TIntermTyped* node = setAggregateOperator(childNode, op, returnType, loc);
         
         TPrecisionQualifier correctPrecision = returnType.getQualifier().precision;
         if (correctPrecision == EpqNone && profile == EEsProfile) {
index 754690c..228850b 100644 (file)
@@ -81,7 +81,7 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb,
             defaultPrecision[EbtSampler] = EpqLow;
             break;
         default:
-            infoSink.info.message(EPrefixError, "unexpected language");
+            infoSink.info.message(EPrefixError, "unexpected es-profile stage");
         }
     }
 
@@ -1965,13 +1965,11 @@ void TParseContext::updateTypedDefaults(TSourceLoc loc, TQualifier qualifier, co
         if (qualifier.layoutPacking != ElpNone)
             error(loc, "cannot specify packing on a variable declaration", id->c_str(), "");
     } else if (qualifier.storage == EvqVaryingIn) {
-        if (qualifier.hasLayout() && language != EShLangVertex) {
+        if (qualifier.hasLayout() && language != EShLangVertex)
             error(loc, "can only use location layout qualifier on a vertex input or fragment output", id->c_str(), "");
-        }
     } else if (qualifier.storage == EvqVaryingOut) {
-        if (qualifier.hasLayout() && language != EShLangFragment) {
+        if (qualifier.hasLayout() && language != EShLangFragment)
             error(loc, "can only use location layout qualifier on a vertex input or fragment output", id->c_str(), "");
-        }
     } else {
         if (qualifier.layoutMatrix != ElmNone ||
             qualifier.layoutPacking != ElpNone)
index 8f244a5..4a65261 100644 (file)
@@ -89,7 +89,7 @@ TSymbolTable* SharedSymbolTables[VersionCount][EProfileCount][EShLangCount] = {}
 
 TPoolAllocator* PerProcessGPA = 0;
 
-bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfile profile, EShLanguage language, TInfoSink& infoSink, 
+bool InitializeSymbolTable(const TBuiltIns& builtIns, int version, EProfile profile, EShLanguage language, TInfoSink& infoSink, 
                            const TBuiltInResource* resources, TSymbolTable* symbolTables)
 {
     TIntermediate intermediate(infoSink, version, profile);    
@@ -119,26 +119,25 @@ bool InitializeSymbolTable(TBuiltInStrings* BuiltInStrings, int version, EProfil
 
     symbolTable->push();
 
-    for (TBuiltInStrings::iterator i  = BuiltInStrings[parseContext.language].begin();
-                                   i != BuiltInStrings[parseContext.language].end();    ++i) {
-        const char* builtInShaders[1];
-        int builtInLengths[1];
+    const char* builtInShaders[2];
+    int builtInLengths[2];
+    builtInShaders[0] = builtIns.getCommonString().c_str();
+    builtInLengths[0] = builtIns.getCommonString().size();
+    builtInShaders[1] = builtIns.getStageString(language).c_str();
+    builtInLengths[1] = builtIns.getStageString(language).size();
 
-        builtInShaders[0] = (*i).c_str();
-        builtInLengths[0] = (int) (*i).size();
-        if (! parseContext.parseShaderStrings(ppContext, const_cast<char**>(builtInShaders), builtInLengths, 1) != 0) {
-            infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
-            printf("Unable to parse built-ins\n");
+    if (! parseContext.parseShaderStrings(ppContext, const_cast<char**>(builtInShaders), builtInLengths, 2) != 0) {
+        infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
+        printf("Unable to parse built-ins\n");
 
-            return false;
-        }
+        return false;
     }
 
-       if (resources) {
+       if (resources)
                IdentifyBuiltIns(version, profile, parseContext.language, *symbolTable, *resources);
-       } else {
+    else
                IdentifyBuiltIns(version, profile, parseContext.language, *symbolTable);
-       }
+
     return true;
 }
 
@@ -147,8 +146,16 @@ bool GenerateBuiltInSymbolTable(TInfoSink& infoSink, TSymbolTable* symbolTables,
     TBuiltIns builtIns;
     
        builtIns.initialize(version, profile);
-       InitializeSymbolTable(builtIns.getBuiltInStrings(), version, profile, EShLangVertex, infoSink, 0, symbolTables);
-       InitializeSymbolTable(builtIns.getBuiltInStrings(), version, profile, EShLangFragment, infoSink, 0, symbolTables);
+    InitializeSymbolTable(builtIns, version, profile, EShLangVertex, infoSink, 0, symbolTables);
+    if (profile != EEsProfile && version >= 400) {
+        InitializeSymbolTable(builtIns, version, profile, EShLangTessControl, infoSink, 0, symbolTables);
+        InitializeSymbolTable(builtIns, version, profile, EShLangTessEvaluation, infoSink, 0, symbolTables);
+    }
+    if (profile != EEsProfile && version >= 150)
+        InitializeSymbolTable(builtIns, version, profile, EShLangGeometry, infoSink, 0, symbolTables);
+    InitializeSymbolTable(builtIns, version, profile, EShLangFragment, infoSink, 0, symbolTables);
+    if (profile != EEsProfile && version >= 430)
+        InitializeSymbolTable(builtIns, version, profile, EShLangCompute, infoSink, 0, symbolTables);
 
     return true;
 }
@@ -158,7 +165,7 @@ bool AddContextSpecificSymbols(const TBuiltInResource* resources, TInfoSink& inf
     TBuiltIns builtIns;
     
        builtIns.initialize(*resources, version, profile, language);
-    InitializeSymbolTable(builtIns.getBuiltInStrings(), version, profile, language, infoSink, resources, symbolTables);
+    InitializeSymbolTable(builtIns, version, profile, language, infoSink, resources, symbolTables);
 
     return true;
 }
@@ -207,10 +214,12 @@ void SetupBuiltinSymbolTable(int version, EProfile profile)
     SetThreadPoolAllocator(*PerProcessGPA);
 
     // Copy the symbol table from the new pool to the process-global pool
-    SharedSymbolTables[versionIndex][profile][EShLangVertex] = new TSymbolTable;
-    SharedSymbolTables[versionIndex][profile][EShLangVertex]->copyTable(symTables[EShLangVertex]);
-    SharedSymbolTables[versionIndex][profile][EShLangFragment] = new TSymbolTable;
-    SharedSymbolTables[versionIndex][profile][EShLangFragment]->copyTable(symTables[EShLangFragment]);
+    for (int stage = 0; stage < EShLangCount; ++stage) {
+        if (! symTables[stage].isEmpty()) {
+            SharedSymbolTables[versionIndex][profile][stage] = new TSymbolTable;
+            SharedSymbolTables[versionIndex][profile][stage]->copyTable(symTables[stage]);
+        }    
+    }
 
     delete builtInPoolAllocator;
     SetThreadPoolAllocator(savedGPA);
@@ -416,9 +425,18 @@ int ShCompile(
 
     TIntermediate intermediate(compiler->infoSink, version, profile);
     SetupBuiltinSymbolTable(version, profile);
-    TSymbolTable symbolTable(*SharedSymbolTables[MapVersionToIndex(version)]
-                                                [profile]
-                                                [compiler->getLanguage()]); 
+    
+    TSymbolTable* cachedTable = SharedSymbolTables[MapVersionToIndex(version)]
+                                                  [profile]
+                                                  [compiler->getLanguage()];
+    TSymbolTable* errorTable = 0;
+    if (! cachedTable) {
+        errorTable = new TSymbolTable;
+        cachedTable = errorTable;
+    }
+    TSymbolTable symbolTable(*cachedTable);
+    if (errorTable)
+        delete errorTable;
     
     // Add built-in symbols that are potentially context dependent;
     // they get popped again further down.
@@ -436,13 +454,13 @@ int ShCompile(
     
     if (! goodProfile)
         parseContext.error(beginning, "incorrect", "#version", "");
-
-    parseContext.initializeExtensionBehavior();
     if (versionStatementMissing)
         parseContext.warn(beginning, "statement missing: use #version on first line of shader", "#version", "");
     else if (profile == EEsProfile && version >= 300 && versionNotFirst)
         parseContext.error(beginning, "statement must appear first in ESSL shader; before comments or newlines", "#version", "");
 
+    parseContext.initializeExtensionBehavior();
+
     //
     // Parse the application's shaders.  All the following symbol table
     // work will be throw-away, so push a new allocation scope that can
index 27d6fc7..8fde88d 100644 (file)
@@ -188,19 +188,20 @@ TSymbolTableLevel::~TSymbolTableLevel()
 
 //
 // Change all function entries in the table with the non-mangled name
-// to be related to the provided built-in operation.  This is a low
-// performance operation, and only intended for symbol tables that
-// live across a large number of compiles.
+// to be related to the provided built-in operation.
 //
 void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
 {
-    tLevel::iterator it;
-    for (it = level.begin(); it != level.end(); ++it) {
-        TFunction* function = (*it).second->getAsFunction();
-        if (function) {
-            if (function->getName() == name)
-                function->relateToOperator(op);
-        }
+    tLevel::const_iterator candidate = level.lower_bound(name);
+    while (candidate != level.end()) {
+        const TString& candidateName = (*candidate).first;
+        TString::size_type parenAt = candidateName.find_first_of('(');
+        if (parenAt != candidateName.npos && candidateName.substr(0, parenAt) == name) {
+            TFunction* function = (*candidate).second->getAsFunction();
+            function->relateToOperator(op);
+        } else
+            break;
+        ++candidate;
     }
 }
 
index c565eef..48a38ef 100644 (file)
@@ -373,10 +373,12 @@ public:
     }
     explicit TSymbolTable(TSymbolTable& symTable)
     {
-        table.push_back(symTable.table[0]);
-        adoptedLevels = 1;
-        uniqueId = symTable.uniqueId;
-        noBuiltInRedeclarations = symTable.noBuiltInRedeclarations;
+        if (! symTable.isEmpty()) {
+            table.push_back(symTable.table[0]);
+            adoptedLevels = 1;
+            uniqueId = symTable.uniqueId;
+            noBuiltInRedeclarations = symTable.noBuiltInRedeclarations;
+        } // else should only be to handle error paths
     }
     ~TSymbolTable()
     {
@@ -391,6 +393,9 @@ public:
     // built-ins specific to a compile are at level 1 and the shader
     // globals are at level 2.
     //
+    // TODO: compile-time memory: have an even earlier level for all built-ins
+    //       common to all stages.  Currently, each stage has copy.
+    //
     bool isEmpty() { return table.size() == 0; }
     bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
     bool atSharedBuiltInLevel() { return table.size() == 1; }  
index 2335c3e..79d5ab1 100644 (file)
@@ -491,7 +491,7 @@ function_call
                 op = fnCandidate->getBuiltInOp();\r
                 if (builtIn && op != EOpNull) {\r
                     // A function call mapped to a built-in operation.\r
-                    $$ = parseContext.intermediate.addBuiltInFunctionCall(op, fnCandidate->getParamCount() == 1, $1.intermNode, fnCandidate->getReturnType());\r
+                    $$ = parseContext.intermediate.addBuiltInFunctionCall($1.loc, op, fnCandidate->getParamCount() == 1, $1.intermNode, fnCandidate->getReturnType());\r
                     if ($$ == 0)  {\r
                         parseContext.error($1.intermNode->getLoc(), " wrong operand type", "Internal Error",\r
                                            "built in unary operator function.  Type: %s",\r
index e538f6a..89d6be2 100644 (file)
@@ -260,6 +260,9 @@ bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
     case EOpAny:            out.debug << "any";                  break;
     case EOpAll:            out.debug << "all";                  break;
 
+    case EOpEmitStreamVertex:   out.debug << "EmitStreamVertex";   break;
+    case EOpEndStreamPrimitive: out.debug << "EndStreamPrimitive"; break;
+
     default: out.debug.message(EPrefixError, "Bad unary op");
     }
 
@@ -355,6 +358,17 @@ bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTravers
     case EOpMul:           out.debug << "component-wise multiply"; break;
     case EOpOuterProduct:  out.debug << "outer product";           break;
 
+    case EOpEmitVertex:    out.debug << "EmitVertex";              break;
+    case EOpEndPrimitive:  out.debug << "EndPrimitive";            break;
+
+    case EOpBarrier:                    out.debug << "Barrier";                    break;
+    case EOpMemoryBarrier:              out.debug << "MemoryBarrier";              break;
+    case EOpMemoryBarrierAtomicCounter: out.debug << "MemoryBarrierAtomicCounter"; break;
+    case EOpMemoryBarrierBuffer:        out.debug << "MemoryBarrierBuffer";        break;
+    case EOpMemoryBarrierImage:         out.debug << "MemoryBarrierImage";         break;
+    case EOpMemoryBarrierShared:        out.debug << "MemoryBarrierShared";        break;
+    case EOpGroupMemoryBarrier:         out.debug << "GroupMemoryBarrier";         break;
+
     default: out.debug.message(EPrefixError, "Bad aggregation op");
     }
 
index 471bee8..4538dea 100644 (file)
@@ -60,7 +60,7 @@ public:
     TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
     TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
     TIntermTyped* addUnaryMath(TOperator, TIntermNode* child, TSourceLoc);
-    TIntermTyped* addBuiltInFunctionCall(TOperator, bool unary, TIntermNode*, const TType& returnType);
+    TIntermTyped* addBuiltInFunctionCall(TSourceLoc line, TOperator, bool unary, TIntermNode*, const TType& returnType);
     bool canImplicitlyPromote(TBasicType from, TBasicType to);
     TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right);
     TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);