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=CHK_ROW):-vk -output-using-type -emit-spirv-directly -render-feature cooperative-matrix-reductions -Xslang -DTEST_MODE=0 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK_COLUMN):-vk -output-using-type -emit-spirv-directly -render-feature cooperative-matrix-reductions -Xslang -DTEST_MODE=1 3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK_ROW_AND_COLUMN):-vk -output-using-type -emit-spirv-directly -render-feature cooperative-matrix-reductions -Xslang -DTEST_MODE=2 4//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK_2X2):-vk -output-using-type -emit-spirv-directly -render-feature cooperative-matrix-reductions -Xslang -DTEST_MODE=3 5 6//CHK_ROW-COUNT-8: 36 7 8//CHK_COLUMN:1 9//CHK_COLUMN-NEXT:2 10//CHK_COLUMN-NEXT:3 11//CHK_COLUMN-NEXT:4 12//CHK_COLUMN-NEXT:5 13//CHK_COLUMN-NEXT:6 14//CHK_COLUMN-NEXT:7 15//CHK_COLUMN-NEXT:8 16 17//CHK_ROW_AND_COLUMN: 36 18 19//CHK_2X2:3 20//CHK_2X2:7 21//CHK_2X2:11 22//CHK_2X2:15 23 24//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8], stride=4, count=256),name=buf 25StructuredBuffer<int32_t> inputBuffer; 26 27//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer 28RWStructuredBuffer<int32_t> outputBuffer; 29 30using namespace linalg; 31 32int32_t CombineOp(int32_t lhs, int32_t rhs) 33{ 34 return lhs + rhs; 35} 36 37[numthreads(32, 1, 1)] 38void computeMain() 39{ 40 let stride = 16; 41 let mat = coopMatLoad<int32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse.MatrixAccumulator, CoopMatMatrixLayout.RowMajor>(inputBuffer, 0, stride); 42#if TEST_MODE == 0 43 let result = mat.ReduceRow<8>(CombineOp); 44#elif TEST_MODE == 1 45 let result = mat.ReduceColumn<8>(CombineOp); 46#elif TEST_MODE == 2 47 let result = mat.ReduceRowAndColumn<8, 8>(CombineOp); 48#elif TEST_MODE == 3 49 let result = mat.Reduce2x2(CombineOp); 50#endif 51 result.Store<CoopMatMatrixLayout.RowMajor>(outputBuffer, 0, stride); 52}