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: float 4// CHECK-NEXT: 1.000000 5// CHECK-NEXT: 2.000000 6// CHECK-NEXT: 3.000000 7// CHECK-NEXT: 4.000000 8// CHECK-NEXT: 5.000000 9// CHECK-NEXT: 6.000000 10// CHECK-NEXT: 7.000000 11// CHECK-NEXT: 8.000000 12 13//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4, count=256),name=input1 14ByteAddressBuffer input1; 15 16//TEST_INPUT:ubuffer(data=[5.0 6.0 7.0 8.0], stride=4, count=256),name=input2 17ByteAddressBuffer input2; 18 19//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer 20RWStructuredBuffer<float> outputBuffer; 21 22using namespace linalg; 23 24typealias CoopMatType = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>; 25 26struct MyStruct 27{ 28 CoopMatType mat1; 29 CoopMatType mat2; 30}; 31 32[numthreads(32, 1, 1)] 33void computeMain() 34{ 35 let stride = 16; 36 let matrixLayout = CoopMatMatrixLayout::RowMajor; 37 38 MyStruct s; 39 s.mat1 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input1, 0, stride); 40 s.mat2 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input2, 0, stride); 41 42 s.mat1.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, stride); 43 s.mat2.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 4, stride); 44}