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
770 B29 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 NonDiff
9{
10    float a;
11}
12
13[BackwardDifferentiable]
14bool myFunc(NonDiff fIn, inout float x)
15{
16    x = pow(x, fIn.a);
17    return x > 100.f;
18}
19
20[numthreads(1, 1, 1)]
21void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
22{
23    float a = 3.0;
24    NonDiff fIn = { a };
25    DifferentialPair<float> dpx = DifferentialPair<float>(4.f, 1.f);
26    __bwd_diff(myFunc)(fIn, dpx);
27
28    outputBuffer[0] = dpx.d;
29}