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(filecheck-buffer=CHECK):-shaderobj -output-using-type 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj -output-using-type 4//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj -output-using-type 5 6struct Functor : IFunc<int, int, bool> 7{ 8 int operator()(int p, bool t) 9 { 10 return p + 1; 11 } 12} 13 14struct MutatingFunctor : IMutatingFunc<int, int, bool> 15{ 16 int data = 0; 17 [mutating] 18 int operator()(int p, bool t) 19 { 20 data++; 21 return p + 1; 22 } 23} 24 25int apply(IMutatingFunc<int, int, bool> f, int p) 26{ 27 return f(p, true); 28} 29 30//TEST_INPUT:ubuffer(data=[0 3 2 2], stride=4):out,name=outputBuffer 31RWStructuredBuffer<uint> outputBuffer; 32 33[numthreads(1, 1, 1)] 34void computeMain(uint tid: SV_DispatchThreadID) 35{ 36 // CHECK: 2 37 outputBuffer[0] = apply(MutatingFunctor(), 1); 38 // CHECK: 3 39 outputBuffer[1] = apply(Functor(), 2); 40}