blob: ba117bcad8bb39b10f9b6112a70c01785392ae15 [file] [log] [blame]
#X1. Constructor tests test constructing arrays of arrays with different declaration syntax and data types.
#X2. Return value tests test arrays of arrays as function return values.
#X3. Parameter tests test arrays of arrays as different types of function parameters (in, out, unnamed).
#X4. Implicit size tests test constructing arrays of arrays with implicit size.
#X5. Assignment tests test assigning an array of arrays to another array of arrays variable.
#X6. Length tests test the length method of arrays of arrays.
#X8. Array access tests test array element access at initialization with const/dynamic values
group constructor "Array of arrays constructors"
group explicit "Testing constructors with explicit sizes"
case float_3x3
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(7.4, -1.0, 2.0) | vec3(3.0, 1.6, -2.0) ];
output vec3 out0 = [ vec3(2.0, 0.5, 1.0) | vec3(2.0, 7.4, -1.0) | vec3(-2.0, 3.0, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
float[3][3] x;
x = float[3][3] ( float[3] (in0.z, in0.x, in0.y),
float[3] (in0.z, in0.x, in0.y),
float[3] (in0.z, in0.x, in0.y) );
out0 = vec3(x[0][0], x[1][1], x[2][2]);
${OUTPUT}
}
""
end
case float_3x4
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input vec4 in0 = [ vec4(0.5, 1.0, 2.0, 0.2) | vec4(7.4, -1.0, 2.0, -1.3) | vec4(3.0, 1.6, -2.0, 0.5) ];
output vec4 out0 = [ vec4(2.0, 0.5, 0.2, 1.0) | vec4(2.0, 7.4, -1.3, -1.0) | vec4(-2.0, 3.0, 0.5, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
float[3][4] x;
x = float[3][4] ( float[4] (in0.z, in0.x, in0.w, in0.y),
float[4] (in0.z, in0.x, in0.w, in0.y),
float[4] (in0.z, in0.x, in0.w, in0.y) );
out0 = vec4(x[0][0], x[1][1], x[2][2], x[2][3]);
${OUTPUT}
}
""
end
case int_3x1
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input ivec3 in0 = [ ivec3(0, 1, 2) | ivec3(7, -1, 2) | ivec3(3, 1, -2) ];
output ivec3 out0 = [ ivec3(2, 0, 1) | ivec3(2, 7, -1) | ivec3(-2, 3, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
int x[3][1];
x = int[3][1] ( int[1] (in0.z),
int[1] (in0.x),
int[1] (in0.y) );
out0 = ivec3(x[0][0], x[1][0], x[2][0]);
${OUTPUT}
}
""
end
case int_4x4x4
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input ivec4 in0 = [ ivec4(0, 1, 2, 0) | ivec4(7, -1, 2, -1) | ivec4(3, 1, -2, 0) ];
output ivec4 out0 = [ ivec4(2, 0, 0, 1) | ivec4(2, 7, -1, -1) | ivec4(-2, 3, 0, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
int[4] x[4][4];
x = int[4][4][4] ( int[4][4] ( (int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y))),
int[4][4] ( (int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y))),
int[4][4] ( (int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y))),
int[4][4] ( (int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y)),
(int[4] (in0.z, in0.x, in0.w, in0.y))) );
out0 = ivec4(x[0][0][0], x[1][1][1], x[2][2][2], x[3][3][3]);
${OUTPUT}
}
""
end
case bool_3x3x3
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input bvec3 in0 = [ bvec3(true, true, false) ];
output bvec3 out0 = [ bvec3(false, true, true) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
bool[3][3][3] x;
x = bool[3][3][3] ( bool[3][3] ((bool[3] (in0.y, in0.y, in0.y)),
(bool[3] (in0.z, in0.z, in0.z)),
(bool[3] (in0.x, in0.x, in0.x))),
bool[3][3] ((bool[3] (in0.y, in0.y, in0.y)),
(bool[3] (in0.z, in0.z, in0.z)),
(bool[3] (in0.x, in0.x, in0.x))),
bool[3][3] ((bool[3] (in0.y, in0.y, in0.y)),
(bool[3] (in0.z, in0.z, in0.z)),
(bool[3] (in0.x, in0.x, in0.x))) );
out0 = bvec3(x[1][1][1], x[0][0][0], x[2][2][2]);
${OUTPUT}
}
""
end
case bool_2x1x4
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input bvec4 in0 = [ bvec4(true, true, false, false) ];
output bvec4 out0 = [ bvec4(false, true, true, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
bool x[2][1][4];
x = bool[2][1][4] ( bool[1][4] ((bool[4] (in0.z, in0.x, in0.y, in0.w))),
bool[1][4] ((bool[4] (in0.z, in0.x, in0.y, in0.w))) );
out0 = bvec4(x[0][0][0], x[0][0][1], x[1][0][2], x[1][0][3]);
${OUTPUT}
}
""
end
case struct_3x2
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) ];
output vec3 out0 = [ vec3(2.0, -0.5, -1.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
struct Test
{
float f;
vec3 v;
};
Test a = Test(in0.z, vec3(in0.x, in0.y, in0.z));
Test b = Test(in0.y, vec3(-in0.z, -in0.x, -in0.y));
Test c = Test(in0.x, vec3(-in0.y, in0.z, -in0.x));
Test[2] x[3] = Test[3][2] ( (Test[2] (a, b)),
(Test[2] (c, a)),
(Test[2] (b, c)) );
out0 = vec3(x[0][0].f, x[0][1].v.y, x[2][1].v.x);
${OUTPUT}
}
""
end
case struct_4x1x4
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input vec4 in0 = [ vec4(0.5, 1.0, 2.0, 1.5) ];
output vec4 out0 = [ vec4(2.0, -0.5, -1.0, -1.5) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
struct Test
{
float f;
vec3 v;
};
Test a = Test(in0.z, vec3(in0.x, in0.y, in0.z));
Test b = Test(in0.y, vec3(-in0.z, -in0.x, -in0.y));
Test c = Test(in0.x, vec3(-in0.y, in0.z, -in0.x));
Test d = Test(-in0.w, vec3(-in0.w, -in0.x, -in0.z));
Test[4] x[4][1] = Test[4][1][4] ( (Test[1][4] (Test[4] (a, b, c, d))),
(Test[1][4] (Test[4] (a, b, c, d))),
(Test[1][4] (Test[4] (a, b, c, d))),
(Test[1][4] (Test[4] (a, b, c, d))) );
out0 = vec4(x[0][0][0].f, x[1][0][1].v.y, x[2][0][2].v.x, x[3][0][3].v.x);
${OUTPUT}
}
""
end
case vec3_4x3
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(7.4, -1.0, 2.0) | vec3(3.0, 1.6, -2.0) ];
output vec3 out0 = [ vec3(0.5, -2.0, 1.0) | vec3(7.4, -2.0, -1.0) | vec3(3.0, 2.0, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
vec3[3] x[4];
x = vec3[4][3] (vec3[3] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)),
vec3[3] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)),
vec3[3] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)),
vec3[3] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)) );
out0 = vec3(x[0][0].x, x[1][1].y, x[3][2].z);
${OUTPUT}
}
""
end
case ivec3_3x2x1
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input ivec3 in0 = [ ivec3(5, 1, 2) | ivec3(7, -1, 2) | ivec3(3, 1, -2) ];
output ivec3 out0 = [ ivec3(5, -2, 1) | ivec3(7, -2, -1) | ivec3(3, 2, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
ivec3 x[3][2][1];
x = ivec3[3][2][1] (ivec3[2][1] ( ivec3[1] (ivec3(in0.x, in0.y, in0.z)),
ivec3[1] (ivec3(-in0.y, -in0.z, -in0.x))),
ivec3[2][1] ( ivec3[1] (ivec3(in0.z, in0.x, in0.y)),
ivec3[1] (ivec3(in0.x, in0.y, in0.z))),
ivec3[2][1] ( ivec3[1] (ivec3(-in0.y, -in0.z, -in0.x)),
ivec3[1] (ivec3(in0.z, in0.x, in0.y))) );
out0 = ivec3(x[0][0][0].x, x[2][0][0].y, x[1][0][0].z);
${OUTPUT}
}
""
end
case bvec3_1x2x3
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input bvec3 in0 = [ bvec3(true, false, true) ];
output bvec3 out0 = [ bvec3(true, true, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
bvec3[3] x[1][2];
x = bvec3[1][2][3] ( bvec3[2][3] ( bvec3[3] ( bvec3(in0.x, in0.y, in0.z),
bvec3(in0.y, in0.z, in0.x),
bvec3(in0.z, in0.x, in0.y)),
bvec3[3] ( bvec3(in0.z, in0.x, in0.y),
bvec3(in0.x, in0.y, in0.z),
bvec3(in0.y, in0.z, in0.x)) ));
out0 = bvec3(x[0][0][0].x, x[0][0][1].y, x[0][1][0].z);
${OUTPUT}
}
""
end
case mat3_3x2
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-1.5, 0.0, -2.3) ];
output vec3 out0 = [ vec3(0.5, -1.0, 1.0) | vec3(-1.5, 0.0, 0.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
mat3[3][2] a = mat3[3][2] ( mat3[2] ( mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z),
mat3( in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y)),
mat3[2] ( mat3( -in0.z, -in0.z, in0.z,
-in0.y, -in0.y, in0.y,
-in0.x, -in0.x, in0.x),
mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z)),
mat3[2] ( mat3( in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y),
mat3( -in0.z, -in0.z, in0.z,
-in0.y, -in0.y, in0.y,
-in0.x, -in0.x, in0.x)) );
mat3 a0 = a[0][0];
mat3 a1 = a[0][1];
mat3 a2 = a[2][1];
float ret0 = a0[2][0];
float ret1 = a1[0][2];
float ret2 = a2[1][2];
out0 = vec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x3x3
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input ivec3 in0 = [ ivec3(0, 1, 2) | ivec3(-1, 0, -2) ];
output ivec3 out0 = [ ivec3(0, -1, 1) | ivec3(-1, 0, 0) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
mat3 a = mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z);
mat3 b = mat3( in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y);
mat3 c = mat3( -in0.z, -in0.z, in0.z,
-in0.y, -in0.y, in0.y,
-in0.x, -in0.x, in0.x);
mat3[3][3][3] x = mat3[3][3][3] ( mat3[3][3] (mat3[3] (a, a, a),
mat3[3] (b, b, b),
mat3[3] (c, c, c)),
mat3[3][3] (mat3[3] (b, b, b),
mat3[3] (a, a, a),
mat3[3] (c, c, c)),
mat3[3][3] (mat3[3] (c, c, c),
mat3[3] (a, a, a),
mat3[3] (b, b, b)) );
mat3 x0 = x[0][0][0];
mat3 x1 = x[1][0][0];
mat3 x2 = x[2][0][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = ivec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x4
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input bvec3 in0 = [ bvec3(true, false, true) ];
output bvec3 out0 = [ bvec3(true, false, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
mat3 a = mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z);
mat3 b = mat3( in0.z, in0.x, in0.y,
in0.z, in0.x, in0.y,
in0.z, in0.x, in0.y);
mat3 c = mat3( in0.z, in0.z, in0.z,
in0.y, in0.y, in0.y,
in0.x, in0.x, in0.x);
mat3[4] x[3] = mat3[3][4] ( mat3[4] (a, b, c, a),
mat3[4] (b, c, a, b),
mat3[4] (c, a, b, c) );
mat3 x0 = x[0][0];
mat3 x1 = x[1][3];
mat3 x2 = x[2][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = bvec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case high_dimensional_array
version 450
desc "Testing constructing explicitly sized arrays of arrays"
values
{
input ivec2 in0 = [ ivec2(1, -2) ];
output ivec2 out0 = [ ivec2(-2, 1) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
int[1][1][1][2][1][1][1] x = int[1][1][1][2][1][1][1] ( int[1][1][2][1][1][1] (int [1][2][1][1][1] ( int[2][1][1][1] ( int[1][1][1] ( int[1][1] (int[1] (in0.y))),
int[1][1][1] ( int[1][1] (int[1] (in0.x)))))));
out0 = ivec2(x[0][0][0][0][0][0][0], x[0][0][0][1][0][0][0]);
${OUTPUT}
}
""
end
end # explicit
group implicit "Testing constructors with implicit size"
case float_3x3
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(7.4, -1.0, 2.0) | vec3(3.0, 1.6, -2.0) ];
output vec3 out0 = [ vec3(2.0, 0.5, 1.0) | vec3(2.0, 7.4, -1.0) | vec3(-2.0, 3.0, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
float[3][3] x;
x = float[][] ( float[](in0.z, in0.x, in0.y),
float[](in0.z, in0.x, in0.y),
float[](in0.z, in0.x, in0.y) );
out0 = vec3(x[0][0], x[1][1], x[2][2]);
${OUTPUT}
}
""
end
case float_3x4
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input vec4 in0 = [ vec4(0.5, 1.0, 2.0, 0.2) | vec4(7.4, -1.0, 2.0, -1.3) | vec4(3.0, 1.6, -2.0, 0.5) ];
output vec4 out0 = [ vec4(2.0, 0.5, 0.2, 1.0) | vec4(2.0, 7.4, -1.3, -1.0) | vec4(-2.0, 3.0, 0.5, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
float[3][4] x;
x = float[][] ( float[] (in0.z, in0.x, in0.w, in0.y),
float[] (in0.z, in0.x, in0.w, in0.y),
float[] (in0.z, in0.x, in0.w, in0.y) );
out0 = vec4(x[0][0], x[1][1], x[2][2], x[2][3]);
${OUTPUT}
}
""
end
case int_3x1
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input ivec3 in0 = [ ivec3(0, 1, 2) | ivec3(7, -1, 2) | ivec3(3, 1, -2) ];
output ivec3 out0 = [ ivec3(2, 0, 1) | ivec3(2, 7, -1) | ivec3(-2, 3, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
int x[3][1];
x = int[][] ( int[] (in0.z),
int[] (in0.x),
int[] (in0.y) );
out0 = ivec3(x[0][0], x[1][0], x[2][0]);
${OUTPUT}
}
""
end
case int_4x4x4
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input ivec4 in0 = [ ivec4(0, 1, 2, 0) | ivec4(7, -1, 2, -1) | ivec4(3, 1, -2, 0) ];
output ivec4 out0 = [ ivec4(2, 0, 0, 1) | ivec4(2, 7, -1, -1) | ivec4(-2, 3, 0, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
int[4] x[4][4];
x = int[][][] ( int[][] ((int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y))),
int[][] ((int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y))),
int[][] ((int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y))),
int[][] ((int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y)),
(int[] (in0.z, in0.x, in0.w, in0.y))) );
out0 = ivec4(x[0][0][0], x[1][1][1], x[2][2][2], x[3][3][3]);
${OUTPUT}
}
""
end
case bool_3x3x3
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input bvec3 in0 = [ bvec3(true, true, false) ];
output bvec3 out0 = [ bvec3(false, true, true) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
bool[3][3][3] x;
x = bool[][][] (bool[][] ( (bool[] (in0.y, in0.y, in0.y)),
(bool[] (in0.z, in0.z, in0.z)),
(bool[] (in0.x, in0.x, in0.x))),
bool[][] ( (bool[] (in0.y, in0.y, in0.y)),
(bool[] (in0.z, in0.z, in0.z)),
(bool[] (in0.x, in0.x, in0.x))),
bool[][] ( (bool[] (in0.y, in0.y, in0.y)),
(bool[] (in0.z, in0.z, in0.z)),
(bool[] (in0.x, in0.x, in0.x))) );
out0 = bvec3(x[1][1][1], x[0][0][0], x[2][2][2]);
${OUTPUT}
}
""
end
case bool_2x1x4
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input bvec4 in0 = [ bvec4(true, true, false, false) ];
output bvec4 out0 = [ bvec4(false, true, true, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
bool x[2][1][4];
x = bool[2][1][4] ( bool[][] ((bool[] (in0.z, in0.x, in0.y, in0.w))),
bool[][] ((bool[] (in0.z, in0.x, in0.y, in0.w))) );
out0 = bvec4(x[0][0][0], x[0][0][1], x[1][0][2], x[1][0][3]);
${OUTPUT}
}
""
end
case struct_3x2
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) ];
output vec3 out0 = [ vec3(2.0, -0.5, -1.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
struct Test
{
float f;
vec3 v;
};
Test a = Test(in0.z, vec3(in0.x, in0.y, in0.z));
Test b = Test(in0.y, vec3(-in0.z, -in0.x, -in0.y));
Test c = Test(in0.x, vec3(-in0.y, in0.z, -in0.x));
Test[2] x[3] = Test[][] ( (Test[] (a, b)),
(Test[] (c, a)),
(Test[] (b, c)) );
out0 = vec3(x[0][0].f, x[0][1].v.y, x[2][1].v.x);
${OUTPUT}
}
""
end
case struct_4x1x4
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input vec4 in0 = [ vec4(0.5, 1.0, 2.0, 1.5) ];
output vec4 out0 = [ vec4(2.0, -0.5, -1.0, -1.5) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
struct Test
{
float f;
vec3 v;
};
Test a = Test(in0.z, vec3(in0.x, in0.y, in0.z));
Test b = Test(in0.y, vec3(-in0.z, -in0.x, -in0.y));
Test c = Test(in0.x, vec3(-in0.y, in0.z, -in0.x));
Test d = Test(-in0.w, vec3(-in0.w, -in0.x, -in0.z));
Test[4] x[4][1] = Test[][][] ( (Test[][] (Test[] (a, b, c, d))),
(Test[][] (Test[] (a, b, c, d))),
(Test[][] (Test[] (a, b, c, d))),
(Test[][] (Test[] (a, b, c, d))) );
out0 = vec4(x[0][0][0].f, x[1][0][1].v.y, x[2][0][2].v.x, x[3][0][3].v.x);
${OUTPUT}
}
""
end
case vec3_4x3
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(7.4, -1.0, 2.0) | vec3(3.0, 1.6, -2.0) ];
output vec3 out0 = [ vec3(0.5, -2.0, 1.0) | vec3(7.4, -2.0, -1.0) | vec3(3.0, 2.0, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
vec3[3] x[4];
x = vec3[][] ( vec3[] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)),
vec3[] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)),
vec3[] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)),
vec3[] ( vec3(in0.x, in0.y, in0.z),
vec3(-in0.y, -in0.z, -in0.x),
vec3(in0.z, in0.x, in0.y)) );
out0 = vec3(x[0][0].x, x[1][1].y, x[3][2].z);
${OUTPUT}
}
""
end
case ivec3_3x2x1
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input ivec3 in0 = [ ivec3(5, 1, 2) | ivec3(7, -1, 2) | ivec3(3, 1, -2) ];
output ivec3 out0 = [ ivec3(5, -2, 1) | ivec3(7, -2, -1) | ivec3(3, 2, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
ivec3 x[3][2][1];
x = ivec3[][][] ( ivec3[][] ( ivec3[] (ivec3(in0.x, in0.y, in0.z)),
ivec3[] (ivec3(-in0.y, -in0.z, -in0.x))),
ivec3[][] ( ivec3[] (ivec3(in0.z, in0.x, in0.y)),
ivec3[] (ivec3(in0.x, in0.y, in0.z))),
ivec3[][] ( ivec3[] (ivec3(-in0.y, -in0.z, -in0.x)),
ivec3[] (ivec3(in0.z, in0.x, in0.y))) );
out0 = ivec3(x[0][0][0].x, x[2][0][0].y, x[1][0][0].z);
${OUTPUT}
}
""
end
case bvec3_1x2x3
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input bvec3 in0 = [ bvec3(true, false, true) ];
output bvec3 out0 = [ bvec3(true, true, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
bvec3[3] x[1][2];
x = bvec3[][][] ( bvec3[][] ( bvec3[] (bvec3(in0.x, in0.y, in0.z),
bvec3(in0.y, in0.z, in0.x),
bvec3(in0.z, in0.x, in0.y)),
bvec3[] (bvec3(in0.z, in0.x, in0.y),
bvec3(in0.x, in0.y, in0.z),
bvec3(in0.y, in0.z, in0.x)) ));
out0 = bvec3(x[0][0][0].x, x[0][0][1].y, x[0][1][0].z);
${OUTPUT}
}
""
end
case mat3_3x2
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-1.5, 0.0, -2.3) ];
output vec3 out0 = [ vec3(0.5, -1.0, 1.0) | vec3(-1.5, 0.0, 0.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
mat3[3][2] a = mat3[][] ( mat3[] (mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z),
mat3( in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y)),
mat3[] (mat3( -in0.z, -in0.z, in0.z,
-in0.y, -in0.y, in0.y,
-in0.x, -in0.x, in0.x),
mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z)),
mat3[] (mat3( in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y),
mat3( -in0.z, -in0.z, in0.z,
-in0.y, -in0.y, in0.y,
-in0.x, -in0.x, in0.x)) );
mat3 a0 = a[0][0];
mat3 a1 = a[0][1];
mat3 a2 = a[2][1];
float ret0 = a0[2][0];
float ret1 = a1[0][2];
float ret2 = a2[1][2];
out0 = vec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x3x3
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input ivec3 in0 = [ ivec3(0, 1, 2) | ivec3(-1, 0, -2) ];
output ivec3 out0 = [ ivec3(0, -1, 1) | ivec3(-1, 0, 0) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
mat3 a = mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z);
mat3 b = mat3( in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y);
mat3 c = mat3( -in0.z, -in0.z, in0.z,
-in0.y, -in0.y, in0.y,
-in0.x, -in0.x, in0.x);
mat3[3][3][3] x = mat3[][][] ( mat3[][] ( mat3[] (a, a, a),
mat3[] (b, b, b),
mat3[] (c, c, c)),
mat3[][] ( mat3[] (b, b, b),
mat3[] (a, a, a),
mat3[] (c, c, c)),
mat3[][] ( mat3[] (c, c, c),
mat3[] (a, a, a),
mat3[] (b, b, b)) );
mat3 x0 = x[0][0][0];
mat3 x1 = x[1][0][0];
mat3 x2 = x[2][0][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = ivec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x4
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input bvec3 in0 = [ bvec3(true, false, true) ];
output bvec3 out0 = [ bvec3(true, false, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
mat3 a = mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z);
mat3 b = mat3( in0.z, in0.x, in0.y,
in0.z, in0.x, in0.y,
in0.z, in0.x, in0.y);
mat3 c = mat3( in0.z, in0.z, in0.z,
in0.y, in0.y, in0.y,
in0.x, in0.x, in0.x);
mat3[4] x[3] = mat3[][] ( mat3[] (a, b, c, a),
mat3[] (b, c, a, b),
mat3[] (c, a, b, c) );
mat3 x0 = x[0][0];
mat3 x1 = x[1][3];
mat3 x2 = x[2][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = bvec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case int_high_dimensional_array
version 450
desc "Testing constructing implicitly sized arrays of arrays"
values
{
input ivec2 in0 = [ ivec2(1, -2) ];
output ivec2 out0 = [ ivec2(-2, 1) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
void main()
{
${SETUP}
int[][][][][][][] x = int[][][][][][][] ( int[][][][][][] (int [][][][][] ( int[][][][] ( int[][][] ( int[][] (int[] (in0.y))),
int[][][] ( int[][] (int[] (in0.x)))))));
out0 = ivec2(x[0][0][0][0][0][0][0], x[0][0][0][1][0][0][0]);
${OUTPUT}
}
""
end
end # implicit
end # constructor
group return "Array of arrays as return value"
group explicit "Testing return value with explicit constructor"
case float_3x3
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(7.4, -1.0, 2.0) | vec3(3.0, 1.6, -2.0) ];
output vec3 out0 = [ vec3(2.0, -0.5, 1.0) | vec3(2.0, -7.4, -1.0) | vec3(-2.0, -3.0, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
float[3][3] func(vec3 a)
{
return float[3][3] (float[3] (a.z, 0.0, 0.0),
float[3] (0.0, -a.x, 0.0),
float[3] (0.0, 0.0, a.y) );
}
void main()
{
${SETUP}
float[3][3] x = func(in0);
out0 = vec3(x[0][0], x[1][1], x[2][2]);
${OUTPUT}
}
""
end
case int_2x2x2
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input ivec2 in0 = [ ivec2(4, 1) | ivec2(7, -1) | ivec2(3, 1) ];
output ivec2 out0 = [ ivec2(1, -4) | ivec2(-1, -7) | ivec2(1, -3) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
int[2][2][2] func(ivec2 a)
{
return int[2][2][2] ( int[2][2] ( int[2] (a.y, -a.x),
int[2] (0, 0)),
int[2][2] ( int[2] (0, 0),
int[2] (a.y, -a.x)) );
}
void main()
{
${SETUP}
int[2][2][2] x = func(in0);
out0 = ivec2(x[0][0][0], x[1][1][1]);
${OUTPUT}
}
""
end
case bool_3x2x3
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input bvec3 in0 = [ bvec3(false, true, true) ];
output bvec3 out0 = [ bvec3(true, false, true) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
bool[3][2][3] func(bvec3 a)
{
return bool[3][2][3] ( bool[2][3] (bool[3] (a.z, a.x, a.y),
bool[3] (a.x, a.y, a.z)),
bool[2][3] (bool[3] (a.x, a.y, a.z),
bool[3] (a.z, a.x, a.y)),
bool[2][3] (bool[3] (a.y, a.z, a.x),
bool[3] (a.y, a.z, a.x)) );
}
void main()
{
${SETUP}
bool[3] x[3][2] = func(in0);
out0 = bvec3(x[0][0][0], x[1][1][1], x[2][1][0]);
${OUTPUT}
}
""
end
case vec3_2x3
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-0.5, 11.2, -1.0) ];
output vec3 out0 = [ vec3(1.0, 0.5, -2.0) | vec3(11.2, -0.5, 1.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
vec3[2][3] func(vec3 p)
{
vec3[2][3] a = vec3[2][3]( vec3[3] (vec3(p.x, p.y, -p.z),
vec3(p.y, -p.z, p.x),
vec3(-p.z, p.x, p.y)),
vec3[3] (vec3(p.y, -p.z, p.x),
vec3(p.x, p.y, -p.z),
vec3(-p.z, p.x, p.y)) );
return vec3[2][3] ( vec3[3] (a[0][1], a[0][2], a[0][0]),
vec3[3] (a[1][1], a[1][2], a[1][0]));
}
void main()
{
${SETUP}
vec3[2][3] x = func(in0);
out0 = vec3(x[0][0].x, x[1][1].y, x[0][2].z);
${OUTPUT}
}
""
end
case struct_3x1x3
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) ];
output vec3 out0 = [ vec3(-1.0, 2.0, 0.5) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
struct Test
{
float f;
vec3 v;
};
Test[3][1][3] func(vec3 p)
{
Test a = Test(p.z, vec3(p.x, p.y, p.z));
Test b = Test(p.y, vec3(-p.z, -p.x, -p.y));
Test c = Test(p.x, vec3(-p.y, p.z, -p.x));
return Test[3][1][3] ( Test[1][3] (Test[3] (b, b, b)),
Test[1][3] (Test[3] (a, a, a)),
Test[1][3] (Test[3] (c, c, c)) );
}
void main()
{
${SETUP}
Test[3][1][3] x = func(in0);
out0 = vec3(x[0][0][0].v.z, x[2][0][2].v.y, x[1][0][1].v.x);
${OUTPUT}
}
""
end
case ivec3_3x3
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input ivec3 in0 = [ ivec3(5, 1, 2) | ivec3(-5, 11, -1) ];
output ivec3 out0 = [ ivec3(1, 5, -2) | ivec3(11, -5, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
ivec3[3][3] func(ivec3 p)
{
ivec3[3][3] a = ivec3[3][3] ( ivec3[3] ( ivec3(p.x, p.y, -p.z),
ivec3(p.x, p.y, -p.z),
ivec3(p.x, p.y, -p.z)),
ivec3[3] ( ivec3(p.y, -p.z, p.x),
ivec3(p.y, -p.z, p.x),
ivec3(p.y, -p.z, p.x)),
ivec3[3] ( ivec3(-p.z, p.x, p.y),
ivec3(-p.z, p.x, p.y),
ivec3(-p.z, p.x, p.y)) );
return a;
}
void main()
{
${SETUP}
ivec3[3][3] x = func(in0);
out0 = ivec3(x[1][0].x, x[2][0].y, x[0][2].z);
${OUTPUT}
}
""
end
case bvec4_4x2
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input bvec4 in0 = [ bvec4(true, false, false, true) ];
output bvec4 out0 = [ bvec4(true, true, false, true) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
bvec4[4][2] func(bvec4 p)
{
bvec4[4] x = bvec4[4]( bvec4(p.x, p.y, p.z, p.w),
bvec4(p.w, p.y, p.z, p.x),
bvec4(p.z, p.w, p.x, p.y),
bvec4(p.y, p.x, p.z, p.w) );
return bvec4[4][2] ( bvec4[2] (bvec4(x[0]),
bvec4(x[1])),
bvec4[2] (bvec4(x[2]),
bvec4(x[3])),
bvec4[2] (bvec4(x[1]),
bvec4(x[2])),
bvec4[2] (bvec4(x[3]),
bvec4(x[0])) );
}
void main()
{
${SETUP}
bvec4[4][2] x = func(in0);
out0 = bvec4(x[0][1].x, x[1][0].y, x[2][0].z, x[3][1].w);
${OUTPUT}
}
""
end
case mat3_3x2
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-1.5, 0.0, -2.3) ];
output vec3 out0 = [ vec3(0.5, -1.0, 1.0) | vec3(-1.5, 0.0, 0.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
mat3[3][2] func(vec3 p)
{
mat3[3][2] a = mat3[3][2] ( mat3[2] (mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z),
mat3( p.z, p.x, -p.y,
p.z, p.x, -p.y,
p.z, p.x, -p.y)),
mat3[2] (mat3( -p.z, -p.z, p.z,
-p.y, -p.y, p.y,
-p.x, -p.x, p.x),
mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z)),
mat3[2] (mat3( p.z, p.x, -p.y,
p.z, p.x, -p.y,
p.z, p.x, -p.y),
mat3( -p.z, -p.z, p.z,
-p.y, -p.y, p.y,
-p.x, -p.x, p.x)) );
return a;
}
void main()
{
${SETUP}
mat3 a[3][2] = func(in0);
mat3 a0 = a[0][0];
mat3 a1 = a[0][1];
mat3 a2 = a[2][1];
float ret0 = a0[2][0];
float ret1 = a1[0][2];
float ret2 = a2[1][2];
out0 = vec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x3x3
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input ivec3 in0 = [ ivec3(0, 1, 2) | ivec3(-1, 0, -2) ];
output ivec3 out0 = [ ivec3(0, -1, 1) | ivec3(-1, 0, 0) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
mat3[3][3][3] func(ivec3 p)
{
mat3 a = mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z);
mat3 b = mat3( p.z, p.x, -p.y,
p.z, p.x, -p.y,
p.z, p.x, -p.y);
mat3 c = mat3( -p.z, -p.z, p.z,
-p.y, -p.y, p.y,
-p.x, -p.x, p.x);
return mat3[3][3][3] ( mat3[3][3] (mat3[3] (a, a, a),
mat3[3] (b, b, b),
mat3[3] (c, c, c)),
mat3[3][3] (mat3[3] (b, b, b),
mat3[3] (a, a, a),
mat3[3] (c, c, c)),
mat3[3][3] (mat3[3] (c, c, c),
mat3[3] (a, a, a),
mat3[3] (b, b, b)) );
}
void main()
{
${SETUP}
mat3 x[3][3][3] = func(in0);
mat3 x0 = x[0][0][0];
mat3 x1 = x[1][0][0];
mat3 x2 = x[2][0][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = ivec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x4
version 450
desc "Testing arrays of arrays as function return values with explicit array size"
values
{
input bvec3 in0 = [ bvec3(true, false, true) ];
output bvec3 out0 = [ bvec3(true, false, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
mat3[3][4] func(bvec3 p)
{
mat3 a = mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z);
mat3 b = mat3( p.z, p.x, p.y,
p.z, p.x, p.y,
p.z, p.x, p.y);
mat3 c = mat3( p.z, p.z, p.z,
p.y, p.y, p.y,
p.x, p.x, p.x);
return mat3[3][4] ( mat3[4] (a, b, c, a),
mat3[4] (b, c, a, b),
mat3[4] (c, a, b, c) );
}
void main()
{
${SETUP}
mat3[4] x[3] = func(in0);
mat3 x0 = x[0][0];
mat3 x1 = x[1][3];
mat3 x2 = x[2][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = bvec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
end # explicit
group implicit "Test return value with implicit constructor"
case float_3x3
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(7.4, -1.0, 2.0) | vec3(3.0, 1.6, -2.0) ];
output vec3 out0 = [ vec3(2.0, -0.5, 1.0) | vec3(2.0, -7.4, -1.0) | vec3(-2.0, -3.0, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
float[3][3] func(vec3 a)
{
return float[][] ( float[] (a.z, 0.0, 0.0),
float[] (0.0, -a.x, 0.0),
float[] (0.0, 0.0, a.y) );
}
void main()
{
${SETUP}
float[3][3] x = func(in0);
out0 = vec3(x[0][0], x[1][1], x[2][2]);
${OUTPUT}
}
""
end
case int_2x2x2
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input ivec2 in0 = [ ivec2(4, 1) | ivec2(7, -1) | ivec2(3, 1) ];
output ivec2 out0 = [ ivec2(1, -4) | ivec2(-1, -7) | ivec2(1, -3) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
int[2][2][2] func(ivec2 a)
{
return int[][][] ( int[][] ( int[] (a.y, -a.x),
int[] (0, 0)),
int[][] ( int[] (0, 0),
int[] (a.y, -a.x)) );
}
void main()
{
${SETUP}
int[2][2][2] x = func(in0);
out0 = ivec2(x[0][0][0], x[1][1][1]);
${OUTPUT}
}
""
end
case bool_3x2x3
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input bvec3 in0 = [ bvec3(false, true, true) ];
output bvec3 out0 = [ bvec3(true, false, true) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
bool[3][2][3] func(bvec3 a)
{
return bool[][][] ( bool[][] ( bool[] (a.z, a.x, a.y),
bool[] (a.x, a.y, a.z)),
bool[][] ( bool[] (a.x, a.y, a.z),
bool[] (a.z, a.x, a.y)),
bool[][] ( bool[] (a.y, a.z, a.x),
bool[] (a.y, a.z, a.x)) );
}
void main()
{
${SETUP}
bool[3] x[3][2] = func(in0);
out0 = bvec3(x[0][0][0], x[1][1][1], x[2][1][0]);
${OUTPUT}
}
""
end
case vec3_2x3
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-0.5, 11.2, -1.0) ];
output vec3 out0 = [ vec3(1.0, 0.5, -2.0) | vec3(11.2, -0.5, 1.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
vec3[2][3] func(vec3 p)
{
vec3[2][3] a = vec3[2][3]( vec3[3] ( vec3(p.x, p.y, -p.z),
vec3(p.y, -p.z, p.x),
vec3(-p.z, p.x, p.y)),
vec3[3] ( vec3(p.y, -p.z, p.x),
vec3(p.x, p.y, -p.z),
vec3(-p.z, p.x, p.y)) );
return vec3[][] ( vec3[] (a[0][1], a[0][2], a[0][0]),
vec3[] (a[1][1], a[1][2], a[1][0]));
}
void main()
{
${SETUP}
vec3[2][3] x = func(in0);
out0 = vec3(x[0][0].x, x[1][1].y, x[0][2].z);
${OUTPUT}
}
""
end
case struct_3x1x3
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) ];
output vec3 out0 = [ vec3(-1.0, 2.0, 0.5) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
struct Test
{
float f;
vec3 v;
};
Test[3][1][3] func(vec3 p)
{
Test a = Test(p.z, vec3(p.x, p.y, p.z));
Test b = Test(p.y, vec3(-p.z, -p.x, -p.y));
Test c = Test(p.x, vec3(-p.y, p.z, -p.x));
return Test[][][] ( Test[][] (Test[] (b, b, b)),
Test[][] (Test[] (a, a, a)),
Test[][] (Test[] (c, c, c)) );
}
void main()
{
${SETUP}
Test[3][1][3] x = func(in0);
out0 = vec3(x[0][0][0].v.z, x[2][0][2].v.y, x[1][0][1].v.x);
${OUTPUT}
}
""
end
case ivec3_3x3
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input ivec3 in0 = [ ivec3(5, 1, 2) | ivec3(-5, 11, -1) ];
output ivec3 out0 = [ ivec3(1, 5, -2) | ivec3(11, -5, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
ivec3[3][3] func(ivec3 p)
{
return ivec3[][] ( ivec3[] ( ivec3(p.x, p.y, -p.z),
ivec3(p.x, p.y, -p.z),
ivec3(p.x, p.y, -p.z)),
ivec3[] ( ivec3(p.y, -p.z, p.x),
ivec3(p.y, -p.z, p.x),
ivec3(p.y, -p.z, p.x)),
ivec3[] ( ivec3(-p.z, p.x, p.y),
ivec3(-p.z, p.x, p.y),
ivec3(-p.z, p.x, p.y)) );
}
void main()
{
${SETUP}
ivec3[3][3] x = func(in0);
out0 = ivec3(x[1][0].x, x[2][0].y, x[0][2].z);
${OUTPUT}
}
""
end
case bvec4_4x2
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input bvec4 in0 = [ bvec4(true, false, false, true) ];
output bvec4 out0 = [ bvec4(true, true, false, true) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
bvec4[4][2] func(bvec4 p)
{
bvec4[4] x = bvec4[4]( bvec4(p.x, p.y, p.z, p.w),
bvec4(p.w, p.y, p.z, p.x),
bvec4(p.z, p.w, p.x, p.y),
bvec4(p.y, p.x, p.z, p.w) );
return bvec4[][] ( bvec4[] (bvec4(x[0]),
bvec4(x[1])),
bvec4[] (bvec4(x[2]),
bvec4(x[3])),
bvec4[] (bvec4(x[1]),
bvec4(x[2])),
bvec4[] (bvec4(x[3]),
bvec4(x[0])) );
}
void main()
{
${SETUP}
bvec4[4][2] x = func(in0);
out0 = bvec4(x[0][1].x, x[1][0].y, x[2][0].z, x[3][1].w);
${OUTPUT}
}
""
end
case mat3_3x2
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-1.5, 0.0, -2.3) ];
output vec3 out0 = [ vec3(0.5, -1.0, 1.0) | vec3(-1.5, 0.0, 0.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
mat3[3][2] func(vec3 p)
{
return mat3[][] ( mat3[] (mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z),
mat3( p.z, p.x, -p.y,
p.z, p.x, -p.y,
p.z, p.x, -p.y)),
mat3[] (mat3( -p.z, -p.z, p.z,
-p.y, -p.y, p.y,
-p.x, -p.x, p.x),
mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z)),
mat3[] (mat3( p.z, p.x, -p.y,
p.z, p.x, -p.y,
p.z, p.x, -p.y),
mat3( -p.z, -p.z, p.z,
-p.y, -p.y, p.y,
-p.x, -p.x, p.x)) );
}
void main()
{
${SETUP}
mat3 a[3][2] = func(in0);
mat3 a0 = a[0][0];
mat3 a1 = a[0][1];
mat3 a2 = a[2][1];
float ret0 = a0[2][0];
float ret1 = a1[0][2];
float ret2 = a2[1][2];
out0 = vec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x3x3
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input ivec3 in0 = [ ivec3(0, 1, 2) | ivec3(-1, 0, -2) ];
output ivec3 out0 = [ ivec3(0, -1, 1) | ivec3(-1, 0, 0) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
mat3[3][3][3] func(ivec3 p)
{
mat3 a = mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z);
mat3 b = mat3( p.z, p.x, -p.y,
p.z, p.x, -p.y,
p.z, p.x, -p.y);
mat3 c = mat3( -p.z, -p.z, p.z,
-p.y, -p.y, p.y,
-p.x, -p.x, p.x);
return mat3[][][] ( mat3[][] ( mat3[] (a, a, a),
mat3[] (b, b, b),
mat3[] (c, c, c)),
mat3[][] ( mat3[] (b, b, b),
mat3[] (a, a, a),
mat3[] (c, c, c)),
mat3[][] ( mat3[] (c, c, c),
mat3[] (a, a, a),
mat3[] (b, b, b)) );
}
void main()
{
${SETUP}
mat3 x[3][3][3] = func(in0);
mat3 x0 = x[0][0][0];
mat3 x1 = x[1][0][0];
mat3 x2 = x[2][0][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = ivec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
case mat3_3x4
version 450
desc "Testing arrays of arrays as function return values with implicit array size"
values
{
input bvec3 in0 = [ bvec3(true, false, true) ];
output bvec3 out0 = [ bvec3(true, false, false) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
mat3[3][4] func(bvec3 p)
{
mat3 a = mat3( p.x, p.y, p.z,
p.x, p.y, p.z,
p.x, p.y, p.z);
mat3 b = mat3( p.z, p.x, p.y,
p.z, p.x, p.y,
p.z, p.x, p.y);
mat3 c = mat3( p.z, p.z, p.z,
p.y, p.y, p.y,
p.x, p.x, p.x);
return mat3[][] ( mat3[] (a, b, c, a),
mat3[] (b, c, a, b),
mat3[] (c, a, b, c) );
}
void main()
{
${SETUP}
mat3[4] x[3] = func(in0);
mat3 x0 = x[0][0];
mat3 x1 = x[1][3];
mat3 x2 = x[2][0];
float ret0 = x0[2][0];
float ret1 = x1[0][2];
float ret2 = x2[1][2];
out0 = bvec3(ret0, ret1, ret2);
${OUTPUT}
}
""
end
end # implicit
end # return
group parameter "Array of arrays as a function parameter"
# in
group in "Array of arrays as an in-function parameter"
case float_3x3
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(7.4, -1.0, 2.0) | vec3(3.0, 1.6, -2.0) ];
output vec3 out0 = [ vec3(2.0, -0.5, 1.0) | vec3(2.0, -7.4, -1.0) | vec3(-2.0, -3.0, 1.6) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
vec3 func(in float[3][3] x)
{
return vec3(x[0][0], x[1][1], x[2][2]);
}
void main()
{
${SETUP}
float[3][3] x = float[3][3] ( float[3] (in0.z, 0.0, 0.0),
float[3] (0.0, -in0.x, 0.0),
float[3] (0.0, 0.0, in0.y) );
out0 = func(x);
${OUTPUT}
}
""
end
case int_2x2x2
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input ivec2 in0 = [ ivec2(4, 1) | ivec2(7, -1) | ivec2(3, 1) ];
output ivec2 out0 = [ ivec2(1, -4) | ivec2(-1, -7) | ivec2(1, -3) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
ivec2 func(in int[2][2][2] x)
{
return ivec2(x[0][0][0], x[1][1][1]);
}
void main()
{
${SETUP}
int[2][2][2] x = int[2][2][2] ( int[2][2] ( int[2] (in0.y, -in0.x),
int[2] (0, 0)),
int[2][2] ( int[2] (0, 0),
int[2] (in0.y, -in0.x)) );
out0 = func(x);
${OUTPUT}
}
""
end
case bool_3x2x3
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input bvec3 in0 = [ bvec3(false, true, true) ];
output bvec3 out0 = [ bvec3(true, false, true) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
bvec3 func(in bool x[3][2][3])
{
return bvec3(x[0][0][0], x[1][1][1], x[2][1][0]);
}
void main()
{
${SETUP}
bool[3] x[3][2] = bool[3][2][3] ( bool[2][3] (bool[3] (in0.z, in0.x, in0.y),
bool[3] (in0.x, in0.y, in0.z)),
bool[2][3] (bool[3] (in0.x, in0.y, in0.z),
bool[3] (in0.z, in0.x, in0.y)),
bool[2][3] (bool[3] (in0.y, in0.z, in0.x),
bool[3] (in0.y, in0.z, in0.x)) );
out0 = func(x);
${OUTPUT}
}
""
end
case vec3_2x3
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-0.5, 11.2, -1.0) ];
output vec3 out0 = [ vec3(1.0, 0.5, -2.0) | vec3(11.2, -0.5, 1.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
vec3 func(in vec3[3] x[2])
{
return vec3(x[0][0].x, x[1][1].y, x[0][2].z);
}
void main()
{
${SETUP}
vec3[2][3] x = vec3[2][3]( vec3[3] ( vec3(in0.x, in0.y, -in0.z),
vec3(in0.y, -in0.z, in0.x),
vec3(-in0.z, in0.x, in0.y)),
vec3[3] ( vec3(in0.y, -in0.z, in0.x),
vec3(in0.x, in0.y, -in0.z),
vec3(-in0.z, in0.x, in0.y)) );
x = vec3[2][3] (vec3[3] (x[0][1], x[0][2], x[0][0]),
vec3[3] (x[1][1], x[1][2], x[1][0]) );
out0 = func(x);
${OUTPUT}
}
""
end
case struct_3x1x3
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) ];
output vec3 out0 = [ vec3(-1.0, 2.0, 0.5) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
struct Test
{
float f;
vec3 v;
};
vec3 func(in Test[3] x[3][1])
{
return vec3(x[0][0][0].v.z, x[2][0][2].v.y, x[1][0][1].v.x);
}
void main()
{
${SETUP}
Test a = Test(in0.z, vec3(in0.x, in0.y, in0.z));
Test b = Test(in0.y, vec3(-in0.z, -in0.x, -in0.y));
Test c = Test(in0.x, vec3(-in0.y, in0.z, -in0.x));
Test x[3][1][3] = Test[3][1][3] ( Test[1][3] (Test[3] (b, b, b)),
Test[1][3] (Test[3] (a, a, a)),
Test[1][3] (Test[3] (c, c, c)) );
out0 = func(x);
${OUTPUT}
}
""
end
case ivec3_3x3
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input ivec3 in0 = [ ivec3(5, 1, 2) | ivec3(-5, 11, -1) ];
output ivec3 out0 = [ ivec3(1, 5, -2) | ivec3(11, -5, 1) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
ivec3 func(in ivec3 x[3][3])
{
return ivec3(x[1][0].x, x[2][0].y, x[0][2].z);
}
void main()
{
${SETUP}
ivec3[3][3] x = ivec3[3][3] ( ivec3[3] ( ivec3(in0.x, in0.y, -in0.z),
ivec3(in0.x, in0.y, -in0.z),
ivec3(in0.x, in0.y, -in0.z)),
ivec3[3] ( ivec3(in0.y, -in0.z, in0.x),
ivec3(in0.y, -in0.z, in0.x),
ivec3(in0.y, -in0.z, in0.x)),
ivec3[3] ( ivec3(-in0.z, in0.x, in0.y),
ivec3(-in0.z, in0.x, in0.y),
ivec3(-in0.z, in0.x, in0.y)) );
out0 = func(x);
${OUTPUT}
}
""
end
case bvec4_4x2
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input bvec4 in0 = [ bvec4(true, false, false, true) ];
output bvec4 out0 = [ bvec4(true, true, false, true) ];
}
both ""
#version 450
precision mediump int;
precision mediump float;
${DECLARATIONS}
bvec4 func(in bvec4[4][2] x)
{
return bvec4(x[0][1].x, x[1][0].y, x[2][0].z, x[3][1].w);
}
void main()
{
${SETUP}
bvec4[4] a = bvec4[4]( bvec4(in0.x, in0.y, in0.z, in0.w),
bvec4(in0.w, in0.y, in0.z, in0.x),
bvec4(in0.z, in0.w, in0.x, in0.y),
bvec4(in0.y, in0.x, in0.z, in0.w) );
bvec4 x[4][2] = bvec4[4][2] ( bvec4[2] (bvec4(a[0]),
bvec4(a[1])),
bvec4[2] (bvec4(a[2]),
bvec4(a[3])),
bvec4[2] (bvec4(a[1]),
bvec4(a[2])),
bvec4[2] (bvec4(a[3]),
bvec4(a[0])) );
out0 = func(x);
${OUTPUT}
}
""
end
case mat3_3x2
version 450
desc "Testing array of arrays as an in-function parameter"
values
{
input vec3 in0 = [ vec3(0.5, 1.0, 2.0) | vec3(-1.5, 0.0, -2.3) ];
output vec3 out0 = [ vec3(0.5, -1.0, 1.0) | vec3(-1.5, 0.0, 0.0) ];
}
both ""
#version 450
precision mediump float;
${DECLARATIONS}
vec3 func(in mat3[2] x[3])
{
mat3 a0 = x[0][0];
mat3 a1 = x[0][1];
mat3 a2 = x[2][1];
float ret0 = a0[2][0];
float ret1 = a1[0][2];
float ret2 = a2[1][2];
return vec3(ret0, ret1, ret2);
}
void main()
{
${SETUP}
mat3 a = mat3( in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z,
in0.x, in0.y, in0.z);
mat3 b = mat3( in0.z, in0.x, -in0.y,
in0.z, in0.x, -in0.y,
in0.