yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
3618f7a4c
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj -output-using-type 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -cuda -shaderobj -output-using-type 4 5//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 6RWStructuredBuffer<float> outputBuffer; 7 8interface IFoo : IDifferentiable 9{ 10 [Differentiable] 11 __init(); 12 13 float compute(float y); 14} 15 16struct Impl : IFoo 17{ 18 float x; 19 [Differentiable] 20 __init() 21 { 22 x = 4.0; 23 } 24 25 float compute(int id) { return outputBuffer[id] = detach(x);} 26} 27 28float test<T : IFoo>(int id) 29{ 30 T t; 31 return t.compute(id); 32} 33 34[numthreads(1, 1, 1)] 35void computeMain(uint id : SV_DispatchThreadID) 36{ 37 // CHECK: 4.0 38 test<Impl>(id); 39}