yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
86fc50c50
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:-cpu -compute -output-using-type -shaderobj 4 5//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer 6RWStructuredBuffer<float> outputBuffer; 7 8float original(float x) 9{ 10 return x * x; 11} 12 13[PrimalSubstituteOf(original)] 14[BackwardDifferentiable] 15float primalSubst(float x) 16{ 17 return 2.0f * x * x; 18} 19 20[numthreads(1, 1, 1)] 21void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 22{ 23 var a = diffPair(3.0, 1.0); 24 __bwd_diff(original)(a, 1.0); 25 outputBuffer[0] = a.d; // Expect: 12.0 26 outputBuffer[1] = __fwd_diff(original)(diffPair(3.0, 1.0)).p; // Expect: 18.0 27}