yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeMake `DifferentialPair` able to nest. (#2477)cbc1eff56

master
390 B21 linesraw
1//TEST:LANG_SERVER:
2RWStructuredBuffer<float> outputBuffer;
3
4[ForwardDifferentiable]
5float f(float x)
6{
7    return x * x;
8}
9
10[ForwardDifferentiable]
11float df(float x)
12{
13//HOVER:14,17
14    return __fwd_diff();
15}
16
17[numthreads(1, 1, 1)]
18void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
19{
20    outputBuffer[0] = __fwd_diff(df)(DifferentialPair<float>(x, 1.0)).d(); // Expect: 2.0
21}