yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
a670bafc1
master
1//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): 2 3float someNoDiffFunc(float x, no_diff float y) 4{ 5 return x * x + y * y; 6} 7 8// Previously, when we call a no-diff function side a differntiable function, we will have to use no_diff to tell compiler that this is intended. 9// However, if the parameter is just a constant, there is no need to use no_diff, because constant won't carry any derivative information. 10// Therefore, this test is to check we won't report any error when the parameter is a constant in this case. 11[Differentiable] 12float eval(float x) 13{ 14 // CHECK-NOT: ([[# @LINE+1]]): error 41020 15 return exp(x) - someNoDiffFunc(1.0f, x); 16} 17 18[Differentiable] 19float eval1(float x) 20{ 21 // CHECK: ([[# @LINE+1]]): error 41020 22 return exp(x) - someNoDiffFunc(x, 1.0); 23} 24 25RWStructuredBuffer<float> output; 26 27[shader("compute")] 28[numthreads(1,1,1)] 29void computeMain(uint id : SV_DispatchThreadID) 30{ 31 var x = diffPair(2.0f); 32 bwd_diff(eval)(x, 1.0f); 33 34 output[0] = x.d; 35 36 var x1 = diffPair(2.0f); 37 bwd_diff(eval1)(x1, 1.0f); 38 output[1] = x1.d; 39} 40