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.3 KiB31 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly
2
3// CHECK: type: float
4// CHECK-NEXT: 2.000000
5// CHECK-NEXT: 4.000000
6// CHECK-NEXT: 6.000000
7// CHECK-NEXT: 8.000000
8
9//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4, count=256):out,name=outputBuffer
10RWStructuredBuffer<float> outputBuffer;
11
12//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4, count=256),name=input
13ByteAddressBuffer input;
14
15using namespace linalg;
16
17[numthreads(32, 1, 1)]
18void computeMain()
19{
20    let stride = 16;
21    let matrixLayout = CoopMatMatrixLayout::RowMajor;
22
23    let intMat = CoopMat<int, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>.Load<CoopMatMatrixLayout::RowMajor>(input, 0, stride);
24    let floatMat = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>(intMat);
25    let uintMat = CoopMat<uint, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>(intMat);
26    let halfMat = CoopMat<half, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>(uintMat);
27    let floatMat2 = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>(halfMat);
28
29    let result = floatMat + floatMat2;
30    result.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, stride);
31}