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
966 B34 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly
2
3// CHECK: type: float
4// CHECK-NEXT: 3.000000
5// CHECK-NEXT: 6.000000
6// CHECK-NEXT: 9.000000
7// CHECK-NEXT: 12.000000
8
9//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4, count=256):name=inputBuffer
10StructuredBuffer<float> inputBuffer;
11
12//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer
13RWStructuredBuffer<float> outputBuffer;
14
15using namespace linalg;
16
17typealias CoopMatType = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>;
18
19CoopMatType doubleCoopmat(CoopMatType mat)
20{
21    return mat * 3.0;
22}
23
24[numthreads(32, 1, 1)]
25void computeMain()
26{
27    let stride = 16;
28    let matrixLayout = CoopMatMatrixLayout::RowMajor;
29
30    let mat = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(inputBuffer, 0, stride);
31
32    let result = doubleCoopmat(mat);
33    result.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, 4);
34}