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: 4.000000 6// CHECK-NEXT: 9.000000 7// CHECK-NEXT: 16.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 19static const int stride = 16; 20static const CoopMatMatrixLayout matrixLayout = CoopMatMatrixLayout::RowMajor; 21 22void squareCoopMatElements(CoopMatType mat) 23{ 24 for (int i = 0; i < 4; ++i) 25 { 26 mat[i] = mat[i] * mat[i]; 27 } 28 mat.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, stride); 29} 30 31[numthreads(32, 1, 1)] 32void computeMain() 33{ 34 let mat = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(inputBuffer, 0, stride); 35 squareCoopMatElements(mat); 36}