yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
20bd48659
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], stride=4):out,name=outputBuffer 6RWStructuredBuffer<float> outputBuffer; 7 8float rng(int state, float x) 9{ 10 return state + x; 11} 12 13[BackwardDerivativeOf(rng)] 14void rng_bwd(int inState, inout DifferentialPair<float> x, float dOut) 15{ 16 x = diffPair(x.p, (float)inState + dOut - 1.0); 17} 18 19[numthreads(1, 1, 1)] 20void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 21{ 22 var x = diffPair(2.0, 1.0); 23 24 __bwd_diff(rng)(4, x, 3.0); 25 26 outputBuffer[0] = x.d; // should be 6 27 28}