diff --git a/Install/Windows/glslangValidator.exe b/Install/Windows/glslangValidator.exe index 35f1078b..e3cbb6d4 100644 Binary files a/Install/Windows/glslangValidator.exe and b/Install/Windows/glslangValidator.exe differ diff --git a/Test/baseResults/120.frag.out b/Test/baseResults/120.frag.out index bbcda690..777a0e92 100644 --- a/Test/baseResults/120.frag.out +++ b/Test/baseResults/120.frag.out @@ -292,4 +292,6 @@ ERROR: node is still EOpNull! 0:? 'm' (uniform 4X2 matrix of float) 0:? 'imageBuffer' (float) 0:? 'uimage2DRect' (float) +0:? 'a' (int) +0:? 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float) diff --git a/Test/baseResults/120.vert.out b/Test/baseResults/120.vert.out index adabd121..96a7fee2 100644 --- a/Test/baseResults/120.vert.out +++ b/Test/baseResults/120.vert.out @@ -23,12 +23,11 @@ ERROR: 0:37: 'arrays of arrays' : not supported with this profile: none ERROR: 0:38: 'arrays of arrays' : not supported with this profile: none ERROR: 0:38: 'constructor' : array constructor needs one argument per array element ERROR: 0:38: 'arrays of arrays' : not supported with this profile: none -ERROR: 0:43: 'uniform' : cannot initialize this type of qualifier ERROR: 0:47: 'arrays of arrays' : not supported with this profile: none ERROR: 0:48: 'arrays of arrays' : not supported with this profile: none ERROR: 0:49: 'arrays of arrays' : not supported with this profile: none ERROR: 0:50: 'arrays of arrays' : not supported with this profile: none -ERROR: 30 compilation errors. No code generated. +ERROR: 29 compilation errors. No code generated. ERROR: node is still EOpNull! 0:15 Function Definition: main( (void) @@ -71,6 +70,10 @@ ERROR: node is still EOpNull! 0:40 move second child to first child (float) 0:40 'gl_PointSize' (invariant gl_PointSize float) 0:40 3.800000 +0:43 Sequence +0:43 move second child to first child (float) +0:43 'initted' (uniform float) +0:43 3.400000 0:? Linker Objects 0:? 'i' (in 4-component vector of float) 0:? 'o' (smooth out 4-component vector of float) @@ -78,4 +81,6 @@ ERROR: node is still EOpNull! 0:? 'attv4' (in 4-component vector of float) 0:? 's2D' (uniform sampler2D) 0:? 'centTexCoord' (invariant smooth out 2-component vector of float) +0:? 'initted' (uniform float) +0:? 'concall' (const float) diff --git a/Test/baseResults/130.frag.out b/Test/baseResults/130.frag.out index 38fa1aac..b1eada0d 100644 --- a/Test/baseResults/130.frag.out +++ b/Test/baseResults/130.frag.out @@ -2,6 +2,9 @@ 0:16 Function Definition: main( (void) 0:16 Function Parameters: 0:? Linker Objects +0:? 'a' (3-component vector of float) +0:? 'b' (float) +0:? 'c' (int) 0:? 'i' (smooth in 4-component vector of float) 0:? 'o' (out 4-component vector of float) 0:? 'fflat' (flat in float) diff --git a/Test/baseResults/300.frag.out b/Test/baseResults/300.frag.out index 9fc969b6..7f15f918 100644 --- a/Test/baseResults/300.frag.out +++ b/Test/baseResults/300.frag.out @@ -217,6 +217,7 @@ ERROR: node is still EOpNull! 0:? 'c1D' (smooth in lowp float) 0:? 'c2D' (smooth in lowp 2-component vector of float) 0:? 'c3D' (smooth in lowp 3-component vector of float) +0:? 'c4D' (smooth lowp 4-component vector of float) 0:? 'ic1D' (flat in mediump int) 0:? 'ic2D' (flat in mediump 2-component vector of int) 0:? 'ic3D' (flat in mediump 3-component vector of int) @@ -227,5 +228,6 @@ ERROR: node is still EOpNull! 0:? 's2' (smooth in structure) 0:? 'sc' (out lowp 3-component vector of float) 0:? 'sf' (out lowp float) +0:? 'arrayedSampler' (uniform 5-element array of lowp sampler2D) 0:? 'multiInst' (layout(shared ) uniform 2-element array of block) diff --git a/Test/baseResults/300.vert.out b/Test/baseResults/300.vert.out index 567be865..1388f662 100644 --- a/Test/baseResults/300.vert.out +++ b/Test/baseResults/300.vert.out @@ -126,6 +126,7 @@ ERROR: node is still EOpNull! 0:? 'm44' (uniform highp 4X4 matrix of float) 0:? 'v3' (in highp 3-component vector of float) 0:? 'v2' (smooth out highp 2-component vector of float) +0:? 'bad' (in 10-element array of highp 4-component vector of float) 0:? 'badorder' (in highp 4-component vector of float) 0:? 'badorder2' (invariant smooth out highp 4-component vector of float) 0:? 'badorder4' (centroid in highp 4-component vector of float) @@ -134,8 +135,10 @@ ERROR: node is still EOpNull! 0:? 'rep2' (centroid smooth sample out highp 4-component vector of float) 0:? 'rep3' (in highp 4-component vector of float) 0:? 's' (smooth out structure) +0:? 'badsize' (unsized array of highp float) 0:? 'badsize2' (unsized array of highp float) 0:? 'ubInst' (layout(shared ) uniform unsized array of block) +0:? 'okayA' (2-element array of highp float) 0:? 'gl_VertexID' (gl_VertexId highp int) 0:? 'gl_InstanceID' (gl_InstanceId highp int) diff --git a/Test/baseResults/300layout.frag.out b/Test/baseResults/300layout.frag.out index 2610ad88..f2128e10 100644 --- a/Test/baseResults/300layout.frag.out +++ b/Test/baseResults/300layout.frag.out @@ -21,4 +21,5 @@ ERROR: node is still EOpNull! 0:? 'color' (layout(location=2 ) smooth in mediump 4-component vector of float) 0:? 'c' (layout(location=1 ) out mediump 4-component vector of float) 0:? 'p' (layout(location=3 ) out mediump 4-component vector of float) +0:? 'q' (layout(location=4 ) out 2-element array of mediump 4-component vector of float) diff --git a/Test/baseResults/300layout.vert.out b/Test/baseResults/300layout.vert.out index 241d003c..77f487da 100644 --- a/Test/baseResults/300layout.vert.out +++ b/Test/baseResults/300layout.vert.out @@ -49,12 +49,15 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'c' (layout(location=7 ) in highp 3-component vector of float) 0:? 'p' (layout(location=3 ) in highp 4-component vector of float) +0:? 'q' (layout(location=9 ) in 4-element array of highp 4-component vector of float) +0:? 'r' (layout(location=10 ) in 4-element array of structure) 0:? 'pos' (smooth out highp 4-component vector of float) 0:? 'color' (smooth out highp 3-component vector of float) 0:? 'badm4' (layout(column_major shared ) uniform highp 4X4 matrix of float) 0:? 'tblock' (layout(std140 ) uniform block) 0:? '__anon__0' (layout(shared ) uniform block) 0:? 'badout' (layout(location=10 ) smooth out highp 4-component vector of float) +0:? 'compute_only' (shared highp 4-component vector of float) 0:? 'gl_VertexID' (gl_VertexId highp int) 0:? 'gl_InstanceID' (gl_InstanceId highp int) diff --git a/Test/baseResults/300operations.frag.out b/Test/baseResults/300operations.frag.out index a679ca08..a40b7f79 100644 --- a/Test/baseResults/300operations.frag.out +++ b/Test/baseResults/300operations.frag.out @@ -200,4 +200,5 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'instanceName' (layout(shared ) uniform block) 0:? 's' (structure) +0:? 'a' (5-element array of mediump float) diff --git a/Test/baseResults/400.frag.out b/Test/baseResults/400.frag.out index fe783037..df37e93e 100644 --- a/Test/baseResults/400.frag.out +++ b/Test/baseResults/400.frag.out @@ -15,4 +15,5 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'c2D' (smooth in 2-component vector of float) 0:? 'i' (flat in int) +0:? 'arrayedSampler' (uniform 5-element array of sampler2D) diff --git a/Test/baseResults/420.vert.out b/Test/baseResults/420.vert.out index af98606c..4150d4ec 100644 --- a/Test/baseResults/420.vert.out +++ b/Test/baseResults/420.vert.out @@ -37,6 +37,7 @@ ERROR: node is still EOpNull! 0:30 'v' (in 4-component vector of float) 0:? Linker Objects 0:? 'v2' (smooth out 2-component vector of float) +0:? 'bad' (in 10-element array of 4-component vector of float) 0:? 'badorder' (in 4-component vector of float) 0:? 'badorder2' (invariant smooth out 4-component vector of float) 0:? 'badorder4' (centroid in 4-component vector of float) diff --git a/Test/baseResults/array.frag.out b/Test/baseResults/array.frag.out index f12c2649..fa745eb3 100644 --- a/Test/baseResults/array.frag.out +++ b/Test/baseResults/array.frag.out @@ -147,5 +147,8 @@ ERROR: node is still EOpNull! 0:58 1 (const int) 0:58 4 (const int) 0:? Linker Objects +0:? 'gu' (unsized array of float) +0:? 'g4' (4-element array of float) +0:? 'g5' (5-element array of float) 0:? 'a' (uniform int) diff --git a/Test/baseResults/array100.frag.out b/Test/baseResults/array100.frag.out index 4dd0235f..d3eb5295 100644 --- a/Test/baseResults/array100.frag.out +++ b/Test/baseResults/array100.frag.out @@ -99,5 +99,8 @@ ERROR: node is still EOpNull! 0:40 1.000000 0:40 1.000000 0:? Linker Objects +0:? 'gu' (unsized array of mediump float) +0:? 'g4' (4-element array of mediump float) +0:? 'g5' (5-element array of mediump float) 0:? 'a' (uniform mediump int) diff --git a/Test/baseResults/constErrors.frag.out b/Test/baseResults/constErrors.frag.out index abc1b67e..82913151 100644 --- a/Test/baseResults/constErrors.frag.out +++ b/Test/baseResults/constErrors.frag.out @@ -15,5 +15,8 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'inVar' (smooth in 4-component vector of float) 0:? 'outVar' (out 4-component vector of float) +0:? 'constInt' (const int) 0:? 'uniformInt' (uniform int) +0:? 's' (structure) +0:? 's2' (structure) diff --git a/Test/baseResults/constFold.frag.out b/Test/baseResults/constFold.frag.out index fff747b7..8d7b1203 100644 --- a/Test/baseResults/constFold.frag.out +++ b/Test/baseResults/constFold.frag.out @@ -138,6 +138,14 @@ 0:81 0 (const int) 0:81 7.000000 0:? Linker Objects +0:? 'a' (const int) +0:? 'b' (const int) +0:? 'c' (const int) +0:? 'd' (const int) +0:? 'e' (const float) +0:? 'f' (const float) +0:? 'g' (const float) +0:? 'pytho' (const 2-component vector of float) 0:? 'inv' (smooth in 4-component vector of float) 0:? 'FragColor' (out 4-component vector of float) 0:? 'out2' (out 2-component vector of float) @@ -152,4 +160,5 @@ 0:? 'out11' (out 4-component vector of float) 0:? 'out12' (out 2-component vector of int) 0:? 'out13' (out 3-component vector of uint) +0:? 's' (const structure) diff --git a/Test/baseResults/cppComplexExpr.vert.out b/Test/baseResults/cppComplexExpr.vert.out index f6410bfc..6069fc0c 100644 --- a/Test/baseResults/cppComplexExpr.vert.out +++ b/Test/baseResults/cppComplexExpr.vert.out @@ -21,4 +21,5 @@ WARNING: #version: statement missing; use #version on first line of shader 0:39 Construct vec4 (highp 4-component vector of float) 0:39 'sum' (highp float) 0:? Linker Objects +0:? 'sum' (highp float) diff --git a/Test/baseResults/cppIndent.vert.out b/Test/baseResults/cppIndent.vert.out index 0f9f66a9..2ef0dcd6 100644 --- a/Test/baseResults/cppIndent.vert.out +++ b/Test/baseResults/cppIndent.vert.out @@ -26,4 +26,5 @@ 0:56 Construct vec4 (4-component vector of float) 0:56 'sum' (float) 0:? Linker Objects +0:? 'sum' (float) diff --git a/Test/baseResults/cppNest.vert.out b/Test/baseResults/cppNest.vert.out index 4574806c..38894d82 100644 --- a/Test/baseResults/cppNest.vert.out +++ b/Test/baseResults/cppNest.vert.out @@ -29,4 +29,5 @@ 0:86 Construct vec4 (4-component vector of float) 0:86 'sum' (float) 0:? Linker Objects +0:? 'sum' (float) diff --git a/Test/baseResults/cppSimple.vert.out b/Test/baseResults/cppSimple.vert.out index b98f560e..76415b23 100644 --- a/Test/baseResults/cppSimple.vert.out +++ b/Test/baseResults/cppSimple.vert.out @@ -71,5 +71,10 @@ ERROR: node is still EOpNull! 0:130 'twoPi' (float) 0:130 6.280000 0:? Linker Objects +0:? 'sum' (float) +0:? 'linenumber' (int) +0:? 'filenumber' (int) +0:? 'version' (int) +0:? 'twoPi' (float) 0:? 'tod' (float) diff --git a/Test/baseResults/dce.frag.out b/Test/baseResults/dce.frag.out index 7975f99e..d2d7ac54 100644 --- a/Test/baseResults/dce.frag.out +++ b/Test/baseResults/dce.frag.out @@ -114,4 +114,6 @@ 0:55 Pre-Increment (int) 0:55 'c' (int) 0:? Linker Objects +0:? 'flag' (const bool) +0:? 'c' (int) diff --git a/Test/baseResults/decls.frag.out b/Test/baseResults/decls.frag.out new file mode 100644 index 00000000..ad0ac0a8 --- /dev/null +++ b/Test/baseResults/decls.frag.out @@ -0,0 +1,151 @@ +ERROR: 0:19: 'vi4' : illegal use of type 'void' +ERROR: 0:20: 'vj' : illegal use of type 'void' +ERROR: 0:20: 'vk5' : illegal use of type 'void' +ERROR: 0:21: 'vm2' : illegal use of type 'void' +ERROR: 0:21: 'vm3' : illegal use of type 'void' +ERROR: 0:22: 'vn8' : illegal use of type 'void' +ERROR: 0:22: 'vp' : illegal use of type 'void' +ERROR: 0:24: 'gl_' : reserved built-in name +ERROR: 0:25: 'gl_' : reserved built-in name +ERROR: 0:25: 'gl_' : reserved built-in name +ERROR: 0:26: 'gl_' : reserved built-in name +ERROR: 0:26: 'gl_' : reserved built-in name +ERROR: 0:27: 'gl_' : reserved built-in name +ERROR: 0:27: 'gl_' : reserved built-in name +ERROR: 0:32: '' : boolean expression expected +ERROR: 0:33: 'gl_' : reserved built-in name +ERROR: 16 compilation errors. No code generated. + +ERROR: node is still EOpNull! +0:5 Sequence +0:5 move second child to first child (int) +0:5 'd1' (int) +0:5 1 (const int) +0:6 Sequence +0:6 move second child to first child (int) +0:6 'e2' (int) +0:6 2 (const int) +0:7 Sequence +0:7 move second child to first child (int) +0:7 'h3' (int) +0:7 3 (const int) +0:14 Sequence +0:14 move second child to first child (4-element array of int) +0:14 'ii4' (4-element array of int) +0:14 1 (const int) +0:14 2 (const int) +0:14 3 (const int) +0:14 4 (const int) +0:15 Sequence +0:15 move second child to first child (5-element array of int) +0:15 'ik5' (5-element array of int) +0:15 5 (const int) +0:15 6 (const int) +0:15 7 (const int) +0:15 8 (const int) +0:15 9 (const int) +0:16 Sequence +0:16 move second child to first child (2-element array of int) +0:16 'im2' (2-element array of int) +0:16 10 (const int) +0:16 11 (const int) +0:16 move second child to first child (3-element array of int) +0:16 'im3' (3-element array of int) +0:16 12 (const int) +0:16 13 (const int) +0:16 14 (const int) +0:17 Sequence +0:17 move second child to first child (4-element array of int) +0:17 'in8' (4-element array of int) +0:17 21 (const int) +0:17 22 (const int) +0:17 23 (const int) +0:17 24 (const int) +0:24 Sequence +0:24 move second child to first child (4-element array of int) +0:24 'gl_vi4' (4-element array of int) +0:24 1 (const int) +0:24 2 (const int) +0:24 3 (const int) +0:24 4 (const int) +0:25 Sequence +0:25 move second child to first child (5-element array of int) +0:25 'gl_vk5' (5-element array of int) +0:25 5 (const int) +0:25 6 (const int) +0:25 7 (const int) +0:25 8 (const int) +0:25 9 (const int) +0:26 Sequence +0:26 move second child to first child (2-element array of int) +0:26 'gl_vm2' (2-element array of int) +0:26 10 (const int) +0:26 11 (const int) +0:26 move second child to first child (3-element array of int) +0:26 'gl_vm3' (3-element array of int) +0:26 12 (const int) +0:26 13 (const int) +0:26 14 (const int) +0:27 Sequence +0:27 move second child to first child (4-element array of int) +0:27 'gl_vn8' (4-element array of int) +0:27 21 (const int) +0:27 22 (const int) +0:27 23 (const int) +0:27 24 (const int) +0:29 Function Definition: main( (void) +0:29 Function Parameters: +0:31 Sequence +0:31 Loop with condition tested first +0:31 Loop Condition +0:31 move second child to first child (bool) +0:31 'cond' (bool) +0:31 Compare Less Than (bool) +0:31 'b' (int) +0:31 'c' (int) +0:31 No loop body +0:32 Loop with condition tested first +0:32 Loop Condition +0:32 move second child to first child (int) +0:32 'icond' (int) +0:32 'b' (int) +0:32 No loop body +0:33 Loop with condition tested first +0:33 Loop Condition +0:33 move second child to first child (bool) +0:33 'gl_cond' (bool) +0:33 Compare Less Than (bool) +0:33 'b' (int) +0:33 'c' (int) +0:33 No loop body +0:? Linker Objects +0:? 'a' (int) +0:? 'b' (int) +0:? 'c' (int) +0:? 'd1' (int) +0:? 'e2' (int) +0:? 'f' (int) +0:? 'g' (int) +0:? 'h3' (int) +0:? 'i4' (4-element array of int) +0:? 'j' (int) +0:? 'k5' (5-element array of int) +0:? 'm6' (6-element array of int) +0:? 'm7' (7-element array of int) +0:? 'n8' (8-element array of int) +0:? 'p' (int) +0:? 'ii4' (4-element array of int) +0:? 'ij' (int) +0:? 'ik5' (5-element array of int) +0:? 'im2' (2-element array of int) +0:? 'im3' (3-element array of int) +0:? 'in8' (4-element array of int) +0:? 'ip' (int) +0:? 'gl_vi4' (4-element array of int) +0:? 'gl_vj' (int) +0:? 'gl_vk5' (5-element array of int) +0:? 'gl_vm2' (2-element array of int) +0:? 'gl_vm3' (3-element array of int) +0:? 'gl_vn8' (4-element array of int) +0:? 'gl_vp' (int) + diff --git a/Test/baseResults/deepRvalue.frag.out b/Test/baseResults/deepRvalue.frag.out index c7c5a7d9..1cda2df1 100644 --- a/Test/baseResults/deepRvalue.frag.out +++ b/Test/baseResults/deepRvalue.frag.out @@ -115,4 +115,8 @@ 0:35 'i' (float) 0:? Linker Objects 0:? 'sampler' (uniform sampler2D) +0:? 'v1' (4-component vector of float) +0:? 'v2' (4-component vector of float) +0:? 'v3' (4-component vector of float) +0:? 'v4' (4-component vector of float) diff --git a/Test/baseResults/functionCall.frag.out b/Test/baseResults/functionCall.frag.out index a1624450..3327c4cf 100644 --- a/Test/baseResults/functionCall.frag.out +++ b/Test/baseResults/functionCall.frag.out @@ -76,4 +76,5 @@ WARNING: 0:4: varying deprecated in version 130; may be removed in future releas 0:? 'bigColor' (uniform 4-component vector of float) 0:? 'BaseColor' (smooth in 4-component vector of float) 0:? 'd' (uniform float) +0:? 'h' (float) diff --git a/Test/baseResults/length.frag.out b/Test/baseResults/length.frag.out index 5deccaaf..4a354ae7 100644 --- a/Test/baseResults/length.frag.out +++ b/Test/baseResults/length.frag.out @@ -19,4 +19,6 @@ 0:17 30.000000 0:17 30.000000 0:? Linker Objects +0:? 'u' (uniform 3-element array of 4-component vector of float) +0:? 'v' (smooth in 2-element array of 2-component vector of float) diff --git a/Test/baseResults/link1.frag.out b/Test/baseResults/link1.frag.out index 5119acfc..47cfec21 100644 --- a/Test/baseResults/link1.frag.out +++ b/Test/baseResults/link1.frag.out @@ -33,8 +33,12 @@ link1.frag 0:? Linker Objects 0:? 'uv4' (uniform 4-component vector of float) 0:? 'glass' (uniform 3-component vector of float) +0:? 'ci' (const int) +0:? 'a' (4-component vector of float) 0:? 'iv3' (smooth in 3-component vector of float) 0:? 'cup' (smooth in 4-component vector of float) +0:? 'b' (4-component vector of float) +0:? 'c' (4-component vector of float) link2.frag @@ -66,8 +70,12 @@ link2.frag 0:? Linker Objects 0:? 'uv4' (uniform 4-component vector of float) 0:? 'glass' (uniform 2-component vector of float) +0:? 'ci' (const int) +0:? 'd' (4-component vector of float) 0:? 'iv3' (smooth in 3-component vector of float) 0:? 'cup' (flat in 4-component vector of float) +0:? 'e' (4-component vector of float) +0:? 'f' (4-component vector of float) link3.frag @@ -145,6 +153,13 @@ ERROR: Linking fragment stage: Precision qualifiers must match: 0:? Linker Objects 0:? 'uv4' (uniform 4-component vector of float) 0:? 'glass' (uniform 3-component vector of float) +0:? 'ci' (const int) +0:? 'a' (4-component vector of float) 0:? 'iv3' (smooth in 3-component vector of float) 0:? 'cup' (smooth in 4-component vector of float) +0:? 'b' (4-component vector of float) +0:? 'c' (4-component vector of float) +0:? 'd' (4-component vector of float) +0:? 'e' (4-component vector of float) +0:? 'f' (4-component vector of float) diff --git a/Test/baseResults/matrixError.vert.out b/Test/baseResults/matrixError.vert.out index 574ede51..0f014cf8 100644 --- a/Test/baseResults/matrixError.vert.out +++ b/Test/baseResults/matrixError.vert.out @@ -30,4 +30,5 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'v3' (in 3-component vector of float) 0:? 'm32' (uniform 3X2 matrix of float) +0:? 'm24' (2X4 matrix of float) diff --git a/Test/baseResults/nonSquare.vert.out b/Test/baseResults/nonSquare.vert.out index 5ee5ea17..631fa591 100644 --- a/Test/baseResults/nonSquare.vert.out +++ b/Test/baseResults/nonSquare.vert.out @@ -59,4 +59,7 @@ 0:? 'v3' (in 3-component vector of float) 0:? 'v4' (in 4-component vector of float) 0:? 'm32' (uniform 3X2 matrix of float) +0:? 'cv2' (const 2-component vector of float) +0:? 'm24' (const 2X4 matrix of float) +0:? 'm42' (const 4X2 matrix of float) diff --git a/Test/baseResults/precision.frag.out b/Test/baseResults/precision.frag.out index 93f1cbab..38d1a200 100644 --- a/Test/baseResults/precision.frag.out +++ b/Test/baseResults/precision.frag.out @@ -109,4 +109,5 @@ ERROR: node is still EOpNull! 0:? 'samplerHigh' (uniform highp sampler2D) 0:? 'uint' (mediump 4-component vector of float) 0:? 'global_high' (highp int) +0:? 'b2' (mediump 2-component vector of bool) diff --git a/Test/baseResults/specExamples.frag.out b/Test/baseResults/specExamples.frag.out index 9bba5309..c776306b 100644 --- a/Test/baseResults/specExamples.frag.out +++ b/Test/baseResults/specExamples.frag.out @@ -3,7 +3,6 @@ ERROR: 0:20: '' : numeric literal too big ERROR: 0:21: '' : hexidecimal literal too big ERROR: 0:37: 'view' : redefinition ERROR: 0:68: 'lightPosition' : redefinition -ERROR: 0:69: 'uniform' : cannot initialize this type of qualifier ERROR: 0:71: 'Material' : only uniform interface blocks are supported ERROR: 0:79: 'Light' : only uniform interface blocks are supported ERROR: 0:83: 'ColoredTexture' : only uniform interface blocks are supported @@ -54,7 +53,7 @@ ERROR: 0:226: 'in' : only allowed at global scope ERROR: 0:227: 'in' : only allowed at global scope ERROR: 0:228: 'in' : only allowed at global scope ERROR: 0:232: 'out' : only allowed at global scope -ERROR: 56 compilation errors. No code generated. +ERROR: 55 compilation errors. No code generated. ERROR: node is still EOpNull! 0:5 Sequence @@ -109,6 +108,12 @@ ERROR: node is still EOpNull! 0:26 move second child to first child (double) 0:26 'fd' (double) 0:26 2.000000 +0:69 Sequence +0:69 move second child to first child (3-component vector of float) +0:69 'color' (uniform 3-component vector of float) +0:69 0.700000 +0:69 0.700000 +0:69 0.200000 0:127 Function Definition: foo(f1[5]; (5-element array of float) 0:127 Function Parameters: 0:127 '' (in 5-element array of float) @@ -196,8 +201,22 @@ ERROR: node is still EOpNull! 0:218 'c' (5-element array of float) 0:218 'a' (5-element array of float) 0:? Linker Objects +0:? 'a' (int) +0:? 'b' (int) +0:? 'c' (uint) +0:? 'd' (uint) +0:? 'e' (int) +0:? 'f' (uint) +0:? 'g' (int) +0:? 'h' (int) +0:? 'i' (int) +0:? 'j' (int) +0:? 'k' (int) +0:? 'l' (int) 0:? 'fa' (float) +0:? 'fb' (float) 0:? 'fc' (double) +0:? 'fd' (double) 0:? 'texcoord1' (2-component vector of float) 0:? 'texcoord2' (2-component vector of float) 0:? 'position' (3-component vector of float) @@ -212,14 +231,20 @@ ERROR: node is still EOpNull! 0:? 'highPrecisionMVP' (4X4 matrix of double) 0:? 'dm' (2X4 matrix of double) 0:? 'lightVar' (structure) +0:? 'frequencies' (3-element array of float) +0:? 'lightPosition' (uniform 4-element array of 4-component vector of float) +0:? 'lights' (2-element array of structure) +0:? 'numLights' (const int) 0:? 'normal' (smooth in 3-component vector of float) 0:? 'TexCoord' (centroid smooth in 2-component vector of float) 0:? 'Color' (invariant centroid smooth in 4-component vector of float) 0:? 'temperature' (noperspective in float) 0:? 'myColor' (flat in 3-component vector of float) 0:? 'myTexCoord' (centroid noperspective in 2-component vector of float) +0:? 'color' (uniform 3-component vector of float) 0:? 'gl_FragCoord' (gl_FragCoord 4-component vector of float) 0:? 'factor' (layout(location=3 ) out 4-component vector of float) +0:? 'colors' (layout(location=2 ) out 3-element array of 4-component vector of float) 0:? 'gl_FragDepth' (gl_FragDepth float) 0:? 'gl_Color' (smooth in 4-component vector of float) diff --git a/Test/baseResults/specExamples.vert.out b/Test/baseResults/specExamples.vert.out index f8b3a34c..3b9733a1 100644 --- a/Test/baseResults/specExamples.vert.out +++ b/Test/baseResults/specExamples.vert.out @@ -222,6 +222,8 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'transforms' (layout(shared ) uniform 4-element array of block) 0:? 'normal' (layout(location=3 ) in 4-component vector of float) +0:? 'colors' (layout(location=6 ) in 3-element array of 4-component vector of float) +0:? 's' (layout(location=3 ) structure) 0:? 'var1' (smooth out 4-component vector of float) 0:? 'var5' (smooth out 4-component vector of float) 0:? 'var7' (smooth out 4-component vector of float) @@ -244,6 +246,7 @@ ERROR: node is still EOpNull! 0:? 'd' (in 4-component vector of float) 0:? 'v' (smooth out 4-component vector of float) 0:? '__anon__2' (layout(shared ) uniform block) +0:? 'shv' (shared 4-component vector of float) 0:? 'img1' (uniform image2D) 0:? 'img2' (coherent uniform image2D) 0:? 'gl_VertexID' (gl_VertexId int) diff --git a/Test/baseResults/structure.frag.out b/Test/baseResults/structure.frag.out index a9746621..9d035947 100644 --- a/Test/baseResults/structure.frag.out +++ b/Test/baseResults/structure.frag.out @@ -59,4 +59,5 @@ WARNING: 0:3: varying deprecated in version 130; may be removed in future releas 0:? 'sampler' (uniform sampler2D) 0:? 'coord' (smooth in 2-component vector of float) 0:? 'foo' (uniform structure) +0:? 'foo2' (uniform 5-element array of structure) diff --git a/Test/baseResults/tokenLength.vert.out b/Test/baseResults/tokenLength.vert.out index 613a81c9..f371596d 100644 --- a/Test/baseResults/tokenLength.vert.out +++ b/Test/baseResults/tokenLength.vert.out @@ -77,7 +77,19 @@ ERROR: node is still EOpNull! 0:? Linker Objects 0:? 'BCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789' (in highp float) 0:? 'ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789' (in highp float) +0:? 'E1' (highp int) +0:? 'E2' (highp int) +0:? 'B' (highp int) +0:? 'OE' (highp int) +0:? 'HE' (highp int) +0:? 'F' (highp float) +0:? 'G' (highp float) +0:? 'E3' (highp float) 0:? 'BCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789B' (highp float) +0:? 'superH' (highp int) +0:? 'superO' (highp int) +0:? 'superI' (highp int) +0:? 'superF' (highp float) 0:? 'gl_VertexID' (gl_VertexId highp int) 0:? 'gl_InstanceID' (gl_InstanceId highp int) diff --git a/Test/baseResults/uniformArray.frag.out b/Test/baseResults/uniformArray.frag.out index f734c29a..f67d80df 100644 --- a/Test/baseResults/uniformArray.frag.out +++ b/Test/baseResults/uniformArray.frag.out @@ -33,4 +33,6 @@ 0:? Linker Objects 0:? 'texSampler2D' (uniform sampler2D) 0:? 'inColor' (uniform 3-component vector of float) +0:? 'color' (uniform 6-element array of 4-component vector of float) +0:? 'alpha' (uniform 16-element array of float) diff --git a/Test/baseResults/variableArrayIndex.frag.out b/Test/baseResults/variableArrayIndex.frag.out index aa20e6ad..a217c280 100644 --- a/Test/baseResults/variableArrayIndex.frag.out +++ b/Test/baseResults/variableArrayIndex.frag.out @@ -86,6 +86,7 @@ WARNING: 0:3: varying deprecated in version 130; may be removed in future releas 0:? 'sampler' (uniform sampler2D) 0:? 'coord' (smooth in 2-component vector of float) 0:? 'foo' (uniform structure) +0:? 'foo2' (uniform 5-element array of structure) 0:? 'foo3' (uniform structure) 0:? 'Count' (uniform int) diff --git a/Test/baseResults/varyingArray.frag.out b/Test/baseResults/varyingArray.frag.out index 2e0245b5..57048da6 100644 --- a/Test/baseResults/varyingArray.frag.out +++ b/Test/baseResults/varyingArray.frag.out @@ -46,4 +46,6 @@ WARNING: 0:8: varying deprecated in version 130; may be removed in future releas 0:? 'texSampler2D' (uniform sampler2D) 0:? 'color' (smooth in 4-component vector of float) 0:? 'alpha' (smooth in float) +0:? 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float) +0:? 'foo' (smooth in 3-element array of 4-component vector of float) diff --git a/Test/baseResults/varyingArrayIndirect.frag.out b/Test/baseResults/varyingArrayIndirect.frag.out index 5db8488c..8e60670d 100644 --- a/Test/baseResults/varyingArrayIndirect.frag.out +++ b/Test/baseResults/varyingArrayIndirect.frag.out @@ -50,6 +50,8 @@ WARNING: 0:8: varying deprecated in version 130; may be removed in future releas 0:? 'texSampler2D' (uniform sampler2D) 0:? 'color' (smooth in 4-component vector of float) 0:? 'alpha' (smooth in float) +0:? 'gl_TexCoord' (smooth in 6-element array of 4-component vector of float) +0:? 'userIn' (smooth in 2-element array of 4-component vector of float) 0:? 'a' (uniform int) 0:? 'b' (uniform int) diff --git a/Test/baseResults/voidFunction.frag.out b/Test/baseResults/voidFunction.frag.out index 4070c71f..3f8254a4 100644 --- a/Test/baseResults/voidFunction.frag.out +++ b/Test/baseResults/voidFunction.frag.out @@ -36,4 +36,5 @@ 0:? 'bigColor' (uniform 4-component vector of float) 0:? 'BaseColor' (smooth in 4-component vector of float) 0:? 'd' (uniform float) +0:? 'bar' (float) diff --git a/Test/decls.frag b/Test/decls.frag new file mode 100644 index 00000000..e76d3857 --- /dev/null +++ b/Test/decls.frag @@ -0,0 +1,34 @@ +#version 120 + +int a; +int b, c; +int d1 = 1; +int e2 = 2, f; +int g, h3 = 3; + +int i4[4]; +int j, k5[5]; +int m6[6], m7[7]; +int n8[8], p; + +int ii4[4] = int[](1, 2, 3, 4); +int ij, ik5[5] = int[](5, 6, 7, 8, 9); +int im2[2] = int[](10, 11), im3[3] = int[](12, 13, 14); +int in8[4] = int[](21, 22, 23, 24), ip; + +void vi4[4] = int[](1, 2, 3, 4); +void vj, vk5[5] = int[](5, 6, 7, 8, 9); +void vm2[2] = int[](10, 11), vm3[3] = int[](12, 13, 14); +void vn8[4] = int[](21, 22, 23, 24), vp; + +int gl_vi4[4] = int[](1, 2, 3, 4); +int gl_vj, gl_vk5[5] = int[](5, 6, 7, 8, 9); +int gl_vm2[2] = int[](10, 11), gl_vm3[3] = int[](12, 13, 14); +int gl_vn8[4] = int[](21, 22, 23, 24), gl_vp; + +void main() +{ + while (bool cond = b < c); + while (int icond = b); + while (bool gl_cond = b < c); +} diff --git a/Test/testlist b/Test/testlist index ef826951..24fd1e59 100644 --- a/Test/testlist +++ b/Test/testlist @@ -1,5 +1,6 @@ sample.frag sample.vert +decls.frag specExamples.frag specExamples.vert versionsClean.frag diff --git a/Todo.txt b/Todo.txt index 84784b27..3fbabcce 100644 --- a/Todo.txt +++ b/Todo.txt @@ -4,6 +4,7 @@ Link Validation + provide input config file for setting limits - also consider spitting out measures of complexity + ensure no static references thrown away + - generate static use of object even if the only use is to access the length of its array Cross-stage linking - type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching - location/binding/index check @@ -20,7 +21,6 @@ Link Validation Intra-stage linking + exactly one main + type consistency check of uniforms, globals, ins, and outs - - still need to cover arrays and the combinations of this rule with redeclarations of built-ins - value checking of global const initializers - value checking of uniform initializers + location match diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index feee5b94..c33e41bf 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -588,6 +588,7 @@ public: arraySizes = NewPoolTArraySizes(); *arraySizes = *s; } + void setArraySizes(const TType& type) { setArraySizes(type.arraySizes); } void changeArraySize(int s) { arraySizes->sizes.front() = s; } void setMaxArraySize (int s) { arraySizes->maxArraySize = s; } diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp index 20212c94..ebf6d142 100644 --- a/glslang/MachineIndependent/Intermediate.cpp +++ b/glslang/MachineIndependent/Intermediate.cpp @@ -644,7 +644,8 @@ TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* r TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc loc) { TIntermAggregate* aggNode = growAggregate(left, right); - aggNode->setLoc(loc); + if (aggNode) + aggNode->setLoc(loc); return aggNode; } diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index d41a31d4..c364c061 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -1325,13 +1325,13 @@ bool TParseContext::constructorError(TSourceLoc loc, TIntermNode* node, TFunctio return false; } -// This function checks to see if a void variable has been declared and raise an error message for such a case +// Checks to see if a void variable has been declared and raise an error message for such a case // // returns true in case of an error // -bool TParseContext::voidErrorCheck(TSourceLoc loc, const TString& identifier, const TPublicType& pubType) +bool TParseContext::voidErrorCheck(TSourceLoc loc, const TString& identifier, const TBasicType basicType) { - if (pubType.basicType == EbtVoid) { + if (basicType == EbtVoid) { error(loc, "illegal use of type 'void'", identifier.c_str(), ""); return true; } @@ -1646,12 +1646,12 @@ void TParseContext::arraySizeCheck(TSourceLoc loc, TIntermTyped* expr, int& size // // Returns true if there is an error. // -bool TParseContext::arrayQualifierError(TSourceLoc loc, const TPublicType& type) +bool TParseContext::arrayQualifierError(TSourceLoc loc, const TQualifier& qualifier) { - if (type.qualifier.storage == EvqConst) + if (qualifier.storage == EvqConst) profileRequires(loc, ENoProfile, 120, "GL_3DL_array_objects", "const array"); - if (type.qualifier.storage == EvqVaryingIn && language == EShLangVertex) { + if (qualifier.storage == EvqVaryingIn && language == EShLangVertex) { requireProfile(loc, (EProfileMask)~EEsProfileMask, "vertex input arrays"); profileRequires(loc, ENoProfile, 150, 0, "vertex input arrays"); } @@ -1698,7 +1698,7 @@ void TParseContext::arrayDimCheck(TSourceLoc loc, const TType* type, TArraySizes // // size == 0 means no specified size. // -void TParseContext::arrayCheck(TSourceLoc loc, TString& identifier, const TPublicType& type, TVariable*& variable) +void TParseContext::declareArray(TSourceLoc loc, TString& identifier, const TType& type, TVariable*& variable, bool& newDeclaration) { // // Don't check for reserved word use until after we know it's not in the symbol table, @@ -1710,46 +1710,39 @@ void TParseContext::arrayCheck(TSourceLoc loc, TString& identifier, const TPubli // Redeclarations have to take place at the same scope; otherwise they are hiding declarations // - bool currentScope; - TSymbol* symbol = symbolTable.find(identifier, 0, ¤tScope); - if (symbol == 0 || ! currentScope) { - if (reservedErrorCheck(loc, identifier)) - return; + if (! variable) { + bool currentScope; + TSymbol* symbol = symbolTable.find(identifier, 0, ¤tScope); + if (symbol == 0 || ! currentScope) { + variable = new TVariable(&identifier, type); + symbolTable.insert(*variable); + newDeclaration = true; - variable = new TVariable(&identifier, TType(type)); - symbolTable.insert(*variable); - } else { + return; + } variable = symbol->getAsVariable(); + } - if (! variable) { - error(loc, "array variable name expected", identifier.c_str(), ""); - return; - } + if (! variable) { + error(loc, "array variable name expected", identifier.c_str(), ""); + return; + } - if (! variable->getType().isArray()) { - error(loc, "redeclaring non-array as array", identifier.c_str(), ""); - return; - } - if (variable->getType().getArraySize() > 0) { - error(loc, "redeclaration of array with size", identifier.c_str(), ""); - return; - } + if (! variable->getType().isArray()) { + error(loc, "redeclaring non-array as array", identifier.c_str(), ""); + return; + } + if (variable->getType().getArraySize() > 0) { + error(loc, "redeclaration of array with size", identifier.c_str(), ""); + return; + } - if (! variable->getType().sameElementType(TType(type))) { - error(loc, "redeclaration of array with a different type", identifier.c_str(), ""); - return; - } - - // For read-only built-ins, add a new variable for holding the declared array size of an implicitly-sized shared array. - if (variable->isReadOnly()) - variable = symbolTable.copyUp(variable); - - // TODO: desktop unsized arrays: include modified built-in arrays (gl_TexCoord) in the linker objects subtree - - variable->getWritableType().setArraySizes(type.arraySizes); - } - - voidErrorCheck(loc, identifier, type); + if (! variable->getType().sameElementType(type)) { + error(loc, "redeclaration of array with a different type", identifier.c_str(), ""); + return; + } + + variable->getWritableType().setArraySizes(type); } bool TParseContext::arraySetMaxSize(TSourceLoc loc, TIntermSymbol *node, int size) @@ -1793,55 +1786,31 @@ bool TParseContext::arraySetMaxSize(TSourceLoc loc, TIntermSymbol *node, int siz // // Enforce non-initializer type/qualifier rules. // -void TParseContext::nonInitConstCheck(TSourceLoc loc, TString& identifier, TPublicType& type) +void TParseContext::nonInitConstCheck(TSourceLoc loc, TString& identifier, TType& type) { // // Make the qualifier make sense. // - if (type.qualifier.storage == EvqConst) { - type.qualifier.storage = EvqTemporary; + if (type.getQualifier().storage == EvqConst) { + type.getQualifier().storage = EvqTemporary; error(loc, "variables with qualifier 'const' must be initialized", identifier.c_str(), ""); } } // -// Do semantic checking for a variable declaration that has no initializer, -// and update the symbol table. +// See if the identifier is a built-in symbol that can be redeclared, and if so, +// copy the symbol table's read-only built-in variable to the current +// global level, where it can be modified based on the passed in type. // -void TParseContext::nonInitCheck(TSourceLoc loc, TString& identifier, TPublicType& publicType) +// Returns 0 if no redeclaration took place; meaning a normal declaration still +// needs to occur for it, not necessarily an error. +// +// Returns a redeclared and type-modified variable if a redeclarated occurred. +// +// Will emit +// +TVariable* TParseContext::redeclareBuiltin(TSourceLoc loc, const TString& identifier, const TType& type, bool& newDeclaration) { - TType type(publicType); - - bool newDeclaration; // true if a new entry gets added to the symbol table - TVariable* variable = redeclare(loc, identifier, type, newDeclaration); - - if (! variable) { - reservedErrorCheck(loc, identifier); - variable = new TVariable(&identifier, type); - if (! symbolTable.insert(*variable)) - error(loc, "redefinition", variable->getName().c_str(), ""); - else - newDeclaration = true; - } - - if (newDeclaration) { - voidErrorCheck(loc, identifier, publicType); - - // see if it's a linker-level object to track - if (type.getQualifier().isUniform() || type.getQualifier().isPipeInput() || type.getQualifier().isPipeOutput() || type.getQualifier().storage == EvqGlobal) - intermediate.addSymbolLinkageNode(linkage, *variable); - } -} - -// -// See if the identifier is a built-in symbol that can be redeclared, -// and if so, copy of the symbol table's read-only built-in to the current -// global level, so it can be modified. -// -TVariable* TParseContext::redeclare(TSourceLoc loc, const TString& identifier, const TType& type, bool& newDeclaration) -{ - newDeclaration = false; // true if a new entry gets added to the symbol table - if (profile == EEsProfile || identifier.substr(0, 3) != TString("gl_") || symbolTable.atBuiltInLevel()) return 0; @@ -1864,24 +1833,28 @@ TVariable* TParseContext::redeclare(TSourceLoc loc, const TString& identifier, c bool builtIn; TSymbol* symbol = symbolTable.find(identifier, &builtIn); - // If the symbol was not found, this must be a version/profile/stage + // If the symbol was not found, this must be a version/profile/stage // that doesn't have it. if (! symbol) return 0; TVariable* variable = symbol->getAsVariable(); - // If it wasn't at a built-in level, then it's already been redeclared - if (! builtIn) - return variable; + // If it wasn't at a built-in level, then it's already been redeclared; + // that is, this is a redeclaration of a redeclaration, reuse that initial + // redeclaration. Otherwise, make the new one. + if (builtIn) { + // Copy the symbol up to make a writable version + newDeclaration = true; + variable = symbolTable.copyUp(variable); + } - // Otherwise, time to copy the symbol up to make a writable version - newDeclaration = true; - variable = symbolTable.copyUp(variable); + // Now, modify the type of the copy, as per the type of the current redeclaration. + // TODO: functionality: verify type change is allowed and make the change in type + return variable; } - error(loc, "cannot redeclare this built-in variable", identifier.c_str(), ""); return 0; } @@ -2013,44 +1986,102 @@ const TFunction* TParseContext::findFunction(TSourceLoc loc, TFunction* call, bo } // -// Handle all types of initializers from the grammar. +// Do everything necessary to handle a variable (non-block) declaration. +// Either redeclaring a variable, or making a new one, updating the symbol +// table, and all error checking. // -bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier, TPublicType& pType, - TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable) +// Returns a subtree node that computes an initializer, if needed. +// Returns 0 if there is no code to execute for initialization. +// +TIntermNode* TParseContext::declareVariable(TSourceLoc loc, TString& identifier, TPublicType& publicType, TArraySizes* arraySizes, TIntermTyped* initializer) { - TType type(pType); + TType type(publicType); - if (variable == 0) { - if (reservedErrorCheck(loc, identifier)) - return true; + if (voidErrorCheck(loc, identifier, type.getBasicType())) + return 0; - if (voidErrorCheck(loc, identifier, pType)) - return true; + if (! initializer) + nonInitConstCheck(loc, identifier, type); - // - // add variable to symbol table - // - variable = new TVariable(&identifier, type); - if (! symbolTable.insert(*variable)) { - error(loc, "redefinition", variable->getName().c_str(), ""); - return true; - // don't delete variable, it's used by error recovery, and the pool - // pop will take care of the memory + // Check for redeclaration of built-ins and/or attempting to declare a reserved name + bool newDeclaration = false; // true if a new entry gets added to the symbol table + TVariable* variable = redeclareBuiltin(loc, identifier, type, newDeclaration); + if (! variable) + reservedErrorCheck(loc, identifier); + + // Declare the variable + if (arraySizes) { + // for ES, since size isn't coming from an initializer, it has to be explicitly declared now + if (profile == EEsProfile && ! initializer) + arraySizeRequiredCheck(loc, arraySizes->getSize()); + + arrayDimCheck(loc, &type, arraySizes); + if (! arrayQualifierError(loc, type.getQualifier())) { + type.setArraySizes(arraySizes); + declareArray(loc, identifier, type, variable, newDeclaration); } + + if (initializer) + profileRequires(loc, ENoProfile, 120, "GL_3DL_array_objects", "initializer"); + } else { + // non-array case + if (! variable) + variable = declareNonArray(loc, identifier, type, newDeclaration); } + // Deal with initializer + TIntermNode* initNode = 0; + if (variable && initializer) + initNode = executeInitializer(loc, identifier, type, initializer, variable); + + // see if it's a linker-level object to track + if (newDeclaration && symbolTable.atGlobalLevel()) + intermediate.addSymbolLinkageNode(linkage, *variable); + + return initNode; +} + +// +// Declare a non-array variable, the main point being there is no redeclaration +// for resizing allowed. +// +// Return the successfully declared variable. +// +TVariable* TParseContext::declareNonArray(TSourceLoc loc, TString& identifier, TType& type, bool& newDeclaration) +{ + // make a new variable + TVariable* variable = new TVariable(&identifier, type); + + // add variable to symbol table + if (! symbolTable.insert(*variable)) { + error(loc, "redefinition", variable->getName().c_str(), ""); + return 0; + } else { + newDeclaration = true; + return variable; + } +} + +// +// Handle all types of initializers from the grammar. +// +TIntermNode* TParseContext::executeInitializer(TSourceLoc loc, TString& identifier, TType& type, + TIntermTyped* initializer, TVariable* variable) +{ // - // identifier must be of type constant, a global, or a temporary + // Identifier must be of type constant, a global, or a temporary, and + // starting at version 120, desktop allows uniforms to have initializers. // TStorageQualifier qualifier = variable->getType().getQualifier().storage; - if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal) && (qualifier != EvqConst)) { + if (! (qualifier == EvqTemporary || qualifier == EvqGlobal || qualifier == EvqConst || + qualifier == EvqUniform && profile != EEsProfile && version >= 120)) { error(loc, " cannot initialize this type of qualifier ", variable->getType().getStorageQualifierString(), ""); - return true; + return 0; } // Fix arrayness if variable is unsized, getting size for initializer if (initializer->getType().isArray() && initializer->getType().getArraySize() > 0 && - type.isArray() && type.getArraySize() == 0) + type.isArray() && type.getArraySize() == 0) type.changeArraySize(initializer->getType().getArraySize()); // @@ -2060,13 +2091,13 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier, if (qualifier != initializer->getType().getQualifier().storage) { error(loc, " assigning non-constant to", "=", "'%s'", variable->getType().getCompleteString().c_str()); variable->getWritableType().getQualifier().storage = EvqTemporary; - return true; + return 0; } if (type != initializer->getType()) { error(loc, " non-matching types for const initializer ", variable->getType().getStorageQualifierString(), ""); variable->getWritableType().getQualifier().storage = EvqTemporary; - return true; + return 0; } if (initializer->getAsConstantUnion()) { TConstUnion* unionArray = variable->getConstUnionPointer(); @@ -2083,26 +2114,25 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier, variable->shareConstPointer(constArray); } else { error(loc, "expected variable", initializer->getAsSymbolNode()->getName().c_str(), ""); - return true; + return 0; } } else { error(loc, " cannot assign to", "=", "'%s'", variable->getType().getCompleteString().c_str()); variable->getWritableType().getQualifier().storage = EvqTemporary; - return true; + return 0; } } if (qualifier != EvqConst) { TIntermSymbol* intermSymbol = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), loc); - intermNode = intermediate.addAssign(EOpAssign, intermSymbol, initializer, loc); - if (intermNode == 0) { + TIntermNode* initNode = intermediate.addAssign(EOpAssign, intermSymbol, initializer, loc); + if (! initNode) assignError(loc, "=", intermSymbol->getCompleteString(), initializer->getCompleteString()); - return true; - } - } else - intermNode = 0; - return false; + return initNode; + } + + return 0; } // This function is used to test for the correctness of the parameters passed to various constructor functions diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 2737553c..f40cd784 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -100,13 +100,12 @@ public: void globalCheck(TSourceLoc, bool global, const char* token); bool constructorError(TSourceLoc, TIntermNode*, TFunction&, TOperator, TType&); void arraySizeCheck(TSourceLoc, TIntermTyped* expr, int& size); - bool arrayQualifierError(TSourceLoc, const TPublicType&); + bool arrayQualifierError(TSourceLoc, const TQualifier&); void arraySizeRequiredCheck(TSourceLoc, int size); void arrayDimError(TSourceLoc); void arrayDimCheck(TSourceLoc, TArraySizes* sizes1, TArraySizes* sizes2); void arrayDimCheck(TSourceLoc, const TType*, TArraySizes*); - void arrayCheck(TSourceLoc, TString& identifier, const TPublicType&, TVariable*& variable); - bool voidErrorCheck(TSourceLoc, const TString&, const TPublicType&); + bool voidErrorCheck(TSourceLoc, const TString&, TBasicType); void boolCheck(TSourceLoc, const TIntermTyped*); void boolCheck(TSourceLoc, const TPublicType&); bool samplerErrorCheck(TSourceLoc, const TPublicType& pType, const char* reason); @@ -119,9 +118,7 @@ public: void precisionQualifierCheck(TSourceLoc, TPublicType&); void parameterSamplerCheck(TSourceLoc, TStorageQualifier qualifier, const TType& type); bool containsSampler(const TType& type); - void nonInitConstCheck(TSourceLoc, TString& identifier, TPublicType& type); - void nonInitCheck(TSourceLoc, TString& identifier, TPublicType& type); - TVariable* redeclare(TSourceLoc, const TString&, const TType&, bool& newDeclaration); + TVariable* redeclareBuiltin(TSourceLoc, const TString&, const TType&, bool& newDeclaration); void paramCheck(TSourceLoc, TStorageQualifier qualifier, TType* type); void nestedBlockCheck(TSourceLoc); void nestedStructCheck(TSourceLoc); @@ -131,8 +128,7 @@ public: void mergeLayoutQualifiers(TSourceLoc, TQualifier& dest, const TQualifier& src); const TFunction* findFunction(TSourceLoc, TFunction* pfnCall, bool *builtIn = 0); - bool executeInitializerError(TSourceLoc, TString& identifier, TPublicType& pType, - TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); + TIntermNode* declareVariable(TSourceLoc, TString& identifier, TPublicType&, TArraySizes* typeArray = 0, TIntermTyped* initializer = 0); TIntermTyped* addConstructor(TIntermNode*, const TType&, TOperator, TFunction*, TSourceLoc); TIntermTyped* constructStruct(TIntermNode*, const TType&, int, TSourceLoc); TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermNode*, TSourceLoc, bool subset); @@ -170,6 +166,11 @@ public: protected: const char* getPreamble(); TBehavior getExtensionBehavior(const char* behavior); + void nonInitConstCheck(TSourceLoc, TString& identifier, TType& type); + TVariable* TParseContext::declareNonArray(TSourceLoc, TString& identifier, TType&, bool& newDeclaration); + void declareArray(TSourceLoc, TString& identifier, const TType&, TVariable*&, bool& newDeclaration); + TIntermNode* executeInitializer(TSourceLoc, TString& identifier, TType&, TIntermTyped* initializer, TVariable* variable); + public: // diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index 73688db1..614bf419 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -972,61 +972,21 @@ init_declarator_list } | init_declarator_list COMMA IDENTIFIER { $$ = $1; - parseContext.nonInitConstCheck($3.loc, *$3.string, $$.type); - parseContext.nonInitCheck($3.loc, *$3.string, $$.type); + parseContext.declareVariable($3.loc, *$3.string, $1.type); } | init_declarator_list COMMA IDENTIFIER array_specifier { - parseContext.nonInitConstCheck($3.loc, *$3.string, $1.type); - if (parseContext.profile == EEsProfile) - parseContext.arraySizeRequiredCheck($4.loc, $4.arraySizes->getSize()); - parseContext.arrayDimCheck($3.loc, $1.type.arraySizes, $4.arraySizes); - $$ = $1; - - if (! parseContext.arrayQualifierError($4.loc, $1.type)) { - $1.type.arraySizes = $4.arraySizes; - TVariable* variable; - parseContext.arrayCheck($4.loc, *$3.string, $1.type, variable); - } + parseContext.declareVariable($3.loc, *$3.string, $1.type, $4.arraySizes); } | init_declarator_list COMMA IDENTIFIER array_specifier EQUAL initializer { - $$ = $1; - - TVariable* variable = 0; - if (! parseContext.arrayQualifierError($4.loc, $1.type)) { - $1.type.arraySizes = $4.arraySizes; - parseContext.arrayCheck($4.loc, *$3.string, $1.type, variable); - } - parseContext.arrayDimCheck($3.loc, $1.type.arraySizes, $4.arraySizes); - - parseContext.profileRequires($5.loc, ENoProfile, 120, "GL_3DL_array_objects", "initializer"); - - TIntermNode* intermNode; - if (! parseContext.executeInitializerError($3.loc, *$3.string, $1.type, $6, intermNode, variable)) { - // - // build the intermediate representation - // - if (intermNode) - $$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, intermNode, $5.loc); - else - $$.intermAggregate = $1.intermAggregate; - } else - $$.intermAggregate = 0; + $$.type = $1.type; + TIntermNode* initNode = parseContext.declareVariable($3.loc, *$3.string, $1.type, $4.arraySizes, $6); + $$.intermAggregate = parseContext.intermediate.growAggregate($1.intermAggregate, initNode, $5.loc); } | init_declarator_list COMMA IDENTIFIER EQUAL initializer { - $$ = $1; - - TIntermNode* intermNode; - if (!parseContext.executeInitializerError($3.loc, *$3.string, $1.type, $5, intermNode)) { - // - // build the intermediate representation - // - if (intermNode) - $$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, intermNode, $4.loc); - else - $$.intermAggregate = $1.intermAggregate; - } else - $$.intermAggregate = 0; + $$.type = $1.type; + TIntermNode* initNode = parseContext.declareVariable($3.loc, *$3.string, $1.type, 0, $5); + $$.intermAggregate = parseContext.intermediate.growAggregate($1.intermAggregate, initNode, $4.loc); } ; @@ -1037,70 +997,26 @@ single_declaration parseContext.updateTypedDefaults($1.loc, $$.type.qualifier, 0); } | fully_specified_type IDENTIFIER { - $$.intermAggregate = 0; $$.type = $1; - - parseContext.nonInitConstCheck($2.loc, *$2.string, $$.type); - parseContext.nonInitCheck($2.loc, *$2.string, $$.type); - + $$.intermAggregate = 0; + parseContext.declareVariable($2.loc, *$2.string, $1); parseContext.updateTypedDefaults($2.loc, $$.type.qualifier, $2.string); } | fully_specified_type IDENTIFIER array_specifier { - $$.intermAggregate = 0; - parseContext.nonInitConstCheck($2.loc, *$2.string, $1); - if (parseContext.profile == EEsProfile) - parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->getSize()); - parseContext.arrayDimCheck($2.loc, $1.arraySizes, $3.arraySizes); - $$.type = $1; - - if (! parseContext.arrayQualifierError($3.loc, $1)) { - $1.arraySizes = $3.arraySizes; - TVariable* variable; - parseContext.arrayCheck($3.loc, *$2.string, $1, variable); - } + $$.intermAggregate = 0; + parseContext.declareVariable($2.loc, *$2.string, $1, $3.arraySizes); parseContext.updateTypedDefaults($2.loc, $$.type.qualifier, $2.string); } - | fully_specified_type IDENTIFIER array_specifier EQUAL initializer { - parseContext.arrayDimCheck($3.loc, $1.arraySizes, $3.arraySizes); - - $$.intermAggregate = 0; + | fully_specified_type IDENTIFIER array_specifier EQUAL initializer { $$.type = $1; - - TVariable* variable = 0; - if (! parseContext.arrayQualifierError($3.loc, $1)) { - $1.arraySizes = $3.arraySizes; - parseContext.arrayCheck($3.loc, *$2.string, $1, variable); - } - - parseContext.profileRequires($4.loc, ENoProfile, 120, "GL_3DL_array_objects", "initializer"); - - TIntermNode* intermNode; - if (!parseContext.executeInitializerError($2.loc, *$2.string, $1, $5, intermNode, variable)) { - // - // Build intermediate representation - // - if (intermNode) - $$.intermAggregate = parseContext.intermediate.makeAggregate(intermNode, $4.loc); - else - $$.intermAggregate = 0; - } else - $$.intermAggregate = 0; + TIntermNode* initNode = parseContext.declareVariable($2.loc, *$2.string, $1, $3.arraySizes, $5); + $$.intermAggregate = parseContext.intermediate.growAggregate(0, initNode, $4.loc); } | fully_specified_type IDENTIFIER EQUAL initializer { $$.type = $1; - - TIntermNode* intermNode; - if (!parseContext.executeInitializerError($2.loc, *$2.string, $1, $4, intermNode)) { - // - // Build intermediate representation - // - if (intermNode) - $$.intermAggregate = parseContext.intermediate.makeAggregate(intermNode, $3.loc); - else - $$.intermAggregate = 0; - } else - $$.intermAggregate = 0; + TIntermNode* initNode = parseContext.declareVariable($2.loc, *$2.string, $1, 0, $4); + $$.intermAggregate = parseContext.intermediate.growAggregate(0, initNode, $3.loc); } // Grammar Note: No 'enum', or 'typedef'. @@ -1128,7 +1044,7 @@ fully_specified_type parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getSize()); } - if ($2.arraySizes && parseContext.arrayQualifierError($2.loc, $1)) + if ($2.arraySizes && parseContext.arrayQualifierError($2.loc, $1.qualifier)) $2.arraySizes = 0; parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true); @@ -2121,7 +2037,7 @@ struct_declaration $$ = $2; - parseContext.voidErrorCheck($1.loc, (*$2)[0].type->getFieldName(), $1); + parseContext.voidErrorCheck($1.loc, (*$2)[0].type->getFieldName(), $1.basicType); parseContext.precisionQualifierCheck($1.loc, $1); for (unsigned int i = 0; i < $$->size(); ++i) { @@ -2139,7 +2055,7 @@ struct_declaration $$ = $3; - parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2); + parseContext.voidErrorCheck($2.loc, (*$3)[0].type->getFieldName(), $2.basicType); parseContext.mergeQualifiers($2.loc, $2.qualifier, $1.qualifier, true); parseContext.precisionQualifierCheck($2.loc, $2); @@ -2302,13 +2218,14 @@ condition parseContext.boolCheck($1->getLoc(), $1); } | fully_specified_type IDENTIFIER EQUAL initializer { - TIntermNode* intermNode; parseContext.boolCheck($2.loc, $1); - if (parseContext.executeInitializerError($2.loc, *$2.string, $1, $4, intermNode)) - $$ = 0; + TType type($1); + TIntermNode* initNode = parseContext.declareVariable($2.loc, *$2.string, $1, 0, $4); + if (initNode) + $$ = initNode->getAsTyped(); else - $$ = $4; + $$ = 0; } ;