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: uint32_t 4// CHECK-NEXT: 0 5// CHECK-NEXT: 1 6// CHECK-NEXT: 1 7 8//TEST_INPUT:ubuffer(data=[1.0 2.0 3.0 4.0], stride=4, count=256),name=input1 9ByteAddressBuffer input1; 10 11//TEST_INPUT:ubuffer(data=[1.0 3.0 2.0 4.0], stride=4, count=256),name=input2 12ByteAddressBuffer input2; 13 14//TEST_INPUT:ubuffer(data=[0 0 0], stride=4):out,name=outputBuffer 15RWStructuredBuffer<uint> outputBuffer; 16 17using namespace linalg; 18 19typealias CoopMatType = CoopMat<float, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse::MatrixAccumulator>; 20 21[numthreads(32, 1, 1)] 22void computeMain(uint3 threadIndex : SV_DispatchThreadID) 23{ 24 let stride = 4; 25 let matrixLayout = CoopMatMatrixLayout::RowMajor; 26 27 let mat1 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input1, 0, stride); 28 let mat2 = CoopMatType.Load<CoopMatMatrixLayout::RowMajor>(input2, 0, stride); 29 30 uint32_t equals = mat1 == mat2 ? 1 : 0; 31 uint32_t lessThan = mat1 < mat2 ? 1 : 0; 32 uint32_t lessThanOrEquals = mat1 <= mat2 ? 1 : 0; 33 34 outputBuffer[0] = equals; 35 outputBuffer[1] = lessThan; 36 outputBuffer[2] = lessThanOrEquals; 37}