yum-mirror/slang

Making it easier to work with shaders

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

Sai Praveen BangaruAssorted auto-diff enhancements for increased performance & more streamlined auto-diff results (#5394)b61be5e6f

master
953 B34 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//DISABLE_TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates
5
6//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
7RWStructuredBuffer<float> outputBuffer;
8
9typedef DifferentialPair<float> dpfloat;
10typedef float.Differential dfloat;
11
12[BackwardDifferentiable]
13float g(float y)
14{
15    float result = 2.0f * y;
16    return result * result;
17}
18
19[BackwardDifferentiable]
20float f(float x)
21{
22    return 3.0f * g(2.0f * x);
23}
24
25[numthreads(1, 1, 1)]
26void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
27{
28    dpfloat dpa = dpfloat(1.0, 0.0);
29
30    __bwd_diff(f)(dpa, 1.0f);
31    outputBuffer[0] = dpa.d; // Expect: 96.0
32}
33
34//CHK-NOT: note