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(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type 2//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-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 8typedef DifferentialPair<float> dpfloat; 9 10[Differentiable] 11float test(float x, no_diff out float y) 12{ 13 if (x == 1.0) 14 y = 0.0; 15 return x * x; 16} 17 18[Differentiable] 19float caller(float x, no_diff out float y) 20{ 21 return test(x, y); 22} 23 24[numthreads(1, 1, 1)] 25void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 26{ 27 var p = diffPair(3.0, 0.0); 28 bwd_diff(caller)(p, 1.0); 29 outputBuffer[dispatchThreadID.x] = p.d; 30 // CHECK: 6.0 31}