yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
d10732742
master
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 8typedef DifferentialPair<float> dpfloat; 9 10[ForwardDifferentiable] 11void h(float x, float y, out float result) 12{ 13 float m = x + y; 14 float n = x - y; 15 result = m * n + 2 * x * y; 16} 17 18 19[numthreads(1, 1, 1)] 20void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 21{ 22 float x = 2.0; 23 float y = 3.5; 24 float dx = 1.0; 25 float dy = 0.5; 26 27 dpfloat dresult; 28 __fwd_diff(h)(dpfloat(x, dx), dpfloat(y, dy), dresult); 29 30 outputBuffer[0] = dresult.d; // Expect: 9.5 31 32}