diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/metal/byte-address-buffer.slang | 8 | ||||
| -rw-r--r-- | tests/wgsl/bitshifts.slang | 92 | ||||
| -rw-r--r-- | tests/wgsl/bitshifts.slang.expected.txt | 47 |
3 files changed, 143 insertions, 4 deletions
diff --git a/tests/metal/byte-address-buffer.slang b/tests/metal/byte-address-buffer.slang index 24802815e..d4b58061f 100644 --- a/tests/metal/byte-address-buffer.slang +++ b/tests/metal/byte-address-buffer.slang @@ -20,11 +20,11 @@ struct TestStruct void main_kernel(uint3 tid: SV_DispatchThreadID) { // CHECK: uint [[WORD0:[a-zA-Z0-9_]+]] = as_type<uint>({{.*}}[(int(0))>>2]); - // CHECK: uint8_t [[A:[a-zA-Z0-9_]+]] = uint8_t([[WORD0]] >> int(0) & 255U); + // CHECK: uint8_t [[A:[a-zA-Z0-9_]+]] = uint8_t([[WORD0]] >> 0U & 255U); // CHECK: uint [[WORD1:[a-zA-Z0-9_]+]] = as_type<uint>({{.*}}[(int(0))>>2]); - // CHECK: half [[H:[a-zA-Z0-9_]+]] = as_type<half>(ushort([[WORD1]] >> int(16) & 65535U)); + // CHECK: half [[H:[a-zA-Z0-9_]+]] = as_type<half>(ushort([[WORD1]] >> 16U & 65535U)); - // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 4294967040U) | uint([[A]]) << int(0)); - // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 65535U) | uint(as_type<ushort>([[H]])) << int(16)); + // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 4294967040U) | uint([[A]]) << 0U); + // CHECK: {{.*}}[(int(128))>>2] = as_type<uint32_t>(({{.*}} & 65535U) | uint(as_type<ushort>([[H]])) << 16U); buffer.Store(128, buffer.Load<TestStruct>(0)); } diff --git a/tests/wgsl/bitshifts.slang b/tests/wgsl/bitshifts.slang new file mode 100644 index 000000000..50d2fc43d --- /dev/null +++ b/tests/wgsl/bitshifts.slang @@ -0,0 +1,92 @@ +//TEST(compute):COMPARE_COMPUTE:-shaderobj + +//TEST_INPUT:ubuffer(data=[3 7 8 10], stride=4):name=inputBuffer +RWStructuredBuffer<int> inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(1,1,1)] +void computeMain() +{ + int amount = 1; + + outputBuffer[0] = inputBuffer[0] >> amount; + + int2 v2 = int2(inputBuffer[0], inputBuffer[1]) >> amount; + outputBuffer[1] = v2[0]; + outputBuffer[2] = v2[1]; + + int3 v3 = int3(inputBuffer[0], inputBuffer[1], inputBuffer[2]) >> amount; + outputBuffer[3] = v3[0]; + outputBuffer[4] = v3[1]; + outputBuffer[5] = v3[2]; + + int4 v4 = int4(inputBuffer[0], inputBuffer[1], inputBuffer[2], inputBuffer[3]) >> amount; + outputBuffer[6] = v4[0]; + outputBuffer[7] = v4[1]; + outputBuffer[8] = v4[2]; + outputBuffer[9] = v4[3]; + + outputBuffer[10] = inputBuffer[0] << amount; + + v2 = int2(inputBuffer[0], inputBuffer[1]) << amount; + outputBuffer[11] = v2[0]; + outputBuffer[12] = v2[1]; + + v3 = int3(inputBuffer[0], inputBuffer[1], inputBuffer[2]) << amount; + outputBuffer[13] = v3[0]; + outputBuffer[14] = v3[1]; + outputBuffer[15] = v3[2]; + + v4 = int4(inputBuffer[0], inputBuffer[1], inputBuffer[2], inputBuffer[3]) << amount; + outputBuffer[16] = v4[0]; + outputBuffer[17] = v4[1]; + outputBuffer[18] = v4[2]; + outputBuffer[19] = v4[3]; + + v2 = inputBuffer[0] >> int2(amount); + outputBuffer[20] = v2[0]; + outputBuffer[21] = v2[1]; + + v3 = inputBuffer[1] >> int3(amount); + outputBuffer[22] = v3[0]; + outputBuffer[23] = v3[1]; + outputBuffer[24] = v3[2]; + + v4 = inputBuffer[2] >> int4(amount); + outputBuffer[25] = v4[0]; + outputBuffer[26] = v4[1]; + outputBuffer[27] = v4[2]; + outputBuffer[28] = v4[3]; + + v2 = inputBuffer[0] << int2(amount); + outputBuffer[29] = v2[0]; + outputBuffer[30] = v2[1]; + + v3 = inputBuffer[1] << int3(amount); + outputBuffer[31] = v3[0]; + outputBuffer[32] = v3[1]; + outputBuffer[33] = v3[2]; + + v4 = inputBuffer[2] << int4(amount); + outputBuffer[34] = v4[0]; + outputBuffer[35] = v4[1]; + outputBuffer[36] = v4[2]; + outputBuffer[37] = v4[3]; + + v2 = int2(inputBuffer[0], inputBuffer[1]) >> int2(1, 2); + outputBuffer[38] = v2[0]; + outputBuffer[39] = v2[1]; + + v3 = int3(inputBuffer[0], inputBuffer[1], inputBuffer[2]) >> int3(1, 2, 3); + outputBuffer[40] = v3[0]; + outputBuffer[41] = v3[1]; + outputBuffer[42] = v3[2]; + + v4 = int4(inputBuffer[0], inputBuffer[1], inputBuffer[2], inputBuffer[4]) >> int4(1, 2, 3, 4); + outputBuffer[43] = v4[0]; + outputBuffer[44] = v4[1]; + outputBuffer[45] = v4[2]; + outputBuffer[46] = v4[3]; +} diff --git a/tests/wgsl/bitshifts.slang.expected.txt b/tests/wgsl/bitshifts.slang.expected.txt new file mode 100644 index 000000000..ff1ae84e4 --- /dev/null +++ b/tests/wgsl/bitshifts.slang.expected.txt @@ -0,0 +1,47 @@ +1 +1 +3 +1 +3 +4 +1 +3 +4 +5 +6 +6 +E +6 +E +10 +6 +E +10 +14 +1 +1 +3 +3 +3 +4 +4 +4 +4 +6 +6 +E +E +E +10 +10 +10 +10 +1 +1 +1 +1 +1 +1 +1 +1 +0 |
