yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-dx12 -compute -shaderobj -output-using-type -xslang -matrix-layout-column-major 2//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-dx12 -compute -shaderobj -output-using-type -xslang -matrix-layout-row-major 3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type -xslang -matrix-layout-column-major 4//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type -xslang -matrix-layout-row-major 5//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-mtl -compute -output-using-type -xslang -matrix-layout-column-major 6//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-mtl -compute -output-using-type -xslang -matrix-layout-row-major 7//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-wgpu -compute -output-using-type -xslang -matrix-layout-column-major 8//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-wgpu -compute -output-using-type -xslang -matrix-layout-row-major 9 10//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer 11RWStructuredBuffer<int> outputBuffer; 12 13int selectDims<int N, int M>(bool cond) 14{ 15 return select( 16 matrix<bool, N, M>(cond), 17 matrix<int, N, M>(1), 18 matrix<int, N, M>(0) 19 )[0][0]; 20} 21 22int selectDimsDigit<int N, int M, int D>(int x) 23{ 24 return selectDims<N, M>(((x >> D) & 0b1) == 0b1) << D; 25} 26 27[numthreads(1, 1, 1)] 28void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 29{ 30 int x = 324; 31 32 int s = 0; 33 s += selectDimsDigit<2, 2, 0>(x); 34 s += selectDimsDigit<2, 3, 1>(x); 35 s += selectDimsDigit<2, 4, 2>(x); 36 s += selectDimsDigit<3, 2, 3>(x); 37 s += selectDimsDigit<3, 3, 4>(x); 38 s += selectDimsDigit<3, 4, 5>(x); 39 s += selectDimsDigit<4, 2, 6>(x); 40 s += selectDimsDigit<4, 3, 7>(x); 41 s += selectDimsDigit<4, 4, 8>(x); 42 43 // CHK: 324 44 outputBuffer[0] = s; 45}