blob: 03298a18bdb1d0a1503071da9c73a07efd291b33 [file] [log] [blame]
uniform half4 colorGreen, colorRed;
uniform float2x2 testMatrix2x2;
bool test_float() {
bool ok = true;
float2x3 m23 = float2x3(2);
ok = ok && (m23 == float2x3(2, 0, 0,
0, 2, 0));
float2x4 m24 = float2x4(3);
ok = ok && (m24 == float2x4(3, 0, 0, 0,
0, 3, 0, 0));
float3x2 m32 = float3x2(4);
ok = ok && (m32 == float3x2(4, 0,
0, 4,
0, 0));
float3x4 m34 = float3x4(5);
ok = ok && (m34 == float3x4(5, 0, 0, 0,
0, 5, 0, 0,
0, 0, 5, 0));
float4x2 m42 = float4x2(6);
ok = ok && (m42 == float4x2(6, 0,
0, 6,
0, 0,
0, 0));
float4x3 m43 = float4x3(7);
ok = ok && (m43 == float4x3(7, 0, 0,
0, 7, 0,
0, 0, 7,
0, 0, 0));
float2x2 m22 = m32 * m23;
ok = ok && (m22 == float2x2(2 * 4));
float3x3 m33 = m43 * m34;
ok = ok && (m33 == float3x3(7 * 5));
float4x4 m44 = m24 * m42;
m23 += 1;
ok = ok && (m23 == float2x3(3, 1, 1,
1, 3, 1));
m32 -= 2;
ok = ok && (m32 == float3x2(2, -2,
-2, 2,
-2, -2));
m24 /= 4;
ok = ok && (m24 == float2x4(0.75, 0, 0, 0,
0, 0.75, 0, 0));
float4 f4 = float4(testMatrix2x2);
ok = ok && float2x3(f4.xyz, f4.w, f4.xy) ==
float2x3(1, 2, 3, 4, 1, 2);
ok = ok && float2x4(f4.xyz, f4.w, f4.x, f4.yzw) ==
float2x4(1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float3x2(f4.xy, f4.zw, f4.x, f4.y) ==
float3x2(1, 2, 3, 4, 1, 2);
ok = ok && float3x4(f4.xy, f4.zw, f4.xyzw, f4.x, f4.yz, f4.w) ==
float3x4(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float4x2(f4.xy, f4.z, f4.w, f4.xy, f4.z, f4.w) ==
float4x2(1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float4x3(f4.x, f4.yz, f4.wx, f4.y, f4.zwx, f4.yzw) ==
float4x3(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4);
return ok;
}
bool test_half() {
bool ok = true;
half2x3 m23 = half2x3(2);
ok = ok && (m23 == half2x3(2, 0, 0,
0, 2, 0));
half2x4 m24 = half2x4(3);
ok = ok && (m24 == half2x4(3, 0, 0, 0,
0, 3, 0, 0));
half3x2 m32 = half3x2(4);
ok = ok && (m32 == half3x2(4, 0,
0, 4,
0, 0));
half3x4 m34 = half3x4(5);
ok = ok && (m34 == half3x4(5, 0, 0, 0,
0, 5, 0, 0,
0, 0, 5, 0));
half4x2 m42 = half4x2(6);
ok = ok && (m42 == half4x2(6, 0,
0, 6,
0, 0,
0, 0));
half4x3 m43 = half4x3(7);
ok = ok && (m43 == half4x3(7, 0, 0,
0, 7, 0,
0, 0, 7,
0, 0, 0));
half2x2 m22 = m32 * m23;
ok = ok && (m22 == half2x2(2 * 4));
half3x3 m33 = m43 * m34;
ok = ok && (m33 == half3x3(7 * 5));
half4x4 m44 = m24 * m42;
m23 += 1;
ok = ok && (m23 == half2x3(3, 1, 1,
1, 3, 1));
m32 -= 2;
ok = ok && (m32 == half3x2(2, -2,
-2, 2,
-2, -2));
m24 /= 4;
ok = ok && (m24 == half2x4(0.75, 0, 0, 0,
0, 0.75, 0, 0));
half4 h4 = half4(testMatrix2x2);
ok = ok && float2x3(h4.xyz, h4.w, h4.xy) ==
float2x3(1, 2, 3, 4, 1, 2);
ok = ok && float2x4(h4.xyz, h4.w, h4.x, h4.yzw) ==
float2x4(1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float3x2(h4.xy, h4.zw, h4.x, h4.y) ==
float3x2(1, 2, 3, 4, 1, 2);
ok = ok && float3x4(h4.xy, h4.zw, h4.xyzw, h4.x, h4.yz, h4.w) ==
float3x4(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float4x2(h4.xy, h4.z, h4.w, h4.xy, h4.z, h4.w) ==
float4x2(1, 2, 3, 4, 1, 2, 3, 4);
ok = ok && float4x3(h4.x, h4.yz, h4.wx, h4.y, h4.zwx, h4.yzw) ==
float4x3(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4);
return ok;
}
half4 main(float2 coords) {
return test_float() && test_half() ? colorGreen : colorRed;
}