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