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.2 KiB42 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -emit-spirv-directly
2
3// CHECK: 1
4// CHECK-NEXT: 2
5// CHECK-NEXT: 3
6// CHECK-NEXT: 4
7// CHECK-NEXT: 5
8// CHECK-NEXT: 6
9// CHECK-NEXT: 7
10// CHECK-NEXT: 8
11// CHECK-NEXT: 9
12// CHECK-NEXT: A
13// CHECK-NEXT: B
14// CHECK-NEXT: C
15// CHECK-NEXT: D
16// CHECK-NEXT: E
17// CHECK-NEXT: F
18// CHECK-NEXT: 10
19
20//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16], stride=4, count=256):name=input
21RWByteAddressBuffer input;
22
23//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer
24RWStructuredBuffer<uint32_t> outputBuffer;
25
26using namespace linalg;
27
28typealias CoopMatType = CoopMat<uint32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse.MatrixAccumulator>;
29
30groupshared float[256] tempShared;
31
32[numthreads(32, 1, 1)]
33void computeMain()
34{
35    let stride = 16;
36
37    let mat = coopMatLoad<uint32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse.MatrixAccumulator, CoopMatMatrixLayout.RowMajor>(input, 0, stride);
38    mat.Store<CoopMatMatrixLayout.RowMajor>(tempShared, 0, stride);
39
40    let result = CoopMatType.Load<CoopMatMatrixLayout.RowMajor>(tempShared, 0, stride);
41    result.Store<CoopMatMatrixLayout.RowMajor>(outputBuffer, 0, stride);
42}