yum-mirror/slang

Making it easier to work with shaders

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

Yong HeUse property for `DifferentialPair` accessors. (#2493)a20f6a030

master
576 B26 linesraw
1//TEST_IGNORE_FILE:
2
3//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
4RWStructuredBuffer<float> outputBuffer;
5
6import test_intrinsics_jvp;
7
8typedef DifferentialPair<float> dpfloat;
9typedef float.Differential dfloat;
10
11[ForwardDifferentiable]
12float f(float x)
13{
14    return pow_(x, 2.0);
15}
16
17[numthreads(1, 1, 1)]
18void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
19{
20    {
21        dpfloat dpa = dpfloat(2.0, 1.0);
22        dpfloat dpb = dpfloat(1.5, 1.0);
23
24        outputBuffer[0] = __fwd_diff(f)(dpa).d;                      // Expect: 2
25    }
26}