yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
d58243d90
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly 2 3// CHECK: type: int32_t 4// CHECK-NEXT: 1 5// CHECK-NEXT: 3 6// CHECK-NEXT: 5 7// CHECK-NEXT: 7 8 9//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer 10RWStructuredBuffer<int32_t> outputBuffer; 11 12//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4, count=256),name=input1 13ByteAddressBuffer input1; 14 15//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4, count=256),name=input2 16ByteAddressBuffer input2; 17 18using namespace linalg; 19 20typealias CoopMatType = CoopMat<int32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse.MatrixAccumulator>; 21 22[numthreads(32, 1, 1)] 23void computeMain() 24{ 25 let stride = 16; 26 let matrixLayout = CoopMatMatrixLayout::RowMajor; 27 28 let mat1 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input1, 0, stride); 29 let mat2 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input2, 0, stride); 30 let result = mat1 + mat2; 31 32 result.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, stride); 33} 34