| uniform half4 colorGreen, colorRed; |
| uniform float2x2 testMatrix2x2; |
| |
| half4 main(float2) { |
| bool ok = true; |
| |
| // Prefix ++ and -- (scalar int). |
| int i = 5; |
| ++i; |
| ok = ok && (i == 6); |
| ok = ok && (++i == 7); |
| ok = ok && (--i == 6); |
| --i; |
| ok = ok && (i == 5); |
| |
| // Prefix ++ and -- (scalar float). |
| float f = 0.5; |
| ++f; |
| ok = ok && (f == 1.5); |
| ok = ok && (++f == 2.5); |
| ok = ok && (--f == 1.5); |
| --f; |
| ok = ok && (f == 0.5); |
| |
| // Prefix ++ and -- (vector-component float). |
| float2 f2 = float2(0.5); |
| ++f2.x; |
| ok = ok && (f2.x == 1.5); |
| ok = ok && (++f2.x == 2.5); |
| ok = ok && (--f2.x == 1.5); |
| --f2.x; |
| ok = ok && (f2.x == 0.5); |
| |
| // Prefix ++ and -- (vector float). |
| ++f2; |
| ok = ok && (f2 == float2(1.5)); |
| ok = ok && (++f2 == float2(2.5)); |
| ok = ok && (--f2 == float2(1.5)); |
| --f2; |
| ok = ok && (f2 == float2(0.5)); |
| |
| // Prefix ++ and -- (vector int). |
| int4 i4 = int4(7, 8, 9, 10); |
| ++i4; |
| ok = ok && (i4 == int4(8, 9, 10, 11)); |
| ok = ok && (++i4 == int4(9, 10, 11, 12)); |
| ok = ok && (--i4 == int4(8, 9, 10, 11)); |
| --i4; |
| ok = ok && (i4 == int4(7, 8, 9, 10)); |
| |
| // Prefix ++ and -- (matrix). |
| float3x3 m3x3 = float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); |
| ++m3x3; |
| ok = ok && (m3x3 == float3x3(2, 3, 4, 5, 6, 7, 8, 9, 10)); |
| ok = ok && (++m3x3 == float3x3(3, 4, 5, 6, 7, 8, 9, 10, 11)); |
| ok = ok && (--m3x3 == float3x3(2, 3, 4, 5, 6, 7, 8, 9, 10)); |
| --m3x3; |
| ok = ok && (m3x3 == float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9)); |
| |
| // Prefix '!' |
| ok = ok && !(colorGreen.r == 1.0); |
| |
| // Prefix '-' (scalar, vector, matrix float) |
| ok = ok && (-1 == -colorGreen.g); |
| ok = ok && (half4(0, -1, 0, -1) == -colorGreen); |
| ok = ok && (float2x2(-1, -2, -3, -4) == -testMatrix2x2); |
| |
| // Prefix '-' (scalar, vector int) |
| int2 iv = int2(i, -i); // (5, -5) |
| ok = ok && (-i == -5); |
| ok = ok && (-iv == int2(-5, 5)); |
| |
| return ok ? colorGreen : colorRed; |
| } |