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 8__generic<let C : int> 9struct Foo : IDifferentiable 10{ 11 float x[C]; 12}; 13 14[Differentiable] 15Foo<3> getFoo(float x) 16{ 17 return { { x, x, x } }; 18} 19 20[Differentiable] 21float foobar(float x) 22{ 23 int i = 3 * int(floor(x)); 24 Foo<3> foo = getFoo(x); 25 return foo.x[i] * foo.x[i]; 26} 27 28[numthreads(1, 1, 1)] 29void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) 30{ 31 { 32 float a = 0.5; 33 var d = fwd_diff(foobar)(diffPair(a, 1.0)).d; 34 outputBuffer[0] = d; 35 } 36}