yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
d10732742
master
1// Tests automatic synthesis of Differential type and method requirements. 2 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type 4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type 5//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type 6 7//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer 8RWStructuredBuffer<float> outputBuffer; 9 10interface IFoo 11{ 12 [BackwardDifferentiable] 13 float f(float v); 14} 15 16struct B : IFoo 17{ 18 [TreatAsDifferentiable] 19 float f(float v) 20 { 21 return v * v; 22 } 23} 24 25[BackwardDifferentiable] 26float use(IFoo o, float x) 27{ 28 return o.f(x); 29} 30 31[numthreads(1, 1, 1)] 32void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 33{ 34 B b; 35 var p = diffPair(1.0); 36 __bwd_diff(use)(b, p, 1.0); 37 outputBuffer[0] = p.d; 38}