Added constant folding for relational (e.g. lessThan) built-ins, relational built-ins for uints, and bitwise ops for mixed scalars and vectors.

Also, allow comments to precede "#version 100".

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@23974 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-11-09 00:18:22 +00:00
parent 0876a58203
commit 77d908af8a
10 changed files with 151 additions and 9 deletions

View file

@ -1,5 +1,5 @@
// okay
#version 100
int a[3] = { 2, 3, 4, }; // ERROR
int uint;

View file

@ -43,4 +43,25 @@ vec4 gl_Color; // ERROR, storage
void bar2()
{
vec4 s = textureGather(sampC, vec3(0.2));
uvec3 uv3;
bvec3 b3;
b3 = lessThan(uv3, uv3);
b3 = equal(uv3, uv3);
const bvec2 bl1 = greaterThanEqual(uvec2(2, 3), uvec2(3,3));
const bvec2 bl2 = equal(uvec2(2, 3), uvec2(3,3));
const bvec2 bl3 = equal(bl1, bl2); // yes, equal
int a1[int(bl3.x)];
int a2[int(bl3.y)];
a1[0]; // size 1
a2[0]; // size 1
const bvec4 bl4 = notEqual(greaterThan(uvec4(1,2,3,4), uvec4(0,2,0,6)), lessThanEqual(uvec4(7,8,9,10), uvec4(6, 8, 0, 11))); // compare (t,f,t,f) with (f,t,f,t)
int a3[int(bl4.x)+int(bl4.y)+int(bl4.z)+int(bl4.w)];
a3[3]; // size 4
b3 != b3;
b3 < b3; // ERROR
uv3 > uv3; // ERROR
uvec2(2, 3) >= uvec2(3,3); // ERROR
int(bl4) <= int(bl4); // true
int(bl4.x) > int(bl4.y); // false
}

View file

@ -81,8 +81,8 @@ void main()
a >> u;
iv3 >> iv4;
i & u;
u ^ uv3;
i & u;
u &= uv3;
i | uv3;
u & f;
m2 | m2;
@ -125,5 +125,11 @@ void main()
i & i;
u | u;
iv3 ^ iv3;
u & uv3;
uv3 | u;
uv3 &= u;
int arr[0x222 & 0xf];
arr[1]; // size 2
int arr2[(uvec2(0, 0x2) | 0x1u).y];
arr2[2]; // size 3
}

View file

