1uniform half4 colorGreen, colorRed; 2uniform float2x2 testMatrix2x2; 3 4half4 main(float2) { 5 bool ok = true; 6 7 // Prefix ++ and -- (scalar int). 8 int i = 5; 9 ++i; 10 ok = ok && (i == 6); 11 ok = ok && (++i == 7); 12 ok = ok && (--i == 6); 13 --i; 14 ok = ok && (i == 5); 15 16 // Prefix ++ and -- (scalar float). 17 float f = 0.5; 18 ++f; 19 ok = ok && (f == 1.5); 20 ok = ok && (++f == 2.5); 21 ok = ok && (--f == 1.5); 22 --f; 23 ok = ok && (f == 0.5); 24 25 // Prefix ++ and -- (vector-component float). 26 float2 f2 = float2(0.5); 27 ++f2.x; 28 ok = ok && (f2.x == 1.5); 29 ok = ok && (++f2.x == 2.5); 30 ok = ok && (--f2.x == 1.5); 31 --f2.x; 32 ok = ok && (f2.x == 0.5); 33 34 // Prefix ++ and -- (vector float). 35 ++f2; 36 ok = ok && (f2 == float2(1.5)); 37 ok = ok && (++f2 == float2(2.5)); 38 ok = ok && (--f2 == float2(1.5)); 39 --f2; 40 ok = ok && (f2 == float2(0.5)); 41 42 // Prefix ++ and -- (vector int). 43 int4 i4 = int4(7, 8, 9, 10); 44 ++i4; 45 ok = ok && (i4 == int4(8, 9, 10, 11)); 46 ok = ok && (++i4 == int4(9, 10, 11, 12)); 47 ok = ok && (--i4 == int4(8, 9, 10, 11)); 48 --i4; 49 ok = ok && (i4 == int4(7, 8, 9, 10)); 50 51 // Prefix ++ and -- (matrix). 52 float3x3 m3x3 = float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9); 53 ++m3x3; 54 ok = ok && (m3x3 == float3x3(2, 3, 4, 5, 6, 7, 8, 9, 10)); 55 ok = ok && (++m3x3 == float3x3(3, 4, 5, 6, 7, 8, 9, 10, 11)); 56 ok = ok && (--m3x3 == float3x3(2, 3, 4, 5, 6, 7, 8, 9, 10)); 57 --m3x3; 58 ok = ok && (m3x3 == float3x3(1, 2, 3, 4, 5, 6, 7, 8, 9)); 59 60 // Prefix '!' 61 ok = ok && !(colorGreen.r == 1.0); 62 63 // Prefix '-' (scalar, vector, matrix float) 64 ok = ok && (-1 == -colorGreen.g); 65 ok = ok && (half4(0, -1, 0, -1) == -colorGreen); 66 ok = ok && (float2x2(-1, -2, -3, -4) == -testMatrix2x2); 67 68 // Prefix '-' (scalar, vector int) 69 int2 iv = int2(i, -i); // (5, -5) 70 ok = ok && (-i == -5); 71 ok = ok && (-iv == int2(-5, 5)); 72 73 return ok ? colorGreen : colorRed; 74} 75