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):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -output-using-type 3//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -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 10struct A : IDifferentiable 11{ 12 float x; 13 no_diff float y; 14} 15 16[BackwardDifferentiable] 17float f(A obj) 18{ 19 return obj.y * obj.x * obj.x + obj.y * obj.y; 20} 21 22[numthreads(1, 1, 1)] 23void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 24{ 25 A a = {2.0, 3.0}; 26 var p = diffPair(a); 27 let rs = __bwd_diff(f)(p, 1.0); 28 outputBuffer[0] = p.d.x; 29}