yum-mirror/slang

Making it easier to work with shaders

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

Ellie HermaszewskaDo no fail on missing no_diff annotation on non-differentiable (inputs and output) function outputs (#6737)83a42cb76

master
595 B29 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu
2
3// CHECK: 40000000
4
5//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
6
7// Non-differentiable function with no_diff parameters and return type
8no_diff float targetFunc(no_diff float x)
9{
10    return x * 2.0f;
11}
12
13[Differentiable]
14float errorForward(no_diff float x)
15{
16    float result = targetFunc(x);
17    return result;
18}
19
20RWStructuredBuffer<float> outputBuffer;
21
22[numthreads(1, 1, 1)]
23void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
24{
25    float input = 1.0f;
26
27    outputBuffer[0] = errorForward(input);
28}
29