yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

CopilotFix Metal 8-bit vector type names: emit char/uchar instead of int8_t/uint8_t (#8223)4e9ee1dc8

master
2.1 KiB46 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -cpu
2//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -vk -compute
3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -cuda -compute
4//TODO: metal was previously failing but should work now after fixing vector type names
5//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -mtl -compute -profile metallib_2_4
6// Not testing the following:
7// -dx12/hlsl, No support for uint8_t with hlsl
8// -wgpu, only has 32-bit support
9//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -vk -compute -emit-spirv-via-glsl
10
11//CHK:1
12
13//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
14RWStructuredBuffer<uint> outputBuffer;
15
16[numthreads(1, 1, 1)]
17void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
18{
19    uint r1 = countbits(uint8_t(0b1U) << 4);
20    uint2 r2 = countbits(uint8_t2(uint8_t(0b0U) << 4, uint8_t(0b1U) << 4));
21    uint3 r3 = countbits(uint8_t3(uint8_t(0b0U) << 4, uint8_t(0b1U) << 4, uint8_t(0b11U) << 4));
22    uint4 r4 = countbits(uint8_t4(uint8_t(0b0U) << 4, uint8_t(0b1U) << 4, uint8_t(0b11U) << 4, uint8_t(0b111U) << 4));
23
24    uint r5 = countbits(int8_t(0b1) << 4);
25    uint2 r6 = countbits(int8_t2(int8_t(0b0) << 4, int8_t(0b1) << 4));
26    uint3 r7 = countbits(int8_t3(int8_t(0b0) << 4, int8_t(0b1) << 4, int8_t(0b11) << 4));
27    uint4 r8 = countbits(int8_t4(int8_t(0b0) << 4, int8_t(0b1) << 4, int8_t(0b11) << 4, int8_t(0b111) << 4));
28
29    uint8_t smallShiftU8 = uint8_t(0b111) << 8;
30    int8_t smallShiftI8 = int8_t(0b1111) << 8;
31
32    uint bitCountBigShiftU8 = countbits(smallShiftU8);
33    uint bitCountBigShiftI8 = countbits(smallShiftI8);
34
35    outputBuffer[0] = true
36        && (r1 == 1)
37        && (r2.x == 0 && r2.y == 1)
38        && (r3.x == 0 && r3.y == 1 && r3.z == 2)
39        && (r4.x == 0 && r4.y == 1 && r4.z == 2 && r4.w == 3)
40        && (r5 == 1)
41        && (r6.x == 0 && r6.y == 1)
42        && (r7.x == 0 && r7.y == 1 && r7.z == 2)
43        && (r8.x == 0 && r8.y == 1 && r8.z == 2 && r8.w == 3)
44        && (bitCountBigShiftU8 == 0 && bitCountBigShiftI8 == 0)
45        ;
46}