yum-mirror/slang

Making it easier to work with shaders

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

Harsh Aggarwal (NVIDIA)Fix 7723 - Add autodiff tests (#7919)d10732742

master
851 B31 linesraw
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
2//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
3//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type
4
5//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
6RWStructuredBuffer<float> outputBuffer;
7
8struct AggType : IDifferentiable
9{
10    float field1;
11    float field2;
12}
13
14[BackwardDifferentiable]
15AggType makeTypeWithNonDiffOps(no_diff float f1, float f2)
16{
17    AggType v = { f1, f2 };
18    return v;
19}
20
21[numthreads(1, 1, 1)]
22void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
23{
24    AggType v = { 0, 2.0 };
25    AggType.Differential dv = { 1.3, 4.2 };
26
27    var f2pair = diffPair(2.0, 0.0); 
28
29    __bwd_diff(makeTypeWithNonDiffOps)(1.0, f2pair, dv);
30    outputBuffer[0] = f2pair.d;
31}