GLSL: Implement correct semantic checking for run-time sized arrays.

This commit is contained in:
John Kessenich 2018-04-02 14:52:15 -06:00
parent 5a867acad5
commit 6a4a427efe
5 changed files with 601 additions and 2 deletions

View File

@ -0,0 +1,490 @@
runtimeArray.vert
ERROR: 0:52: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:53: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:54: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:57: 'length' : array must be declared with a size before using this method
ERROR: 0:58: 'length' : array must be declared with a size before using this method
ERROR: 0:59: 'length' : array must be declared with a size before using this method
ERROR: 0:62: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:63: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:64: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:67: 'length' : array must be declared with a size before using this method
ERROR: 0:68: 'length' : array must be declared with a size before using this method
ERROR: 0:69: 'length' : array must be declared with a size before using this method
ERROR: 0:72: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:73: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:74: '[' : array must be redeclared with a size before being indexed with a variable
ERROR: 0:77: 'length' : array must be declared with a size before using this method
ERROR: 0:78: 'length' : array must be declared with a size before using this method
ERROR: 0:79: 'length' : array must be declared with a size before using this method
ERROR: 18 compilation errors. No code generated.
Shader version: 450
ERROR: node is still EOpNull!
0:35 Function Definition: main( ( global void)
0:35 Function Parameters:
0:37 Sequence
0:37 direct index (layout( column_major shared) temp int)
0:37 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:37 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:37 Constant:
0:37 0 (const int)
0:37 Constant:
0:37 3 (const int)
0:38 direct index (layout( column_major shared) temp float)
0:38 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:38 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:38 Constant:
0:38 1 (const int)
0:38 Constant:
0:38 3 (const int)
0:39 direct index (layout( column_major shared) temp int)
0:39 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:39 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:39 Constant:
0:39 0 (const int)
0:39 Constant:
0:39 3 (const int)
0:40 direct index (layout( column_major shared) temp float)
0:40 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:40 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:40 Constant:
0:40 1 (const int)
0:40 Constant:
0:40 3 (const int)
0:42 direct index (layout( column_major shared) temp int)
0:42 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:42 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:42 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:42 Constant:
0:42 3 (const int)
0:42 Constant:
0:42 0 (const int)
0:42 Constant:
0:42 3 (const int)
0:43 direct index (layout( column_major shared) temp float)
0:43 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:43 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:43 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:43 Constant:
0:43 3 (const int)
0:43 Constant:
0:43 1 (const int)
0:43 Constant:
0:43 3 (const int)
0:44 direct index (layout( column_major shared) temp int)
0:44 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:44 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:44 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:44 Constant:
0:44 3 (const int)
0:44 Constant:
0:44 0 (const int)
0:44 Constant:
0:44 3 (const int)
0:45 direct index (layout( column_major shared) temp float)
0:45 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:45 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:45 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:45 Constant:
0:45 3 (const int)
0:45 Constant:
0:45 1 (const int)
0:45 Constant:
0:45 3 (const int)
0:47 direct index (layout( column_major shared) temp int)
0:47 aua: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:47 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:47 Constant:
0:47 0 (const uint)
0:47 Constant:
0:47 3 (const int)
0:48 direct index (layout( column_major shared) temp float)
0:48 aub: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:48 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:48 Constant:
0:48 1 (const uint)
0:48 Constant:
0:48 3 (const int)
0:49 direct index (layout( column_major shared) temp int)
0:49 aba: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:49 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:49 Constant:
0:49 0 (const uint)
0:49 Constant:
0:49 3 (const int)
0:50 direct index (layout( column_major shared) temp float)
0:50 abb: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:50 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:50 Constant:
0:50 1 (const uint)
0:50 Constant:
0:50 3 (const int)
0:52 indirect index (layout( column_major shared) temp int)
0:52 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:52 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:52 Constant:
0:52 0 (const int)
0:52 'i' ( global int)
0:53 indirect index (layout( column_major shared) temp float)
0:53 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:53 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:53 Constant:
0:53 1 (const int)
0:53 'i' ( global int)
0:54 indirect index (layout( column_major shared) temp int)
0:54 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:54 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:54 Constant:
0:54 0 (const int)
0:54 'i' ( global int)
0:55 indirect index (layout( column_major shared) temp float)
0:55 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:55 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:55 Constant:
0:55 1 (const int)
0:55 'i' ( global int)
0:57 Constant:
0:57 1 (const int)
0:58 Constant:
0:58 1 (const int)
0:59 Constant:
0:59 1 (const int)
0:60 array length ( temp int)
0:60 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:60 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:60 Constant:
0:60 1 (const int)
0:62 indirect index (layout( column_major shared) temp int)
0:62 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:62 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:62 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:62 Constant:
0:62 1 (const int)
0:62 Constant:
0:62 0 (const int)
0:62 'i' ( global int)
0:63 indirect index (layout( column_major shared) temp float)
0:63 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:63 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:63 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:63 Constant:
0:63 1 (const int)
0:63 Constant:
0:63 1 (const int)
0:63 'i' ( global int)
0:64 indirect index (layout( column_major shared) temp int)
0:64 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:64 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:64 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:64 Constant:
0:64 1 (const int)
0:64 Constant:
0:64 0 (const int)
0:64 'i' ( global int)
0:65 indirect index (layout( column_major shared) temp float)
0:65 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:65 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:65 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:65 Constant:
0:65 1 (const int)
0:65 Constant:
0:65 1 (const int)
0:65 'i' ( global int)
0:67 Constant:
0:67 1 (const int)
0:68 Constant:
0:68 1 (const int)
0:69 Constant:
0:69 1 (const int)
0:70 array length ( temp int)
0:70 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:70 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:70 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:70 Constant:
0:70 1 (const int)
0:70 Constant:
0:70 1 (const int)
0:72 indirect index (layout( column_major shared) temp int)
0:72 aua: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:72 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:72 Constant:
0:72 0 (const uint)
0:72 'i' ( global int)
0:73 indirect index (layout( column_major shared) temp float)
0:73 aub: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:73 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:73 Constant:
0:73 1 (const uint)
0:73 'i' ( global int)
0:74 indirect index (layout( column_major shared) temp int)
0:74 aba: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:74 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:74 Constant:
0:74 0 (const uint)
0:74 'i' ( global int)
0:75 indirect index (layout( column_major shared) temp float)
0:75 abb: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:75 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:75 Constant:
0:75 1 (const uint)
0:75 'i' ( global int)
0:77 Constant:
0:77 1 (const int)
0:78 Constant:
0:78 1 (const int)
0:79 Constant:
0:79 1 (const int)
0:80 array length ( temp int)
0:80 abb: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:80 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:80 Constant:
0:80 1 (const uint)
0:? Linker Objects
0:? 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:? 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:? 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:? 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:? 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:? 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:? 'i' ( global int)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
Linked vertex stage:
Shader version: 450
ERROR: node is still EOpNull!
0:35 Function Definition: main( ( global void)
0:35 Function Parameters:
0:37 Sequence
0:37 direct index (layout( column_major shared) temp int)
0:37 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:37 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:37 Constant:
0:37 0 (const int)
0:37 Constant:
0:37 3 (const int)
0:38 direct index (layout( column_major shared) temp float)
0:38 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:38 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:38 Constant:
0:38 1 (const int)
0:38 Constant:
0:38 3 (const int)
0:39 direct index (layout( column_major shared) temp int)
0:39 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:39 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:39 Constant:
0:39 0 (const int)
0:39 Constant:
0:39 3 (const int)
0:40 direct index (layout( column_major shared) temp float)
0:40 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:40 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:40 Constant:
0:40 1 (const int)
0:40 Constant:
0:40 3 (const int)
0:42 direct index (layout( column_major shared) temp int)
0:42 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:42 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:42 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:42 Constant:
0:42 3 (const int)
0:42 Constant:
0:42 0 (const int)
0:42 Constant:
0:42 3 (const int)
0:43 direct index (layout( column_major shared) temp float)
0:43 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:43 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:43 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:43 Constant:
0:43 3 (const int)
0:43 Constant:
0:43 1 (const int)
0:43 Constant:
0:43 3 (const int)
0:44 direct index (layout( column_major shared) temp int)
0:44 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:44 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:44 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:44 Constant:
0:44 3 (const int)
0:44 Constant:
0:44 0 (const int)
0:44 Constant:
0:44 3 (const int)
0:45 direct index (layout( column_major shared) temp float)
0:45 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:45 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:45 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:45 Constant:
0:45 3 (const int)
0:45 Constant:
0:45 1 (const int)
0:45 Constant:
0:45 3 (const int)
0:47 direct index (layout( column_major shared) temp int)
0:47 aua: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:47 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:47 Constant:
0:47 0 (const uint)
0:47 Constant:
0:47 3 (const int)
0:48 direct index (layout( column_major shared) temp float)
0:48 aub: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:48 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:48 Constant:
0:48 1 (const uint)
0:48 Constant:
0:48 3 (const int)
0:49 direct index (layout( column_major shared) temp int)
0:49 aba: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:49 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:49 Constant:
0:49 0 (const uint)
0:49 Constant:
0:49 3 (const int)
0:50 direct index (layout( column_major shared) temp float)
0:50 abb: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:50 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:50 Constant:
0:50 1 (const uint)
0:50 Constant:
0:50 3 (const int)
0:52 indirect index (layout( column_major shared) temp int)
0:52 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:52 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:52 Constant:
0:52 0 (const int)
0:52 'i' ( global int)
0:53 indirect index (layout( column_major shared) temp float)
0:53 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:53 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:53 Constant:
0:53 1 (const int)
0:53 'i' ( global int)
0:54 indirect index (layout( column_major shared) temp int)
0:54 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:54 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:54 Constant:
0:54 0 (const int)
0:54 'i' ( global int)
0:55 indirect index (layout( column_major shared) temp float)
0:55 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:55 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:55 Constant:
0:55 1 (const int)
0:55 'i' ( global int)
0:57 Constant:
0:57 1 (const int)
0:58 Constant:
0:58 1 (const int)
0:59 Constant:
0:59 1 (const int)
0:60 array length ( temp int)
0:60 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:60 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:60 Constant:
0:60 1 (const int)
0:62 indirect index (layout( column_major shared) temp int)
0:62 a: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:62 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:62 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:62 Constant:
0:62 1 (const int)
0:62 Constant:
0:62 0 (const int)
0:62 'i' ( global int)
0:63 indirect index (layout( column_major shared) temp float)
0:63 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:63 direct index (layout( column_major shared) temp block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:63 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:63 Constant:
0:63 1 (const int)
0:63 Constant:
0:63 1 (const int)
0:63 'i' ( global int)
0:64 indirect index (layout( column_major shared) temp int)
0:64 a: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:64 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:64 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:64 Constant:
0:64 1 (const int)
0:64 Constant:
0:64 0 (const int)
0:64 'i' ( global int)
0:65 indirect index (layout( column_major shared) temp float)
0:65 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:65 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:65 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:65 Constant:
0:65 1 (const int)
0:65 Constant:
0:65 1 (const int)
0:65 'i' ( global int)
0:67 Constant:
0:67 1 (const int)
0:68 Constant:
0:68 1 (const int)
0:69 Constant:
0:69 1 (const int)
0:70 array length ( temp int)
0:70 b: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:70 direct index (layout( column_major shared) temp block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:70 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:70 Constant:
0:70 1 (const int)
0:70 Constant:
0:70 1 (const int)
0:72 indirect index (layout( column_major shared) temp int)
0:72 aua: direct index for structure (layout( column_major shared) uniform runtime-sized array of int)
0:72 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:72 Constant:
0:72 0 (const uint)
0:72 'i' ( global int)
0:73 indirect index (layout( column_major shared) temp float)
0:73 aub: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:73 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:73 Constant:
0:73 1 (const uint)
0:73 'i' ( global int)
0:74 indirect index (layout( column_major shared) temp int)
0:74 aba: direct index for structure (layout( column_major shared) buffer runtime-sized array of int)
0:74 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:74 Constant:
0:74 0 (const uint)
0:74 'i' ( global int)
0:75 indirect index (layout( column_major shared) temp float)
0:75 abb: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:75 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:75 Constant:
0:75 1 (const uint)
0:75 'i' ( global int)
0:77 Constant:
0:77 1 (const int)
0:78 Constant:
0:78 1 (const int)
0:79 Constant:
0:79 1 (const int)
0:80 array length ( temp int)
0:80 abb: direct index for structure (layout( column_major shared) buffer runtime-sized array of float)
0:80 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:80 Constant:
0:80 1 (const uint)
0:? Linker Objects
0:? 'buf' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:? 'ubuf' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:? 'bufa' (layout( column_major shared) buffer 4-element array of block{layout( column_major shared) buffer runtime-sized array of int a, layout( column_major shared) buffer runtime-sized array of float b})
0:? 'ubufa' (layout( column_major shared) uniform 4-element array of block{layout( column_major shared) uniform runtime-sized array of int a, layout( column_major shared) uniform runtime-sized array of float b})
0:? 'anon@0' (layout( column_major shared) buffer block{layout( column_major shared) buffer runtime-sized array of int aba, layout( column_major shared) buffer runtime-sized array of float abb})
0:? 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform runtime-sized array of int aua, layout( column_major shared) uniform runtime-sized array of float aub})
0:? 'i' ( global int)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)

81
Test/runtimeArray.vert Normal file
View File

@ -0,0 +1,81 @@
#version 450 core
buffer bn {
int a[];
float b[];
} buf;
uniform un {
int a[];
float b[];
} ubuf;
buffer bna {
int a[];
float b[];
} bufa[4];
uniform una {
int a[];
float b[];
} ubufa[4];
buffer abn {
int aba[];
float abb[];
};
uniform aun {
int aua[];
float aub[];
};
int i;
void main()
{
ubuf.a[3];
ubuf.b[3];
buf.a[3];
buf.b[3];
ubufa[3].a[3];
ubufa[3].b[3];
bufa[3].a[3];
bufa[3].b[3];
aua[3];
aub[3];
aba[3];
abb[3];
ubuf.a[i]; // ERROR
ubuf.b[i]; // ERROR
buf.a[i]; // ERROR
buf.b[i];
ubuf.a.length(); // ERROR
ubuf.b.length(); // ERROR
buf.a.length(); // ERROR
buf.b.length();
ubufa[1].a[i]; // ERROR
ubufa[1].b[i]; // ERROR
bufa[1].a[i]; // ERROR
bufa[1].b[i];
ubufa[1].a.length(); // ERROR
ubufa[1].b.length(); // ERROR
bufa[1].a.length(); // ERROR
bufa[1].b.length();
aua[i]; // ERROR
aub[i]; // ERROR
aba[i]; // ERROR
abb[i];
aua.length(); // ERROR
aub.length(); // ERROR
aba.length(); // ERROR
abb.length();
}

View File

@ -390,7 +390,7 @@ TIntermTyped* TParseContext::handleBracketDereference(const TSourceLoc& loc, TIn
error(loc, "", "[", "array must be sized by a redeclaration or layout qualifier before being indexed with a variable");
else {
// it is okay for a run-time sized array
if (base->getType().getQualifier().storage != EvqBuffer)
if (!isRuntimeSizable(*base))
error(loc, "", "[", "array must be redeclared with a size before being indexed with a variable");
}
base->getWritableType().setArrayVariablyIndexed();
@ -1235,7 +1235,7 @@ TIntermTyped* TParseContext::handleLengthMethod(const TSourceLoc& loc, TFunction
if (length == 0) {
if (intermNode->getAsSymbolNode() && isIoResizeArray(type))
error(loc, "", function->getName().c_str(), "array must first be sized by a redeclaration or layout qualifier");
else if (type.getQualifier().isUniformOrBuffer()) {
else if (isRuntimeLength(*intermNode->getAsTyped())) {
// Create a unary op and let the back end handle it
return intermediate.addBuiltInFunctionCall(loc, EOpArrayLength, true, intermNode, TType(EbtInt));
} else
@ -3268,6 +3268,31 @@ void TParseContext::declareArray(const TSourceLoc& loc, const TString& identifie
checkIoArraysConsistency(loc);
}
// Policy decision for whether a node could potentially be sized at runtime.
bool TParseContext::isRuntimeSizable(const TIntermTyped& base) const
{
const TType& type = base.getType();
if (type.getQualifier().storage == EvqBuffer) {
// in a buffer block
const TIntermBinary* binary = base.getAsBinaryNode();
if (binary != nullptr && binary->getOp() == EOpIndexDirectStruct) {
// is it the last member?
const int index = binary->getRight()->getAsConstantUnion()->getConstArray()[0].getIConst();
const int memberCount = (int)binary->getLeft()->getType().getStruct()->size();
if (index == memberCount - 1)
return true;
}
}
return false;
}
// Policy decision for whether a run-time .length() is allowed.
bool TParseContext::isRuntimeLength(const TIntermTyped& base) const
{
return isRuntimeSizable(base);
}
// Returns true if the first argument to the #line directive is the line number for the next line.
//
// Desktop, pre-version 3.30: "After processing this directive

View File

@ -427,6 +427,8 @@ protected:
TVariable* makeInternalVariable(const char* name, const TType&) const;
TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&);
void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&);
bool isRuntimeSizable(const TIntermTyped&) const;
bool isRuntimeLength(const TIntermTyped&) const;
TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable);
TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer);
void finish() override;

View File

@ -204,6 +204,7 @@ INSTANTIATE_TEST_CASE_P(
"Operations.frag",
"overlongLiteral.frag",
"prepost.frag",
"runtimeArray.vert",
"simpleFunctionCall.frag",
"structAssignment.frag",
"structDeref.frag",