yum-mirror/slang

Making it easier to work with shaders

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

Jay KwakSupport Vulkan memory model (#7057)d58243d90

master
1.6 KiB54 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -emit-spirv-directly
2
3// CHECK: 0
4// CHECK-NEXT: 0
5// CHECK-NEXT: 1
6// CHECK-NEXT: 2
7
8// CHECK: 0
9// CHECK-NEXT: 0
10// CHECK: 1
11// CHECK-NEXT: 2
12
13// CHECK: 0
14// CHECK-NEXT: 0
15// CHECK: 1
16// CHECK-NEXT: 2
17
18//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer
19RWStructuredBuffer<int> outputBuffer;
20
21//TEST_INPUT:ubuffer(data=[4 3 5 7], stride=4, count=256),name=input1
22ByteAddressBuffer input1;
23
24//TEST_INPUT:ubuffer(data=[2 3 4 5], stride=4, count=256),name=input2
25ByteAddressBuffer input2;
26
27using namespace linalg;
28
29typealias CoopMatIntType = CoopMat<int32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
30typealias CoopMatUintType = CoopMat<uint32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
31typealias CoopMatFloatType = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
32
33[numthreads(32, 1, 1)]
34void computeMain()
35{
36    let stride = 16;
37
38    let mat1 = CoopMatIntType.Load<CoopMatMatrixLayout::RowMajor>(input1, 0, stride);
39    let mat2 = CoopMatIntType.Load<CoopMatMatrixLayout::RowMajor>(input2, 0, stride);
40
41    let mat3 = CoopMatFloatType(mat1);
42    let mat4 = CoopMatFloatType(mat2);
43
44    let mat5 = CoopMatUintType(mat1);
45    let mat6 = CoopMatUintType(mat2);
46
47    let result = mat1 % mat2;
48    let result2 = CoopMatIntType(mat3 % mat4);
49    let result3 = CoopMatIntType(mat5 % mat6);
50
51    result.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, stride);
52    result2.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 16, stride);
53    result3.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 32, stride);
54}