GLSL: Fix #1359: don't allow unsized arrays as initializers.

This commit is contained in:
John Kessenich 2018-04-23 15:18:42 -06:00
parent d8462c6f49
commit b4cb70fcd9
6 changed files with 45 additions and 17 deletions

View file

@ -102,11 +102,12 @@ void foo3()
}
int[] i = int[](); // ERROR, need constructor arguments
float emptyA[];
float b = vec4(emptyA); // ERROR, array can't be a constructor argument
uniform sampler2D s2d[];
void foo4()
{
s2d[a]; // ERROR, can't variably index unsized array
}
float emptyA[];
float b = vec4(emptyA); // ERROR, array can't be a constructor argument
uniform sampler2D s2d[];
void foo4()
{
s2d[a]; // ERROR, can't variably index unsized array
float local[] = gUnusedUnsized; // ERROR, can initialize with runtime-sized array
}

View file

@ -27,7 +27,8 @@ ERROR: 0:104: '=' : cannot convert from ' const float' to ' global unsized 1-el
ERROR: 0:106: 'constructor' : array argument must be sized
ERROR: 0:111: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
ERROR: 0:111: 'variable indexing sampler array' : not supported with this profile: none
ERROR: 28 compilation errors. No code generated.
ERROR: 0:112: '[]' : array initializer must be sized
ERROR: 29 compilation errors. No code generated.
Shader version: 130
@ -272,6 +273,10 @@ ERROR: node is still EOpNull!
0:111 indirect index ( temp sampler2D)
0:111 's2d' ( uniform runtime-sized array of sampler2D)
0:111 'a' ( uniform int)
0:112 Sequence
0:112 move second child to first child ( temp unsized 1-element array of float)
0:112 'local' ( temp unsized 1-element array of float)
0:112 'gUnusedUnsized' ( global unsized 1-element array of float)
0:? Linker Objects
0:? 'gu' ( global runtime-sized array of float)
0:? 'g4' ( global 4-element array of float)

View file

@ -31,7 +31,8 @@ ERROR: 0:104: 'variable index' : required extension not requested: GL_EXT_nonuni
ERROR: 0:105: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
ERROR: 0:106: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
ERROR: 0:107: 'variable index' : required extension not requested: GL_EXT_nonuniform_qualifier
ERROR: 26 compilation errors. No code generated.
ERROR: 0:109: '[]' : array initializer must be sized
ERROR: 27 compilation errors. No code generated.
Shader version: 450
@ -311,6 +312,13 @@ ERROR: node is still EOpNull!
0:107 indirect index (layout( binding=9 r32f) temp imageBuffer)
0:107 'storageTexelBuffer' (layout( binding=9 r32f) uniform runtime-sized array of imageBuffer)
0:107 'i' ( global int)
0:109 Sequence
0:109 move second child to first child ( temp unsized 1-element array of float)
0:109 'local' ( temp unsized 1-element array of float)
0:109 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:109 '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:109 Constant:
0:109 1 (const int)
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})
@ -611,6 +619,13 @@ ERROR: node is still EOpNull!
0:107 indirect index (layout( binding=9 r32f) temp imageBuffer)
0:107 'storageTexelBuffer' (layout( binding=9 r32f) uniform runtime-sized array of imageBuffer)
0:107 'i' ( global int)
0:109 Sequence
0:109 move second child to first child ( temp 1-element array of float)
0:109 'local' ( temp 1-element array of float)
0:109 b: direct index for structure (layout( column_major shared) uniform runtime-sized array of float)
0:109 '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:109 Constant:
0:109 1 (const int)
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})

View file

@ -105,4 +105,6 @@ void main()
storageImage[i]; // ERROR, need extension
uniformTexelBuffer[i]; // ERROR, need extension
storageTexelBuffer[i]; // ERROR, need extension
float local[] = ubuf.b; // ERROR, can initialize with runtime-sized array
}