blob: 6b1435e5bb4180405c2f03c95a12468d61d9aace (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
//TEST:SIMPLE(filecheck=CHK):-stage compute -entry computeMain -target hlsl
//TEST:SIMPLE(filecheck=CHK):-target cuda -line-directive-mode none
//CHK: struct DiffPair_1
//CHK-NOT: struct DiffPair_2
RWTexture2D<float> gOutputColor;
struct ShadingFrame : IDifferentiable
{
float3 T;
}
[Differentiable]
float computeRay()
{
float3 dir = 1.f;
return dot(dir, dir);
}
[Differentiable]
float paramRay()
{
DifferentialPair<float> dpDir = fwd_diff(computeRay)();
return dpDir.p;
}
[Shader("compute")]
[NumThreads(1, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
DifferentialPair<float> dpColor = fwd_diff(paramRay)();
gOutputColor[0] = dpColor.p;
}
|