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: 2.000000 5// CHECK-NEXT: 4.000000 6// CHECK-NEXT: 6.000000 7// CHECK-NEXT: 8.000000 8 9// XXX FW: having out instead of in below actually properly creates two output buffers, nice 10//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4, count=256):name=inputBuffer 11StructuredBuffer<float> inputBuffer; 12 13//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer 14RWStructuredBuffer<float> outputBuffer; 15 16using namespace linalg; 17 18typealias CoopMatType = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>; 19 20void doubleCoopMat(CoopMatType mat, out CoopMatType result) 21{ 22 result = mat * 2.0; 23} 24 25[numthreads(32, 1, 1)] 26void computeMain() 27{ 28 let stride = 16; 29 let matrixLayout = CoopMatMatrixLayout::RowMajor; 30 31 let mat = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(inputBuffer, 0, stride); 32 33 CoopMatType result; 34 doubleCoopMat(mat, result); 35 result.Store<CoopMatMatrixLayout::RowMajor>(outputBuffer, 0, stride); 36}