@ -4,7 +4,10 @@ ERROR: 0:35: 'redeclaration' : cannot change the type of gl_Color
ERROR: 0:38: 'gl_Color' : redeclaring non-array as array
ERROR: 0:39: 'redeclaration' : cannot change storage, memory, or auxiliary qualification of gl_Color
WARNING: 0:45: extension GL_ARB_texture_gather is being used for texture gather function
ERROR: 4 compilation errors. No code generated.
ERROR: 0:62: '<' : wrong operand types: no operation '<' exists that takes a left-hand operand of type '3-component vector of bool' and a right operand of type '3-component vector of bool' (or there is no acceptable conversion)
ERROR: 0:63: '>' : wrong operand types: no operation '>' exists that takes a left-hand operand of type '3-component vector of uint' and a right operand of type '3-component vector of uint' (or there is no acceptable conversion)
ERROR: 0:64: '>=' : wrong operand types: no operation '>=' exists that takes a left-hand operand of type 'const 2-component vector of uint' and a right operand of type 'const 2-component vector of uint' (or there is no acceptable conversion)
ERROR: 7 compilation errors. No code generated.
ERROR: node is still EOpNull!
0:16 Function Definition: main( (void)
@ -53,6 +56,41 @@ ERROR: node is still EOpNull!
0:45 0.200000
0:45 0.200000
0:45 0.200000
0:49 move second child to first child (3-component vector of bool)
0:49 'b3' (3-component vector of bool)
0:49 Compare Less Than (3-component vector of bool)
0:49 'uv3' (3-component vector of uint)
0:49 'uv3' (3-component vector of uint)
0:50 move second child to first child (3-component vector of bool)
0:50 'b3' (3-component vector of bool)
0:50 Equal (3-component vector of bool)
0:50 'uv3' (3-component vector of uint)
0:50 'uv3' (3-component vector of uint)
0:56 direct index (int)
0:56 'a1' (1-element array of int)
0:56 Constant:
0:56 0 (const int)
0:57 direct index (int)
0:57 'a2' (1-element array of int)
0:57 Constant:
0:57 0 (const int)
0:60 direct index (int)
0:60 'a3' (4-element array of int)
0:60 Constant:
0:60 3 (const int)
0:61 Compare Not Equal (bool)
0:61 'b3' (3-component vector of bool)
0:61 'b3' (3-component vector of bool)
0:62 Constant:
0:62 false (const bool)
0:63 Constant:
0:63 false (const bool)
0:64 Constant:
0:64 false (const bool)
0:65 Constant:
0:65 true (const bool)
0:66 Constant:
0:66 false (const bool)
0:? Linker Objects
0:? 'a' (3-component vector of float)
0:? 'b' (float)

View file

@ -48,7 +48,7 @@ ERROR: 0:80: '>>' : wrong operand types: no operation '>>' exists that takes a
ERROR: 0:81: '>>' : wrong operand types: no operation '>>' exists that takes a left-hand operand of type '5-element array of mediump float' and a right operand of type 'mediump uint' (or there is no acceptable conversion)
ERROR: 0:82: '>>' : wrong operand types: no operation '>>' exists that takes a left-hand operand of type 'mediump 3-component vector of int' and a right operand of type 'mediump 4-component vector of int' (or there is no acceptable conversion)
ERROR: 0:84: '&' : wrong operand types: no operation '&' exists that takes a left-hand operand of type 'mediump int' and a right operand of type 'mediump uint' (or there is no acceptable conversion)
ERROR: 0:85: '^' : wrong operand types: no operation '^' exists that takes a left-hand operand of type 'mediump uint' and a right operand of type 'mediump 3-component vector of uint' (or there is no acceptable conversion)
ERROR: 0:85: 'assign' : cannot convert from 'mediump 3-component vector of uint' to 'mediump uint'
ERROR: 0:86: '|' : wrong operand types: no operation '|' exists that takes a left-hand operand of type 'mediump int' and a right operand of type 'mediump 3-component vector of uint' (or there is no acceptable conversion)
ERROR: 0:87: '&' : wrong operand types: no operation '&' exists that takes a left-hand operand of type 'mediump uint' and a right operand of type 'mediump float' (or there is no acceptable conversion)
ERROR: 0:88: '|' : wrong operand types: no operation '|' exists that takes a left-hand operand of type 'mediump 2X2 matrix of float' and a right operand of type 'mediump 2X2 matrix of float' (or there is no acceptable conversion)
@ -211,6 +211,23 @@ ERROR: node is still EOpNull!
0:127 exclusive-or (mediump 3-component vector of int)
0:127 'iv3' (mediump 3-component vector of int)
0:127 'iv3' (mediump 3-component vector of int)
0:128 bitwise and (mediump 3-component vector of uint)
0:128 'u' (mediump uint)
0:128 'uv3' (mediump 3-component vector of uint)
0:129 inclusive-or (mediump 3-component vector of uint)
0:129 'uv3' (mediump 3-component vector of uint)
0:129 'u' (mediump uint)
0:130 and second child into first child (mediump 3-component vector of uint)
0:130 'uv3' (mediump 3-component vector of uint)
0:130 'u' (mediump uint)
0:132 direct index (mediump int)
0:132 'arr' (2-element array of mediump int)
0:132 Constant:
0:132 1 (const int)
0:134 direct index (mediump int)
0:134 'arr2' (3-element array of mediump int)
0:134 Constant:
0:134 2 (const int)
0:? Linker Objects
0:? 'instanceName' (layout(column_major shared ) uniform block{f})
0:? 's' (structure{i})