yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
d10732742
master
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type 2//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type 4 5//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 6RWStructuredBuffer<float> outputBuffer; 7 8struct NonDiff 9{ 10 float a; 11} 12 13void getCode(uint2 x, out Array<float, 2> v) 14{ 15 for (int i = 0; i < 8; i++) 16 v[i] = (float)i; 17} 18 19[BackwardDerivativeOf(getCode)] 20void getCode_bwd(uint2 x, Array<float, 2> dout) 21{ 22 outputBuffer[0] = dout[0]; 23} 24 25[numthreads(1, 1, 1)] 26void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) 27{ 28 float a = 10.0; 29 float inArray[2] = { 1, 2 }; 30 __bwd_diff(getCode)(uint2(1,2), inArray); 31}