yum-mirror/slang

Making it easier to work with shaders

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

Yong HeFix transposeCall. (#2669)0ef7aa85d

master
824 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:-cpu -compute -output-using-type -shaderobj
4
5//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
6RWStructuredBuffer<float> outputBuffer;
7
8[BackwardDifferentiable]
9void assign(inout float rs, float v)
10{
11    rs = v;
12}
13
14[BackwardDifferentiable]
15void f(inout float p, float x)
16{
17    assign(p, x);
18}
19
20[numthreads(1, 1, 1)]
21void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
22{
23    var x = diffPair(5.0, 0.0);
24    var pp = diffPair(1.0, 3.0);
25    __bwd_diff(f)(pp, x);
26
27    outputBuffer[0] = pp.p; // should be 1, since bwd_diff does not write back new primal val.
28    outputBuffer[1] = x.d; // 3
29}